
- 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
94 lines
2.4 KiB
Markdown
94 lines
2.4 KiB
Markdown
# 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
|
|
|
|
1. Install dependencies:
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
2. Run database migrations:
|
|
```bash
|
|
alembic upgrade head
|
|
```
|
|
|
|
3. Start the application:
|
|
```bash
|
|
uvicorn main:app --reload
|
|
```
|
|
|
|
4. 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 links
|
|
- `GET /health` - Health check endpoint
|
|
|
|
### Task Management
|
|
- `GET /api/v1/tasks` - Get all tasks (with pagination)
|
|
- `GET /api/v1/tasks/{id}` - Get a specific task
|
|
- `POST /api/v1/tasks` - Create a new task
|
|
- `PUT /api/v1/tasks/{id}` - Update a task
|
|
- `DELETE /api/v1/tasks/{id}` - Delete a task
|
|
|
|
## Task Schema
|
|
|
|
```json
|
|
{
|
|
"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
|