2025-05-24 15:58:57 +00:00

130 lines
2.4 KiB
Markdown

# Task Manager API
A RESTful API for managing tasks built with FastAPI and SQLite.
## Features
- Create, read, update, and delete tasks
- Filter tasks by completion status and priority
- Health check endpoint
- SQLite database with SQLAlchemy ORM
- Database migrations with Alembic
## Tech Stack
- **Framework**: FastAPI
- **Database**: SQLite
- **ORM**: SQLAlchemy
- **Migrations**: Alembic
## Project Structure
```
.
├── app
│ ├── api
│ │ ├── endpoints
│ │ │ ├── health.py
│ │ │ └── tasks.py
│ │ └── api.py
│ ├── core
│ ├── db
│ │ └── database.py
│ ├── models
│ │ └── task.py
│ ├── schemas
│ │ └── task.py
│ └── main.py
├── migrations
│ ├── versions
│ │ └── 001_create_tasks_table.py
│ ├── env.py
│ └── script.py.mako
├── storage
│ └── db
├── alembic.ini
├── main.py
├── README.md
└── requirements.txt
```
## Installation
1. Clone the repository:
```bash
git clone https://github.com/yourusername/taskmanagerapi.git
cd taskmanagerapi
```
2. Install dependencies:
```bash
pip install -r requirements.txt
```
3. Run database migrations:
```bash
alembic upgrade head
```
## Usage
### Running the API
```bash
# Development with auto-reload
python main.py
# Or using uvicorn directly
uvicorn app.main:app --reload
```
The API will be available at `http://localhost:8000`.
### API Documentation
FastAPI automatically generates interactive API documentation:
- Swagger UI: `http://localhost:8000/docs`
- ReDoc: `http://localhost:8000/redoc`
## API Endpoints
### Health Check
- `GET /health` - Check API and database health
### Tasks
- `GET /tasks` - List all tasks (with optional filtering)
- `POST /tasks` - Create a new task
- `GET /tasks/{task_id}` - Get a specific task
- `PUT /tasks/{task_id}` - Update a task
- `DELETE /tasks/{task_id}` - Delete a task
## Task Model
```json
{
"id": 1,
"title": "Example Task",
"description": "This is an example task",
"completed": false,
"priority": 1,
"due_date": "2023-09-30T00:00:00Z",
"created_at": "2023-09-25T15:00:00Z",
"updated_at": "2023-09-25T15:00:00Z"
}
```
### Priority Levels
- `0`: Low
- `1`: Medium
- `2`: High
## License
This project is licensed under the MIT License.