
- Set up project structure and dependencies - Create task model and schema - Implement Alembic migrations - Add CRUD API endpoints for task management - Add health endpoint with database connectivity check - Add comprehensive error handling - Add tests for API endpoints - Update README with API documentation
129 lines
2.5 KiB
Markdown
129 lines
2.5 KiB
Markdown
# Task Manager API
|
|
|
|
A RESTful API for managing tasks built with FastAPI and SQLite.
|
|
|
|
## Features
|
|
|
|
- CRUD operations for tasks
|
|
- Filtering by task status, priority, and title search
|
|
- Health check endpoint with database connectivity check
|
|
- Comprehensive error handling
|
|
- Database migrations with Alembic
|
|
- Complete test suite
|
|
|
|
## Technical Stack
|
|
|
|
- **Python 3.9+**
|
|
- **FastAPI** - High-performance web framework
|
|
- **SQLite** - Database
|
|
- **SQLAlchemy** - ORM
|
|
- **Alembic** - Database migrations
|
|
- **Pydantic** - Data validation
|
|
- **Pytest** - Testing
|
|
|
|
## Setup and Installation
|
|
|
|
### Prerequisites
|
|
|
|
- Python 3.9 or higher
|
|
|
|
### Installation
|
|
|
|
1. Clone the repository
|
|
2. Install dependencies:
|
|
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
3. Set up environment variables (optional):
|
|
|
|
```bash
|
|
# Enable debug mode
|
|
export DEBUG=True
|
|
```
|
|
|
|
### Database Setup
|
|
|
|
The database will be automatically created at `/app/storage/db/db.sqlite` when the application starts. To apply migrations:
|
|
|
|
```bash
|
|
alembic upgrade head
|
|
```
|
|
|
|
### Running the API
|
|
|
|
```bash
|
|
# Development mode with auto-reload
|
|
uvicorn main:app --reload
|
|
|
|
# Production mode
|
|
uvicorn main:app --host 0.0.0.0 --port 8000
|
|
```
|
|
|
|
## API Documentation
|
|
|
|
The API documentation is available at `/docs` or `/redoc` when the server is running.
|
|
|
|
### Endpoints
|
|
|
|
#### Health Check
|
|
|
|
```
|
|
GET /health
|
|
```
|
|
|
|
Returns the health status of the API, including database connectivity.
|
|
|
|
#### Tasks
|
|
|
|
| Method | Endpoint | Description |
|
|
|--------|----------|-------------|
|
|
| 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 by ID |
|
|
| PUT | `/api/v1/tasks/{task_id}` | Update a specific task |
|
|
| DELETE | `/api/v1/tasks/{task_id}` | Delete a specific task |
|
|
|
|
### Filtering Tasks
|
|
|
|
The `GET /api/v1/tasks` endpoint supports the following query parameters:
|
|
|
|
- `completed` - Filter by completion status (true/false)
|
|
- `priority` - Filter by priority level (1-3)
|
|
- `search` - Search by task title
|
|
- `skip` - Number of items to skip (pagination)
|
|
- `limit` - Maximum number of items to return (pagination)
|
|
|
|
### Task Object Structure
|
|
|
|
```json
|
|
{
|
|
"id": 1,
|
|
"title": "Task Title",
|
|
"description": "Task description",
|
|
"completed": false,
|
|
"priority": 2,
|
|
"due_date": "2023-09-30T00:00:00",
|
|
"created_at": "2023-09-01T12:00:00",
|
|
"updated_at": "2023-09-01T12:00:00"
|
|
}
|
|
```
|
|
|
|
## Testing
|
|
|
|
Run the test suite with:
|
|
|
|
```bash
|
|
pytest
|
|
```
|
|
|
|
## Development
|
|
|
|
### Running Linting
|
|
|
|
```bash
|
|
ruff check .
|
|
ruff check --fix .
|
|
```
|