
- Created FastAPI application structure with main.py and requirements.txt - Setup SQLite database with SQLAlchemy models for tasks - Implemented Alembic migrations for database schema management - Added CRUD endpoints for task management (GET, POST, PUT, DELETE) - Configured CORS middleware to allow all origins - Added health endpoint and base route with API information - Updated README with comprehensive documentation - Applied code formatting with Ruff linter
2.4 KiB
2.4 KiB
Task Manager API
A simple task management API built with FastAPI and SQLite.
Features
- Create, read, update, and delete tasks
- Task priority levels (high, medium, low)
- Task completion status tracking
- RESTful API design
- Automatic API documentation with Swagger UI
Quick Start
-
Install dependencies:
pip install -r requirements.txt
-
Run database migrations:
alembic upgrade head
-
Start the application:
uvicorn main:app --reload
-
Open your browser and navigate to:
- API Documentation: http://localhost:8000/docs
- Alternative Documentation: http://localhost:8000/redoc
- Health Check: http://localhost:8000/health
API Endpoints
Base Routes
GET /
- API information and linksGET /health
- Health check endpoint
Task Management
GET /api/v1/tasks
- Get all tasks (with pagination)GET /api/v1/tasks/{id}
- Get a specific taskPOST /api/v1/tasks
- Create a new taskPUT /api/v1/tasks/{id}
- Update a taskDELETE /api/v1/tasks/{id}
- Delete a task
Task Schema
{
"title": "string",
"description": "string (optional)",
"completed": "boolean (default: false)",
"priority": "string (default: medium)",
"id": "integer (auto-generated)",
"created_at": "datetime (auto-generated)",
"updated_at": "datetime (auto-generated)"
}
Project Structure
├── main.py # FastAPI application entry point
├── requirements.txt # Python dependencies
├── alembic.ini # Alembic configuration
├── alembic/ # Database migrations
├── app/
│ ├── db/
│ │ ├── base.py # SQLAlchemy Base
│ │ └── session.py # Database session management
│ ├── models/
│ │ └── task.py # Task SQLAlchemy model
│ ├── routers/
│ │ └── tasks.py # Task API endpoints
│ └── schemas/
│ └── task.py # Pydantic schemas
└── storage/
└── db/ # SQLite database storage
Database
The application uses SQLite for data storage. The database file is created automatically at /app/storage/db/db.sqlite
.
Development
The application is configured with:
- CORS enabled for all origins
- Automatic API documentation
- Database migrations with Alembic
- Pydantic models for request/response validation