Loading repository data…
Loading repository data…
kumarsonu676 / repository
A scalable FastAPI project template with async SQLAlchemy, PostgreSQL, and repository pattern implementation. Features JWT authentication, comprehensive error handling, and follows best practices for building production-ready APIs. Includes modular architecture, dependency injection, Pydantic validation, and Alembic migrations.
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
A scalable FastAPI project template with SQLAlchemy, PostgreSQL, and best practices for building robust APIs.
.
├── alembic/ # Database migrations
├── app/ # Application code
│ ├── api/ # API routes
│ │ └── v1/ # API version 1
│ │ ├── endpoints/ # API endpoints
│ │ └── api.py # API router
│ ├── core/ # Core configuration
│ ├── db/ # Database models and session
│ ├── dependencies/ # Dependency injection
│ ├── exceptions/ # Custom exceptions
│ ├── middlewares/ # Middleware functions
│ ├── models/ # SQLAlchemy models
│ ├── repositories/ # Data access layer
│ ├── schemas/ # Pydantic schemas
│ ├── services/ # Business logic
│ ├── utils/ # Utility functions
│ └── main.py # FastAPI application
├── docs/ # Documentation
├── tests/ # Tests
│ ├── integration/ # Integration tests
│ └── unit/ # Unit tests
├── .env.example # Example environment variables
├── .gitignore # Git ignore file
├── docker-compose.yml # Docker Compose configuration
├── Dockerfile # Docker configuration
├── main.py # Application entry point
├── pytest.ini # Pytest configuration
├── README.md # Project documentation
├── requirements.txt # Python dependencies
└── setup.py # Package setup
git clone https://github.com/kumarsonu676/python-fastapi-starter-api-project
cd python-fastapi-starter-api-project
py -m venv venv
venv\Scripts\activate #venv\scripts\activate for windows
pip install -r requirements.txt
OR
py -m pip install -r requirements.txt
#to update requirements.txt file =>
py -m pip freeze > requirements.txt
.env file based on .env.example:cp .env.example .env
python main.py
OR
py -m main
git clone https://github.com/kumarsonu676/python-fastapi-starter-api-project
cd python-fastapi-starter-api-project
.env file based on .env.example:cp .env.example .env
docker-compose up -d
The API will be available at http://localhost:8000.
API documentation is available at:
app/api/v1/endpoints/app/schemas/app/models/ if neededapp/services/app/repositories/ for data accessapp/api/v1/api.py# Initialize migrations (first time only)
py -m alembic init alembic
# Create a new migration
py -m alembic revision --autogenerate -m "Migration message"
# Run migrations
py -m alembic upgrade head
# For the first migration— When it has no parent (Revises: is empty).
py -m alembic upgrade base:<revision_name> --sql > migration_script.sql
# If you want to generate a script that can be used to downgrade from the current revision to the base revision, you can use:
py -m alembic downgrade base --sql > migration_script.sql
# For the subsequent migration— When it has a parent (Revises: <revision_name>).
# This will generate a script that can be used to upgrade from the previous revision to the current one.
py -m alembic upgrade <from_rev>:<to_rev> --sql > migration_script.sql
# If you want the SQL to downgrade from to_rev back to from_rev, just reverse the order:
py -m alembic downgrade <to_rev>:<from_rev> --sql > migration_script.sql
# To list all revisions and order:
py -m alembic history --verbose
# To show the current revision:
py -m alembic current
# To inspect details of a specific revision:
py -m alembic show <revision_name>
Key environment variables for configuration:
API_V1_STR: API version prefixSECRET_KEY: Secret key for JWT tokensPOSTGRES_SERVER: PostgreSQL server addressPOSTGRES_USER: PostgreSQL usernamePOSTGRES_PASSWORD: PostgreSQL passwordPOSTGRES_DB: PostgreSQL database nameThis project is licensed under the MIT License - see the LICENSE file for details.
Activate the virtual environment:
# On Windows
venv\Scripts\activate
# On Linux/Mac
source venv/bin/activate
Run the application:
python main.py
Access the API at http://localhost:8000