
- Add CRUD operations for todos (create, read, update, delete) - Implement SQLAlchemy models and schemas - Set up Alembic for database migrations - Add health endpoint and CORS configuration - Include comprehensive API documentation - Structure project with proper separation of concerns
70 lines
1.7 KiB
Markdown
70 lines
1.7 KiB
Markdown
# Todo App API
|
|
|
|
A simple Todo application API built with FastAPI and SQLite.
|
|
|
|
## Features
|
|
|
|
- CRUD operations for todos (Create, Read, Update, Delete)
|
|
- SQLite database with SQLAlchemy ORM
|
|
- Database migrations with Alembic
|
|
- CORS enabled for all origins
|
|
- Health check endpoint
|
|
- Interactive API documentation
|
|
|
|
## Installation
|
|
|
|
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
|
|
```
|
|
|
|
The API will be available at `http://localhost:8000`
|
|
|
|
## API Endpoints
|
|
|
|
### Base
|
|
- `GET /` - API information and links
|
|
- `GET /health` - Health check
|
|
|
|
### Todos
|
|
- `POST /todos/` - Create a new todo
|
|
- `GET /todos/` - Get all todos (with pagination)
|
|
- `GET /todos/{todo_id}` - Get a specific todo
|
|
- `PUT /todos/{todo_id}` - Update a todo
|
|
- `DELETE /todos/{todo_id}` - Delete a todo
|
|
|
|
## Documentation
|
|
|
|
- Interactive API docs: `http://localhost:8000/docs`
|
|
- ReDoc documentation: `http://localhost:8000/redoc`
|
|
- OpenAPI JSON: `http://localhost:8000/openapi.json`
|
|
|
|
## Database
|
|
|
|
The application uses SQLite with the database file stored at `/app/storage/db/db.sqlite`.
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
├── main.py # FastAPI application entry point
|
|
├── requirements.txt # Python dependencies
|
|
├── alembic.ini # Alembic configuration
|
|
├── alembic/ # Database migrations
|
|
├── app/
|
|
│ ├── db/ # Database configuration
|
|
│ ├── models/ # SQLAlchemy models
|
|
│ ├── schemas/ # Pydantic schemas
|
|
│ └── routes/ # API routes
|
|
└── storage/ # Application storage directory
|
|
```
|