2025-05-23 06:38:05 +00:00

110 lines
3.7 KiB
Markdown

# Task Manager API
A RESTful API for managing tasks and to-do items, built with FastAPI and SQLite.
## Features
- Create, read, update, and delete tasks
- Filter tasks by status, priority, and completion status
- Pagination support for listing tasks
- Data validation with Pydantic models
- Database migrations with Alembic
- Comprehensive error handling
- API documentation with Swagger UI and ReDoc
## Project Structure
```
taskmanagerapi/
├── alembic.ini # Alembic configuration
├── app/ # Main application package
│ ├── api/ # API endpoints
│ │ ├── v1/ # API version 1
│ │ │ ├── endpoints/ # API endpoint modules
│ │ │ │ ├── health.py # Health check endpoint
│ │ │ │ └── tasks.py # Task CRUD endpoints
│ │ │ └── router.py # API router
│ ├── core/ # Core application modules
│ │ ├── config.py # Application configuration
│ │ ├── error_handlers.py # Error handling middleware
│ │ └── exceptions.py # Custom exceptions
│ ├── db/ # Database modules
│ │ └── session.py # Database session
│ ├── models/ # SQLAlchemy models
│ │ └── task.py # Task model
│ ├── schemas/ # Pydantic schemas
│ │ ├── responses.py # Response schemas
│ │ └── task.py # Task schemas
│ ├── services/ # Business logic
│ │ └── task.py # Task service
│ └── storage/ # Storage directory
│ └── db/ # Database directory
├── migrations/ # Alembic migrations
│ ├── versions/ # Migration versions
│ │ └── 0001_create_tasks_table.py
│ ├── env.py # Alembic environment
│ └── script.py.mako # Alembic script template
├── main.py # Application entry point
├── pyproject.toml # Project configuration
└── requirements.txt # Project dependencies
```
## API Endpoints
- **GET /api/v1/health** - Health check endpoint
- **GET /api/v1/tasks** - List tasks with optional filtering and pagination
- **POST /api/v1/tasks** - Create a new task
- **GET /api/v1/tasks/{task_id}** - Get a specific task
- **PUT /api/v1/tasks/{task_id}** - Update a specific task
- **DELETE /api/v1/tasks/{task_id}** - Delete a specific task
## Task Model
- **id**: Integer - Task ID
- **title**: String - Task title
- **description**: String (optional) - Task description
- **status**: Enum - Task status (todo, in_progress, done)
- **priority**: Enum - Task priority (low, medium, high)
- **due_date**: DateTime (optional) - Task due date
- **completed**: Boolean - Whether the task is completed
- **created_at**: DateTime - Task creation timestamp
- **updated_at**: DateTime - Task update timestamp
## Requirements
- Python 3.8+
- FastAPI
- SQLAlchemy
- Alembic
- Pydantic
- Uvicorn
## Getting Started
1. Clone the repository
2. Install dependencies:
```bash
pip install -r requirements.txt
```
3. Run database migrations:
```bash
alembic upgrade head
```
4. Start the application:
```bash
uvicorn main:app --reload
```
5. Access the API documentation:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
## Development
- Linting:
```bash
ruff check .
```
- Auto-fix linting issues:
```bash
ruff check --fix .
```