
- Set up project structure with FastAPI - Configure SQLite database with SQLAlchemy - Create Task model with Alembic migrations - Implement CRUD API endpoints for tasks - Add health check and CORS configuration - Update documentation
79 lines
2.6 KiB
Markdown
79 lines
2.6 KiB
Markdown
# Task Manager API
|
|
|
|
This is a FastAPI-based Task Manager API with SQLite backend. It provides endpoints for managing tasks with features like priority, due dates, and filtering.
|
|
|
|
## Features
|
|
|
|
- Create, read, update, and delete tasks
|
|
- Mark tasks as completed
|
|
- Filter tasks by completion status and priority
|
|
- SQLite database with SQLAlchemy ORM
|
|
- Alembic for database migrations
|
|
- FastAPI automatic API documentation
|
|
|
|
## API Endpoints
|
|
|
|
- `GET /health`: Health check endpoint
|
|
- `GET /api/v1/tasks`: List all tasks (with optional filtering)
|
|
- `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 task
|
|
- `DELETE /api/v1/tasks/{task_id}`: Delete a task
|
|
- `PATCH /api/v1/tasks/{task_id}/complete`: Mark a task as completed
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
taskmanagerapi/
|
|
├── alembic.ini # Alembic configuration
|
|
├── main.py # FastAPI application entry point
|
|
├── requirements.txt # Python dependencies
|
|
├── app/ # Application code
|
|
│ ├── api/ # API routes
|
|
│ │ └── v1/ # API version 1
|
|
│ │ ├── endpoints/ # API endpoint handlers
|
|
│ │ └── router.py # API router
|
|
│ ├── core/ # Core application code
|
|
│ │ └── config.py # Application configuration
|
|
│ ├── db/ # Database related code
|
|
│ │ └── session.py # Database session setup
|
|
│ ├── models/ # SQLAlchemy models
|
|
│ │ └── task.py # Task model
|
|
│ └── schemas/ # Pydantic schemas
|
|
│ └── task.py # Task schemas
|
|
└── migrations/ # Database migrations
|
|
├── env.py # Alembic environment
|
|
├── script.py.mako # Migration script template
|
|
└── versions/ # Migration versions
|
|
└── 01_initial_migration.py # Initial migration
|
|
```
|
|
|
|
## Getting Started
|
|
|
|
### Prerequisites
|
|
|
|
- Python 3.8+
|
|
- pip (Python package installer)
|
|
|
|
### Installation
|
|
|
|
1. Clone the repository
|
|
2. Install dependencies:
|
|
```
|
|
pip install -r requirements.txt
|
|
```
|
|
3. Apply migrations:
|
|
```
|
|
alembic upgrade head
|
|
```
|
|
4. Start the server:
|
|
```
|
|
uvicorn main:app --reload
|
|
```
|
|
|
|
### API Documentation
|
|
|
|
Once the server is running, you can access:
|
|
- Swagger UI documentation: http://localhost:8000/docs
|
|
- ReDoc documentation: http://localhost:8000/redoc
|
|
- OpenAPI JSON: http://localhost:8000/openapi.json |