
- Set up project structure and dependencies - Create database models and schemas for tasks - Implement CRUD operations for tasks - Add API endpoints for task management - Create Alembic migrations for the database - Add health check endpoint - Implement error handling - Add documentation in README.md
106 lines
2.1 KiB
Markdown
106 lines
2.1 KiB
Markdown
# Task Management API
|
|
|
|
A simple task management API built with FastAPI and SQLite.
|
|
|
|
## Features
|
|
|
|
- Create, read, update, and delete tasks
|
|
- Filter tasks by status
|
|
- Mark tasks as completed
|
|
- Set task priorities
|
|
- Health check endpoint
|
|
|
|
## Tech Stack
|
|
|
|
- **FastAPI**: Modern, fast web framework for building APIs
|
|
- **SQLAlchemy**: SQL toolkit and ORM
|
|
- **Alembic**: Database migration tool
|
|
- **SQLite**: Lightweight, file-based database
|
|
- **Pydantic**: Data validation and settings management
|
|
- **Uvicorn**: ASGI server for FastAPI
|
|
|
|
## Setup and Installation
|
|
|
|
### Prerequisites
|
|
|
|
- Python 3.9+
|
|
|
|
### Installation
|
|
|
|
1. Clone the repository:
|
|
|
|
```bash
|
|
git clone <repository-url>
|
|
cd <repository-directory>
|
|
```
|
|
|
|
2. Create a virtual environment and activate it:
|
|
|
|
```bash
|
|
python -m venv venv
|
|
source venv/bin/activate # On Windows, use: 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 application with Uvicorn:
|
|
|
|
```bash
|
|
uvicorn main:app --host 0.0.0.0 --port 8000 --reload
|
|
```
|
|
|
|
The API will be available at http://localhost:8000.
|
|
|
|
## API Documentation
|
|
|
|
Once the application is running, you can access:
|
|
|
|
- Interactive API documentation: http://localhost:8000/docs
|
|
- Alternative API documentation: http://localhost:8000/redoc
|
|
|
|
## API Endpoints
|
|
|
|
### Health Check
|
|
|
|
- `GET /api/v1/health`: Check API and database health
|
|
|
|
### Tasks
|
|
|
|
- `GET /api/v1/tasks`: Get all tasks
|
|
- `POST /api/v1/tasks`: Create a new task
|
|
- `GET /api/v1/tasks/{id}`: Get a specific task
|
|
- `PUT /api/v1/tasks/{id}`: Update a task
|
|
- `DELETE /api/v1/tasks/{id}`: Delete (soft delete) a task
|
|
|
|
## Task Structure
|
|
|
|
A task has the following structure:
|
|
|
|
```json
|
|
{
|
|
"id": 1,
|
|
"title": "Sample Task",
|
|
"description": "This is a sample task",
|
|
"status": "todo",
|
|
"priority": "medium",
|
|
"due_date": "2023-12-31T23:59:59",
|
|
"created_at": "2023-09-27T10:00:00",
|
|
"updated_at": "2023-09-27T10:00:00"
|
|
}
|
|
```
|
|
|
|
- `status` can be: "todo", "in_progress", or "done"
|
|
- `priority` can be: "low", "medium", or "high"
|