Python Technology Stack
IMPORTANT NOTE: This document is not final; it is under review.
This document outlines the specific standards and conventions for developing backend services with Python.
Core Stack
- Language: Python
- Framework: FastAPI is the required web framework.
- Database: PostgreSQL
- ORM: SQLAlchemy (with
asyncio) is required for all database interactions. - Type Hinting: Code must include type hints, and
mypyshould be used for static analysis.
Testing
- Standard: Pytest is the required framework for all testing.
Naming Conventions
- Variables, Functions, Files:
snake_case. - Classes:
PascalCase.
Dependency Management
- Standard: Poetry is the required tool for dependency management and packaging.
Directory Structure
A standard structure for FastAPI projects is as follows:
project_name/
├── alembic/ # Database migrations
├── tests/ # All tests
├── project_name/
│ ├── api/ # API endpoints and routers
│ │ └── v1/
│ │ └── endpoints/
│ │ └── users.py
│ ├── core/ # Configuration, startup events
│ ├── db/ # Database session, models
│ ├── schemas/ # Pydantic schemas
│ ├── services/ # Business logic
│ └── main.py # FastAPI app instantiation
├── .env
├── poetry.lock
└── pyproject.toml