109 lines
2.1 KiB
Markdown
109 lines
2.1 KiB
Markdown
# Simple Todo App
|
|
|
|
A simple Todo application built with FastAPI and SQLite.
|
|
|
|
## Features
|
|
|
|
- Create, read, update, and delete todo items
|
|
- RESTful API with JSON responses
|
|
- SQLite database with SQLAlchemy ORM
|
|
- Alembic for database migrations
|
|
- API documentation with Swagger UI and ReDoc
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
.
|
|
├── alembic.ini
|
|
├── app
|
|
│ ├── api
|
|
│ │ ├── endpoints
|
|
│ │ │ ├── health.py
|
|
│ │ │ └── todos.py
|
|
│ │ └── router.py
|
|
│ ├── core
|
|
│ │ └── config.py
|
|
│ ├── database
|
|
│ │ ├── base.py
|
|
│ │ └── deps.py
|
|
│ ├── models
|
|
│ │ └── todo.py
|
|
│ ├── schemas
|
|
│ │ └── todo.py
|
|
│ └── services
|
|
│ └── todo_service.py
|
|
├── main.py
|
|
├── migrations
|
|
│ ├── env.py
|
|
│ ├── README
|
|
│ ├── script.py.mako
|
|
│ └── versions
|
|
│ └── 001_create_todos_table.py
|
|
└── requirements.txt
|
|
```
|
|
|
|
## Installation
|
|
|
|
1. Clone the repository:
|
|
|
|
```bash
|
|
git clone <repository-url>
|
|
cd simpletodoapp
|
|
```
|
|
|
|
2. Create a virtual environment and install dependencies:
|
|
|
|
```bash
|
|
python -m venv venv
|
|
source venv/bin/activate # On Windows, use `venv\\Scripts\\activate`
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
3. Run the application:
|
|
|
|
```bash
|
|
uvicorn main:app --reload
|
|
```
|
|
|
|
The application will be available at http://localhost:8000.
|
|
|
|
## API Documentation
|
|
|
|
API documentation is available at:
|
|
|
|
- Swagger UI: http://localhost:8000/docs
|
|
- ReDoc: http://localhost:8000/redoc
|
|
|
|
## API Endpoints
|
|
|
|
### Health Check
|
|
|
|
- `GET /health` - Check API health status
|
|
|
|
### Todos
|
|
|
|
- `GET /api/v1/todos` - Get all todos (with pagination)
|
|
- `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
|
|
|
|
## Database Migrations
|
|
|
|
The application uses Alembic for database migrations:
|
|
|
|
1. Run migrations:
|
|
|
|
```bash
|
|
alembic upgrade head
|
|
```
|
|
|
|
2. Create a new migration:
|
|
|
|
```bash
|
|
alembic revision -m "your migration message"
|
|
```
|
|
|
|
## License
|
|
|
|
MIT |