Production-grade REST API for inventory management — FastAPI + SQLAlchemy 2.0 + PostgreSQL + JWT.
A reference implementation of an enterprise-grade backend that recruiters and tech leads can actually clone and run in 60 seconds.
It demonstrates the patterns I use in production work: layered architecture, migrations as code, typed ORM, JWT auth with role separation, and a Dockerized dev environment that mirrors prod.
flowchart TB
Client[Client] -->|HTTPS + JWT| API[FastAPI App]
API --> Routers[Routers Layer]
Routers --> Services[Service Layer]
Services --> Repo[Repository Layer]
Repo --> ORM[SQLAlchemy 2.0]
ORM --> DB[(PostgreSQL)]
Alembic[Alembic Migrations] -.-> DB
style API fill:#009688,color:#fff
style DB fill:#336791,color:#fff
- JWT authentication with access / refresh tokens and role-based access control
- SQLAlchemy 2.0 typed ORM (no legacy
QueryAPI) - Alembic migrations checked into the repo, autogenerated and reviewed
- Pydantic v2 schemas for request / response validation
- Async request handlers (
async def) - Dependency injection for DB session, current user, settings
- Layered architecture: routers → services → repositories → models
- Docker Compose for full local stack (api + db) in one command
- OpenAPI / Swagger auto-docs at
/docs
git clone https://github.com/franamaro-dev/Store-Inventory-API.git
cd Store-Inventory-API
cp .env.example .env
docker compose up --buildAPI at http://localhost:8000/docs
docker compose exec api alembic upgrade headdocker compose exec api pytest -v| Concern | Tool |
|---|---|
| Framework | FastAPI |
| ORM | SQLAlchemy 2.0 (typed) |
| Migrations | Alembic |
| Validation | Pydantic v2 |
| Auth | python-jose (JWT), passlib (bcrypt) |
| Database | PostgreSQL 16 |
| Container | Docker + docker-compose |
| Testing | pytest, httpx, pytest-asyncio |
.
├── app/
│ ├── api/ # routers (FastAPI endpoints)
│ ├── core/ # config, security, dependencies
│ ├── models/ # SQLAlchemy models
│ ├── schemas/ # Pydantic schemas
│ ├── services/ # business logic
│ └── main.py # app factory
├── alembic/ # migrations
├── tests/
├── docker-compose.yml
├── Dockerfile
└── requirements.txt
- Role-based field-level permissions
- Soft-delete with audit log
- Background jobs (Celery + Redis)
- Prometheus metrics endpoint
- OpenTelemetry tracing
MIT © Francisco Amaro Prieto
Built by Francisco Amaro — Backend Engineer & SOC L1 Analyst LinkedIn · Email