96 lines
1.8 KiB
Markdown
96 lines
1.8 KiB
Markdown
# Todo App API
|
|
|
|
This is a simple Todo application backend built with FastAPI and SQLite.
|
|
|
|
## Features
|
|
|
|
- Create, read, update, and delete Todo items
|
|
- Filter Todos by completion status
|
|
- RESTful API with proper status codes
|
|
- SQLite database with SQLAlchemy ORM
|
|
- Database migrations with Alembic
|
|
- Input validation with Pydantic
|
|
- CORS support
|
|
- Health check endpoint
|
|
|
|
## Requirements
|
|
|
|
- Python 3.8+
|
|
- FastAPI
|
|
- SQLAlchemy
|
|
- Alembic
|
|
- Uvicorn
|
|
- Pydantic
|
|
- Ruff (for linting)
|
|
|
|
## Installation
|
|
|
|
1. Clone the repository:
|
|
```bash
|
|
git clone <repository-url>
|
|
cd todoappbackend-uspc3m
|
|
```
|
|
|
|
2. Install dependencies:
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
## Configuration
|
|
|
|
The application uses environment variables for configuration. You can create a `.env` file in the root directory with the following settings:
|
|
|
|
```
|
|
PROJECT_NAME=Todo App API
|
|
```
|
|
|
|
## Database Setup
|
|
|
|
The application uses SQLite by default. The database file will be created at `/app/storage/db/db.sqlite`.
|
|
|
|
To initialize the database:
|
|
|
|
```bash
|
|
# Run the database migrations
|
|
alembic upgrade head
|
|
```
|
|
|
|
## Running the Application
|
|
|
|
```bash
|
|
# Development server
|
|
uvicorn main:app --reload
|
|
|
|
# Production server
|
|
uvicorn main:app --host 0.0.0.0 --port 8000
|
|
```
|
|
|
|
## API Documentation
|
|
|
|
Once the application is running, you can access the API documentation at:
|
|
|
|
- Swagger UI: http://localhost:8000/docs
|
|
- ReDoc: http://localhost:8000/redoc
|
|
|
|
## API Endpoints
|
|
|
|
- `GET /api/v1/todos`: Get all todos (with optional filtering)
|
|
- `POST /api/v1/todos`: Create a new todo
|
|
- `GET /api/v1/todos/{todo_id}`: Get a specific todo
|
|
- `PUT /api/v1/todos/{todo_id}`: Update a todo
|
|
- `DELETE /api/v1/todos/{todo_id}`: Delete a todo
|
|
- `GET /health`: Health check endpoint
|
|
|
|
## Development
|
|
|
|
### Linting
|
|
|
|
```bash
|
|
ruff check .
|
|
```
|
|
|
|
### Fix linting issues
|
|
|
|
```bash
|
|
ruff check --fix .
|
|
``` |