2025-05-17 04:43:35 +00:00

112 lines
2.3 KiB
Markdown

# Todo Application API
This is a FastAPI-based Todo Application API that allows you to manage todo items. It's built with FastAPI and SQLite for data persistence.
## Features
### Hii
### Hullooo
- Create, read, update, and delete todo items
- Filter todos by completion status
- Health check endpoint
- Swagger/OpenAPI documentation
- SQLite database with Alembic migrations
## Tech Stack
- **FastAPI**: Modern, fast web framework for building APIs
- **SQLAlchemy**: SQL toolkit and Object-Relational Mapping
- **Alembic**: Database migration tool
- **SQLite**: Lightweight disk-based database
- **Pydantic**: Data validation and settings management
- **Uvicorn**: ASGI server for FastAPI
## Setup
1. Clone the repository:
```
git clone [your-repository-url]
cd todoapplication-omxawp
```
2. Install dependencies:
```
pip install -r requirements.txt
```
3. Run the application:
```
uvicorn main:app --reload
```
4. Access the API:
- API: http://127.0.0.1:8000/
- Swagger docs: http://127.0.0.1:8000/docs
- ReDoc: http://127.0.0.1:8000/redoc
## API Endpoints
### Health Check
- `GET /health` - Check if the API is running
### Todo Operations
- `POST /api/todos/` - Create a new todo
- `GET /api/todos/` - List all todos (with optional filters)
- `GET /api/todos/{todo_id}` - Get a specific todo
- `PUT /api/todos/{todo_id}` - Update a todo
- `DELETE /api/todos/{todo_id}` - Delete a todo
## Example API Usage
### Create a Todo Item
```bash
curl -X 'POST' \
'http://127.0.0.1:8000/api/todos/' \
-H 'Content-Type: application/json' \
-d '{
"title": "Buy groceries",
"description": "Milk, eggs, bread",
"completed": false
}'
```
### Get All Todos
```bash
curl -X 'GET' 'http://127.0.0.1:8000/api/todos/'
```
### Get a Specific Todo
```bash
curl -X 'GET' 'http://127.0.0.1:8000/api/todos/1'
```
### Update a Todo
```bash
curl -X 'PUT' \
'http://127.0.0.1:8000/api/todos/1' \
-H 'Content-Type: application/json' \
-d '{
"completed": true
}'
```
### Delete a Todo
```bash
curl -X 'DELETE' 'http://127.0.0.1:8000/api/todos/1'
```
## Database
The application uses SQLite with the database file stored at `/app/storage/db/db.sqlite`.
## Migrations
Migrations are handled with Alembic:
```bash
# Apply migrations
alembic upgrade head
# Create a new migration
alembic revision --autogenerate -m "Description of changes"
```