todoapp-tbb9a5/README.md
2025-05-22 19:30:08 +00:00

95 lines
2.2 KiB
Markdown

# Todo App API
A simple Todo app API built with FastAPI and SQLite.
## Features
- CRUD operations for todo items
- SQLAlchemy ORM for database interactions
- Alembic for database migrations
- Pydantic for data validation
- Health check endpoint
- FastAPI automatic documentation with Swagger UI and ReDoc
## Project Structure
```
/
├── app/ # Application package
│ ├── api/ # API endpoints
│ │ ├── deps.py # Dependencies
│ │ └── endpoints/ # API routes
│ ├── core/ # Core modules
│ │ └── config.py # Configuration
│ ├── crud/ # CRUD operations
│ ├── db/ # Database setup
│ ├── models/ # SQLAlchemy models
│ └── schemas/ # Pydantic schemas
├── migrations/ # Alembic migrations
├── alembic.ini # Alembic config
├── main.py # Application entry point
└── requirements.txt # Dependencies
```
## Getting Started
### Prerequisites
- Python 3.8 or higher
### Installation
1. Clone the repository:
```bash
git clone <repository-url>
cd todoapp
```
2. Install dependencies:
```bash
pip install -r requirements.txt
```
3. Run database migrations:
```bash
alembic upgrade head
```
4. Start the application:
```bash
uvicorn main:app --reload
```
The API will be available at http://localhost:8000
## API Documentation
Once the application is running, you can access:
- Swagger UI documentation: http://localhost:8000/docs
- ReDoc documentation: http://localhost:8000/redoc
## API Endpoints
- `GET /health` - Health check endpoint
- `GET /api/v1/todos` - List all todos
- `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
## Data Models
### Todo
- `id`: Integer (auto-generated)
- `title`: String (required)
- `description`: String (optional)
- `completed`: Boolean (default: false)
- `priority`: Integer (0=low, 1=medium, 2=high)
- `created_at`: DateTime (auto-generated)
- `updated_at`: DateTime (auto-updated)