93 lines
2.3 KiB
Markdown
93 lines
2.3 KiB
Markdown
# Simple Todo App
|
|
|
|
This is a simple Todo API application built with FastAPI and SQLite.
|
|
|
|
## Features
|
|
|
|
- Create, Read, Update, and Delete Todo items
|
|
- Health check endpoint
|
|
- Database migrations using Alembic
|
|
- SQLite database for data storage
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
.
|
|
├── alembic/ # Database migration files
|
|
├── app/ # Application package
|
|
│ ├── database/ # Database configuration and session management
|
|
│ ├── models/ # SQLAlchemy ORM models
|
|
│ ├── routers/ # API route handlers
|
|
│ └── schemas/ # Pydantic models for request/response validation
|
|
├── alembic.ini # Alembic configuration
|
|
├── main.py # Application entry point
|
|
└── requirements.txt # Project dependencies
|
|
```
|
|
|
|
## Installation
|
|
|
|
1. Clone the repository:
|
|
|
|
```bash
|
|
git clone <repository-url>
|
|
cd simpletodoapp
|
|
```
|
|
|
|
2. Create a virtual environment and activate it:
|
|
|
|
```bash
|
|
python -m venv venv
|
|
source venv/bin/activate # On Windows: venv\Scripts\activate
|
|
```
|
|
|
|
3. Install dependencies:
|
|
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
## Database Setup
|
|
|
|
The application uses SQLite as the database. The database file will be created automatically in the following location:
|
|
- In production: `/app/storage/db/db.sqlite`
|
|
- In development: `./storage/db/db.sqlite` (relative to the project root)
|
|
|
|
1. Run database migrations:
|
|
|
|
```bash
|
|
# Make sure you're in the project root directory
|
|
alembic upgrade head
|
|
```
|
|
|
|
Note: If you encounter import errors with Alembic, make sure you're running the command from the project root directory so that the `app` module can be found.
|
|
|
|
## Running the Application
|
|
|
|
Start the application with Uvicorn:
|
|
|
|
```bash
|
|
uvicorn main:app --reload
|
|
```
|
|
|
|
The API will be available at http://localhost:8000
|
|
|
|
## API Documentation
|
|
|
|
Once the application is running, you can access the Swagger UI documentation at:
|
|
|
|
- http://localhost:8000/docs
|
|
- http://localhost:8000/redoc
|
|
|
|
## API Endpoints
|
|
|
|
### Health Check
|
|
|
|
- GET `/health`: Check the application health status
|
|
|
|
### Todo Endpoints
|
|
|
|
- GET `/todos`: List all todos
|
|
- POST `/todos`: Create a new todo
|
|
- GET `/todos/{todo_id}`: Get a specific todo by ID
|
|
- PATCH `/todos/{todo_id}`: Update a specific todo
|
|
- DELETE `/todos/{todo_id}`: Delete a specific todo |