O aplicație To-Do modernă bazată pe FastAPI cu containerizare Docker.
✅ CRUD complet pentru To-Do items
✅ Filtrare după status (completate/incompletate)
✅ Priorități (low, normal, high)
✅ Bază de date SQLite cu SQLAlchemy ORM
✅ Documentație API automată (Swagger UI)
✅ CORS support
✅ Docker & Docker Compose gata de utilizare
✅ Health check endpoint
- Python 3.11+
- pip
# Clonează/deschide proiectul
cd to-do
# Creează environment virtual
python -m venv venv
# Activează environment
# Windows:
venv\Scripts\activate
# Linux/Mac:
source venv/bin/activate
# Instalează dependențe
pip install -r requirements.txt# Rulează serverul
uvicorn main:app --reload
# Serverul va fi disponibil la:
# http://localhost:8000
# Swagger UI: http://localhost:8000/docs
# ReDoc: http://localhost:8000/redocdocker build -t todo-api:latest .docker run -p 8000:8000 todo-api:latest# Pornire
docker-compose up
# Oprire
docker-compose down
# Rebuild
docker-compose up --build| Metoda | Endpoint | Descriere |
|---|---|---|
GET |
/api/todos |
Obține toate to-do items |
POST |
/api/todos |
Creează un nou to-do |
GET |
/api/todos/{id} |
Obține un to-do specific |
PUT |
/api/todos/{id} |
Actualizează un to-do |
DELETE |
/api/todos/{id} |
Șterge un to-do |
GET |
/api/todos/status/{completed} |
Obține to-dos după status |
| Metoda | Endpoint | Descriere |
|---|---|---|
GET |
/ |
Info API |
GET |
/health |
Health check |
curl -X POST "http://localhost:8000/api/todos" \
-H "Content-Type: application/json" \
-d '{
"title": "Înt compras",
"description": "Cumpără lapte și pâine",
"priority": "high"
}'curl "http://localhost:8000/api/todos"curl -X PUT "http://localhost:8000/api/todos/1" \
-H "Content-Type: application/json" \
-d '{
"completed": true
}'to-do/
├── main.py # Entry point principal
├── app/
│ ├── __init__.py
│ ├── database.py # Configurare bază de date
│ ├── models.py # SQLAlchemy models
│ ├── schemas.py # Pydantic schemas
│ ├── crud.py # CRUD operations
│ └── routes/
│ ├── __init__.py
│ └── todos.py # Todo endpoints
├── requirements.txt # Dependențe Python
├── dockerfile # Docker image definition
├── docker-compose.yml # Docker Compose setup
├── .gitignore # Git ignore file
├── .dockerignore # Docker ignore file
└── README.md # Acest fișier
Creează .env dacă ai nevoie de variabile custom:
DATABASE_URL=sqlite:///./todos.db# Schimbă portul în command
uvicorn main:app --port 8001# Șterge baza de date
rm todos.db
# Rulează din nou
uvicorn main:app --reloadProiectul este gata pentru deployment pe:
- AWS ECS
- Google Cloud Run
- Azure Container Instances
- DigitalOcean App Platform
- Railway
- Render
Doar construiește imaginea Docker și deploy-ează containerul.
MIT License - Free to use
Pentru probleme sau sugestii, contactează-mă!