Repository Core
A powerful and flexible base repository and service utilities package for SQLAlchemy-backed FastAPI applications.
Overview
Repository Core provides a set of base classes and utilities to help you implement clean and maintainable repository and service patterns in your FastAPI applications. It's designed to work seamlessly with SQLAlchemy and follows best practices for database operations and business logic separation.
Features
- Base repository classes for common CRUD operations
- Service layer abstractions for business logic
- SQLAlchemy model utilities
- Exceptions
- Schema validation
- Utility functions for common operations
Installation
pip install repository-core
Requirements
- Python >= 3.13
- FastAPI >= 0.115.2
- SQLAlchemy >= 2.0.40
Usage Guide
1. Setting Up Base Models
from repository_core.models import BaseModel
class User(BaseModel):
__tablename__ = "users"
email = Column(String, unique=True, nullable=False)
name = Column(String)
2. Creating a Repository
from repository_core.repository import BaseRepository
from repository_core.models import BaseModel
class UserRepository(BaseRepository):
def __init__(self, session):
super().__init__(session, User) #Access all the methods of base-repository
# Add custom repository methods here
async def get_by_email(self, email: str) -> Optional[User]:
return await self.get_one(User.email == email)
3. Implementing a Service
from repository_core.services import BaseService
class UserService(BaseService):
def __init__(self, repository: UserRepository):
super().__init__(repository)
# Add custom service methods here
async def create_user(self, data: UserCreate) -> User:
return await self.create(data)
Project Structure
repository_core/
├── models/ # Base model classes
├── repository/ # Base repository implementations
├── services/ # Base service implementations
├── schemas/ # Pydantic schemas
├── exceptions/ # Custom exceptions
└── utils/ # Utility functions
License
This project is licensed under the MIT License - see the LICENSE file for details.
Metadata
Release files for abs-repository-core 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| abs_repository_core-0.5.0.tar.gz | 8.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| abs_repository_core-0.5.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.1 kB
Release files / abs_repository_core-0.5.0.tar.gz
| Download URL | abs_repository_core-0.5.0.tar.gz |
|---|---|
| Size | 8.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
447d212f5a6d361bf97f3557e8b79109dc252188412f408b483052f5c629d2c7
|
|
BLAKE2b-256 checksum How to use checksums |
1d0fb18da783c1425011e45a5e2019b277ba2b411cdc7163ea36b872719e3e32
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.3 CPython/3.13.5 Darwin/24.5.0
|
Release files / abs_repository_core-0.5.0-py3-none-any.whl
| Download URL | abs_repository_core-0.5.0-py3-none-any.whl |
|---|---|
| Size | 10.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fbce8c28db6223bf9c006c2fdf096a0a19b76aaa4f604e53e5d2c47430682631
|
|
BLAKE2b-256 checksum How to use checksums |
df16d496e4535084654afe251cdd5b408396e1f5e9031fe2ffbef8a1ee08c318
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.3 CPython/3.13.5 Darwin/24.5.0
|