A professional, scalable, and future-ready To-Do list REST API built with FastAPI, SQLModel (async ORM), SQLite, and Alembic for migrations.
- Async FastAPI application with modular structure
- SQLite database with SQLModel ORM
- Alembic migrations for database version control
- Environment-based configuration using
.envandpydantic-settings - Clean architecture with separated layers: models, schemas, repositories, services, routes
- Data validation with Pydantic schemas
- Ready for extension to PostgreSQL, Docker, and auth
fa-todo-rest/
├── alembic/
│ └── versions/ # Alembic migration scripts
├── app/
│ ├── api/
│ │ └── v1/
│ │ └── routes/ # FastAPI routes
│ ├── core/
│ │ └── config.py # App settings (pydantic)
│ ├── crud/ or repositories/ # Data access layer
│ ├── db/
│ │ ├── base.py # Base metadata
│ │ └── session.py # DB session management
│ ├── models/ # SQLModel models
│ ├── schemas/ # Pydantic schemas
│ ├── services/ # Business logic layer
│ └── main.py # FastAPI app entrypoint
├── .env # Environment variables
├── alembic.ini # Alembic config
├── requirements.txt # Python dependencies
└── README.md # This file
- Python 3.10+
- SQLite (comes bundled with Python)
- Clone the repo:
git clone https://github.com/whoismaruf/fa-todo-rest.git
cd fa-todo-rest- Create and activate a virtual environment:
python -m venv .venv
source .venv/bin/activate # On Windows use `.venv\Scripts\activate`- Install dependencies:
pip install -r requirements.txt- Create a
.envfile at project root with:
DATABASE_URL=sqlite+aiosqlite:///./todo.db
API_KEY=your_api_key_here
DEBUG=True- Run Alembic migrations:
alembic upgrade head- Start the FastAPI server:
uvicorn app.main:app --reloadOpen your browser at http://127.0.0.1:8000/docs for Swagger UI.
- Create, Read, Update, Delete (CRUD) To-Do items via REST API
- Use
/docsfor interactive API exploration
- To create a new migration after model changes:
alembic revision --autogenerate -m "your message"
alembic upgrade headAll settings are managed via environment variables loaded by pydantic-settings:
| Variable | Description | Default |
|---|---|---|
DATABASE_URL |
Database connection URL | No default (required) |
API_KEY |
API key for auth or external services | No default (required) |
DEBUG |
Enable debug mode (True/False) | False |
- Add authentication (JWT, OAuth2)
- Switch to PostgreSQL or other DBs
- Dockerize app with Docker Compose
- Add unit and integration tests
- Implement pagination, filtering
Created by [Maruf Khan] - feel free to reach out!
Happy coding! 🚀