
- Remove return None from delete endpoints with 204 status code - HTTP status code 204 must not have a response body per HTTP spec - Fixed in both users.py and todos.py API endpoints - Addresses AssertionError: Status code 204 must not have a response body
Simple Todo Application API with Authentication
This is a REST API for a todo application built with FastAPI and SQLite, featuring user authentication and authorization.
Features
- User registration and authentication with JWT tokens
- Secure password hashing with bcrypt
- User-specific todo items
- Create, read, update, and delete todo items
- User profile management
- Role-based access control
- Health endpoint for application monitoring
- API documentation via Swagger UI and ReDoc
- Database migrations using Alembic
- SQLite database for data storage
Project Structure
├── app/
│ ├── api/ # API endpoints
│ ├── core/ # Core functionality, security, dependencies
│ ├── crud/ # Database CRUD operations
│ ├── db/ # Database connection and utilities
│ ├── models/ # SQLAlchemy models
│ └── schemas/ # Pydantic schemas
├── migrations/ # Alembic migration scripts
├── main.py # FastAPI application entry point
├── alembic.ini # Alembic configuration
└── requirements.txt # Project dependencies
Installation
- Clone the repository
- Install the dependencies:
pip install -r requirements.txt
Running the Application
Start the application with:
uvicorn main:app --reload
The API will be available at http://localhost:8000
API Documentation
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
API Endpoints
Authentication
POST /auth/register
: Register a new userPOST /auth/login
: Login and get access tokenPOST /auth/refresh
: Refresh access tokenGET /auth/me
: Get current user information
Users
GET /users/
: Get all users (requires authentication)GET /users/{id}
: Get a specific user by ID (requires authentication)PATCH /users/{id}
: Update a user (requires authentication and ownership)DELETE /users/{id}
: Delete a user (requires authentication and ownership)
Todo Items
GET /todos
: Get all todo items for the current userPOST /todos
: Create a new todo itemGET /todos/{id}
: Get a specific todo itemPATCH /todos/{id}
: Update a todo itemDELETE /todos/{id}
: Delete a todo item
Note: All todo operations require authentication and only access to the user's own todos is allowed.
Other
GET /
: Root endpoint with API informationGET /health
: Health check endpoint
Authentication Flow
- Register a new user:
POST /auth/register
- Login to get a JWT token:
POST /auth/login
- Use the token in the Authorization header for all subsequent requests:
Authorization: Bearer {token}
Database Migrations
Run migrations with:
alembic upgrade head
Development
This project uses Ruff for linting. Run the linter with:
ruff check .
To automatically fix issues:
ruff check --fix .
Description
Languages
Python
98.4%
Mako
1.6%