164 lines
3.3 KiB
Markdown

# Task Manager API
A RESTful API for managing tasks built with FastAPI and SQLite.
## Features
- CRUD operations for tasks
- Task filtering by status
- Task pagination
- Automatic API documentation
- Health check endpoint
- Root endpoint with API information
- Task status and priority validation using Enums
## Project Structure
```
taskmanagerapi-daenmk/
├── alembic.ini
├── app/
│ ├── api/
│ │ └── v1/
│ │ ├── endpoints/
│ │ │ └── tasks.py
│ │ └── router.py
│ ├── core/
│ │ └── config.py
│ ├── database/
│ │ ├── base.py
│ │ ├── base_class.py
│ │ ├── deps.py
│ │ └── session.py
│ ├── models/
│ │ └── task.py
│ └── schemas/
│ └── task.py
├── migrations/
│ ├── env.py
│ ├── README
│ ├── script.py.mako
│ └── versions/
│ └── 6e1b8a0e43c1_create_task_table.py
├── main.py
└── requirements.txt
```
## Requirements
- Python 3.8+
- Dependencies listed in `requirements.txt`
## Installation
1. Clone the repository:
```bash
git clone https://github.com/yourusername/taskmanagerapi-daenmk.git
cd taskmanagerapi-daenmk
```
2. Create a virtual environment (optional but recommended):
```bash
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
```
3. Install dependencies:
```bash
pip install -r requirements.txt
```
4. Run database migrations:
```bash
alembic upgrade head
```
## Running the Application
Start the FastAPI server:
```bash
uvicorn main:app --reload
```
The API will be available at http://localhost:8000
## API Documentation
FastAPI generates interactive API documentation:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
## API Endpoints
### Root Endpoint
- `GET /` - Returns information about the API including the title, documentation links, and health check endpoint
### Health Check
- `GET /health` - Check if the API is running
### Tasks
- `GET /api/v1/tasks` - List all 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 task
- `DELETE /api/v1/tasks/{task_id}` - Delete a task
## Task Schema
```json
{
"title": "string",
"description": "string",
"status": "string", // One of: "pending", "in_progress", "completed", "cancelled"
"priority": "string", // One of: "low", "medium", "high", "urgent"
"due_date": "datetime",
"completed": false
}
```
## Query Parameters
For the `GET /api/v1/tasks` endpoint:
- `skip` (int, default=0): Number of records to skip for pagination
- `limit` (int, default=100): Maximum number of records to return
- `status` (string, optional): Filter tasks by status (e.g., "pending", "completed")
## Development
### Linting
Lint your code using Ruff:
```bash
ruff check .
```
Fix linting issues automatically:
```bash
ruff check --fix .
```
### Database Migrations
Create a new migration after model changes:
```bash
alembic revision --autogenerate -m "description of changes"
```
Apply migrations:
```bash
alembic upgrade head
```
## License
MIT