A FastAPI-based todo management backend with a playful toad theme
Toado is a production-ready REST API for todo management, built with modern Python best practices. It features comprehensive CRUD operations, input validation, auto-generated documentation, and a modular architecture designed for scalability.
- β Full CRUD operations for todos with filtering and pagination
- β Input validation with Pydantic (title, description, status, priority, due dates)
- β Auto-generated documentation (Swagger UI & ReDoc)
- β Request logging middleware with performance timing
- β SQLAlchemy ORM with SQLite (easily swappable to PostgreSQL)
- β Comprehensive test suite (17 tests passing)
- β Postman collection for API testing
- ποΈ Modular design with clear separation of concerns
- π Repository pattern for data access abstraction
- π― Dependency injection for database sessions
- π Type hints throughout the codebase
- π§ͺ Test-driven development ready
- π Production-ready with proper error handling
The codebase includes placeholders for Phase 2 enhancements:
- π JWT authentication
- π₯ User management
- π‘οΈ Admin endpoints
- β±οΈ Rate limiting
- π§ Email verification
- Quick Start
- Project Structure
- API Documentation
- Testing
- Development
- Deployment
- Roadmap
- Contributing
- License
- Python 3.11 or higher
- pip (Python package manager)
- Git
# Clone the repository
git clone https://github.com/hassanalzahrani-1/toado.git
cd toado
# Create and activate virtual environment
python -m venv venv
.\venv\Scripts\Activate.ps1
# If you get execution policy error, use:
# Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process
# Install dependencies
pip install -r requirements.txt
# Run the application
uvicorn app.main:app --reload# Clone the repository
git clone https://github.com/hassanalzahrani-1/toado.git
cd toado
# Create and activate virtual environment
python -m venv venv
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Run the application
uvicorn app.main:app --reloadOnce running, access the following endpoints:
- API Root: http://localhost:8000
- Interactive Docs (Swagger UI): http://localhost:8000/docs
- Alternative Docs (ReDoc): http://localhost:8000/redoc
- Health Check: http://localhost:8000/health
toado/
βββ app/
β βββ __init__.py
β βββ main.py # FastAPI app entry point, middleware setup
β βββ config.py # Environment-based configuration
β βββ db.py # Database engine and session management
β βββ models.py # SQLAlchemy ORM models (Todo, enums)
β βββ schemas.py # Pydantic models for validation
β βββ middleware.py # Custom middleware (logging, timing)
β βββ dependencies/ # Reusable FastAPI dependencies
β β βββ __init__.py
β β βββ db.py # Database session injection
β β βββ auth.py # Auth dependency (Phase 2 placeholder)
β β βββ rate_limit.py # Rate limiter (Phase 2 placeholder)
β βββ repositories/ # Data access layer
β β βββ __init__.py
β β βββ todos.py # Todo CRUD operations
β βββ routers/ # API route handlers
β β βββ __init__.py
β β βββ todos.py # Todo endpoints
β βββ services/ # Business logic layer
β βββ __init__.py
β βββ auth.py # JWT service (Phase 2 placeholder)
β βββ email.py # Email service (Phase 2 placeholder)
βββ tests/
β βββ __init__.py
β βββ test_todos.py # Comprehensive test suite
βββ .gitignore
βββ requirements.txt
βββ Toado_API.postman_collection.json
βββ Toado_API.postman_environment.json
βββ README.md
http://localhost:8000
| Method | Endpoint | Description |
|---|---|---|
| GET | / |
Welcome message with API info |
| GET | /health |
Health check status |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| POST | /todos |
Create a new todo | No |
| GET | /todos |
List all todos (with filters) | No |
| GET | /todos/{id} |
Get a specific todo | No |
| PUT | /todos/{id} |
Update a todo | No |
| DELETE | /todos/{id} |
Delete a todo | No |
Request:
curl -X POST "http://localhost:8000/todos" \
-H "Content-Type: application/json" \
-d '{
"title": "Complete project documentation",
"description": "Write comprehensive README",
"status": "pending",
"priority": "high",
"due_date": "2025-10-15T12:00:00Z"
}'Response:
{
"id": 1,
"title": "Complete project documentation",
"description": "Write comprehensive README",
"status": "pending",
"priority": "high",
"due_date": "2025-10-15T12:00:00Z",
"created_at": "2025-10-07T13:00:00Z",
"updated_at": "2025-10-07T13:00:00Z"
}Request:
curl "http://localhost:8000/todos?status=pending&priority=high&limit=10"Query Parameters:
status- Filter by status (pending,in_progress,completed)priority- Filter by priority (low,medium,high)due_before- Filter by due date (ISO 8601 format)skip- Number of records to skip (pagination)limit- Maximum records to return (default: 100)
| Field | Type | Required | Description |
|---|---|---|---|
id |
integer | Auto | Unique identifier |
title |
string | Yes | Todo title (1-200 chars) |
description |
string | No | Detailed description (max 2000 chars) |
status |
enum | No | Status: pending, in_progress, completed |
priority |
enum | No | Priority: low, medium, high |
due_date |
datetime | No | Due date (ISO 8601, must be future) |
created_at |
datetime | Auto | Creation timestamp |
updated_at |
datetime | Auto | Last update timestamp |
# Run all tests with verbose output
pytest tests/ -v
# Run with coverage report
pytest tests/ --cov=app --cov-report=html
# Run specific test file
pytest tests/test_todos.py -vThe test suite includes:
- β CRUD operations (create, read, update, delete)
- β Input validation (empty titles, past due dates)
- β Filtering (status, priority, due date)
- β Pagination (skip, limit)
- β Error handling (404 not found)
- β Health check endpoints
Current Coverage: 17 tests, all passing β
- Follow PEP 8 style guide
- Use type hints for all function signatures
- Write docstrings for all public functions and classes
- Keep functions small and focused (single responsibility)
- Use meaningful variable names
- Add comments for complex logic
- Create a new model in
app/models.py - Define Pydantic schemas in
app/schemas.py - Implement repository in
app/repositories/ - Create router in
app/routers/ - Write tests in
tests/ - Update documentation
Abstracts data access logic from business logic:
# app/repositories/todos.py
def create_todo(db: Session, todo_data: TodoCreate) -> Todo:
todo = Todo(**todo_data.model_dump())
db.add(todo)
db.commit()
db.refresh(todo)
return todoFastAPI's dependency system for clean code:
# app/routers/todos.py
@router.post("/todos")
def create_todo(
todo_data: TodoCreate,
db: Session = Depends(get_db), # Injected dependency
):
return todo_repo.create_todo(db, todo_data)A comprehensive Postman collection is included for easy API testing.
- Open Postman
- Click Import button
- Select both files:
Toado_API.postman_collection.jsonToado_API.postman_environment.json
- Select the Toado API - Local environment
- Start making requests!
- β Health endpoints - Root and health check
- β CRUD operations - Create, read, update, delete
- β Filtering examples - Status, priority, due date
- β Pagination - Skip and limit parameters
- β Error cases - Validation errors, 404 handling
- β
Auto-capture -
todo_idsaved after creation
Create a .env file in the project root:
# Database
DATABASE_URL=sqlite:///./toado.db
# Application
APP_TITLE=Toado API
APP_VERSION=1.0.0
# JWT (Phase 2)
JWT_SECRET_KEY=your-secret-key-change-in-production
JWT_ALGORITHM=HS256Create a Dockerfile:
FROM python:3.11-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
EXPOSE 8000
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]Build and run:
docker build -t toado-api .
docker run -p 8000:8000 toado-api- Use PostgreSQL instead of SQLite
- Set
echo=Falsein database engine - Configure CORS origins properly
- Enable HTTPS with SSL certificates
- Set up logging to files or external service
- Use environment variables for secrets
- Implement rate limiting (Phase 2)
- Add monitoring and health checks
- Full CRUD operations
- Input validation
- Auto-generated documentation
- Request logging middleware
- SQLAlchemy with SQLite
- Comprehensive test suite
- Postman collection
- User registration and login
- JWT authentication
- User-specific todos
- Admin endpoints
- Rate limiting with Redis
- Email verification (mock)
- Password reset functionality
- Role-based access control
- React/Vue frontend
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
# Clone your fork
git clone https://github.com/YOUR_USERNAME/toado.git
cd toado
# Create virtual environment
python -m venv venv
source venv/bin/activate # or .\venv\Scripts\Activate.ps1 on Windows
# Install dependencies
pip install -r requirements.txt
# Run tests
pytest tests/ -vThis project is licensed under the MIT License - see the LICENSE file for details.
- FastAPI - Modern web framework
- SQLAlchemy - SQL toolkit and ORM
- Pydantic - Data validation
- Uvicorn - ASGI server
Hassan Alzahrani - @hassanalzahrani-1
Project Link: https://github.com/hassanalzahrani-1/toado