Backend API for the Quimba platform. This service exposes endpoints for laboratory workflows, consultations, pharmacy, sales, transactions, service bookings, and supporting administrative operations. It is built with FastAPI, SQLAlchemy, and Redis.
- Laboratory services, queues, and results
- Service booking and consultation flows
- Transactions, payments, bundles, and referrals
- Pharmacy operations and sales
- Redis caching for frequently accessed endpoints
- OpenAPI docs via FastAPI
- Python 3.11
- FastAPI + Uvicorn
- SQLAlchemy + Alembic
- PostgreSQL
- Redis
main.py- FastAPI app entrypointdb.py- database engine/session setuprouters/- API routesrepos/- data access and domain logicmodels/- SQLAlchemy modelsdtos/- Pydantic DTOsalembic/- migrationscache/- Redis integrationtests/- test suite
- Python 3.11
- PostgreSQL
- Redis
Install dependencies:
python -m venv venv
source venv/bin/activate
pip install -r requirements.txtThis app expects a DATABASE_URL environment variable:
DATABASE_URL=postgresql://USER:PASSWORD@HOST:PORT/DBNAME
Redis is assumed to be available at localhost:6379 by default (see main.py).
export DATABASE_URL=postgresql://quimba:secretofthesand@localhost:5432/postgres
uvicorn main:app --host 0.0.0.0 --port 8000 --reloadOpenAPI docs:
- Swagger UI:
http://localhost:8000/docs - Redoc:
http://localhost:8000/redoc
This repo includes a docker-compose.yml that starts the API, PostgreSQL, Redis, and a webapp container:
docker compose upThe API container already has DATABASE_URL configured to talk to the db service.
On startup, the app:
- creates tables (see
main.py) - runs a bootstrap data loader (
bootstrap/db_data_init.py)
If you are using Alembic migrations, ensure the database is aligned with your migration history.
There are tests under tests/.
pytest- Missing DATABASE_URL:
db.pyreadsDATABASE_URLfrom the environment. Set it before starting the app. - Redis not running: some endpoints use caching. Start Redis or update
main.pyto point to your Redis host. - Migrations vs create_all:
main.pycallsBase.metadata.create_all. If you rely on Alembic, consider removing that in production environments.
- Repositories in
repos/encapsulate database access and business logic. - Routers in
routers/should remain thin; keep data access inside repositories. - DTOs in
dtos/define API shapes and serialization.