
- Set up FastAPI application with CORS and authentication - Implement user registration and login with JWT tokens - Create SQLAlchemy models for users and items - Add CRUD endpoints for item management - Configure Alembic for database migrations - Add health check endpoint - Include comprehensive API documentation - Set up proper project structure with routers and schemas
REST API Service
A comprehensive REST API built with FastAPI and SQLite, featuring user authentication, CRUD operations, and health monitoring.
Features
- User registration and authentication with JWT tokens
- Item management (CRUD operations)
- SQLite database with SQLAlchemy ORM
- Database migrations with Alembic
- Health check endpoint
- CORS enabled for all origins
- Interactive API documentation at
/docs
and/redoc
- OpenAPI specification at
/openapi.json
Installation
- Install dependencies:
pip install -r requirements.txt
- Run the application:
uvicorn main:app --host 0.0.0.0 --port 8000
Environment Variables
Set the following environment variables:
SECRET_KEY
: JWT secret key for token signing (required for production)
API Endpoints
Authentication
POST /auth/register
- Register a new userPOST /auth/login
- Login and get access tokenGET /auth/me
- Get current user profile
Items
GET /items/
- List user's itemsPOST /items/
- Create a new itemGET /items/{item_id}
- Get a specific itemPUT /items/{item_id}
- Update an itemDELETE /items/{item_id}
- Delete an item
Health
GET /health
- Health check endpoint
Documentation
GET /
- Service informationGET /docs
- Interactive API documentationGET /redoc
- ReDoc documentationGET /openapi.json
- OpenAPI specification
Database
The application uses SQLite with database file stored at /app/storage/db/db.sqlite
.
Development
The application includes Ruff for code linting and formatting. Run linting with:
ruff check .
ruff format .
Description
Languages
Python
96.8%
Mako
3.2%