Skip to main content

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
from repository_core.schemas import BaseSchema

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 repository-core 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for repository-core 0.2.0
File Size Uploaded
repository_core-0.2.0.tar.gz 7.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for repository-core 0.2.0
File Interpreter ABI Platform
repository_core-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 18.3 kB

Release files / repository_core-0.2.0.tar.gz

Download URL repository_core-0.2.0.tar.gz
Size 7.8 kB
Tags Source
SHA-256 checksum
How to use checksums
e269b6ad2caeccfb5b761f8b8bfea0ff4453083c0992ccc01a19419210aa651f
BLAKE2b-256 checksum
How to use checksums
206d16b36266db9a772e898a9058f3caea775ddd7a76c08bf5d2558214fed816
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.2 CPython/3.13.3 Darwin/23.6.0

Release files / repository_core-0.2.0-py3-none-any.whl

Download URL repository_core-0.2.0-py3-none-any.whl
Size 10.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6c3670f0d35f01190ba4114521f47fa583089157824a1191502319cf28ccfeab
BLAKE2b-256 checksum
How to use checksums
a688f35c1398953f6f7c8d8f50d703187a715d4eda8a27a56cf6606a5e9db578
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.2 CPython/3.13.3 Darwin/23.6.0

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page