
- Set up FastAPI application with CORS support - Implement SQLite database with SQLAlchemy ORM - Create User model with CRUD operations - Add Alembic for database migrations - Include health check and documentation endpoints - Set up proper project structure with organized modules - Add comprehensive README with setup instructions - Configure Ruff for code linting and formatting
REST API Service
A REST API service built with FastAPI and SQLite, providing user management functionality.
Features
- FastAPI web framework
- SQLite database with SQLAlchemy ORM
- Alembic database migrations
- CRUD operations for users
- Health check endpoint
- Auto-generated OpenAPI documentation
- CORS support
Project Structure
├── main.py # FastAPI application entry point
├── requirements.txt # Python dependencies
├── alembic.ini # Alembic configuration
├── alembic/ # Database migrations
│ ├── env.py
│ ├── script.py.mako
│ └── versions/
│ └── 001_initial_migration.py
└── app/
├── __init__.py
├── db/
│ ├── __init__.py
│ ├── base.py # SQLAlchemy base
│ └── session.py # Database session configuration
├── models/
│ ├── __init__.py
│ └── user.py # User model
├── schemas/
│ ├── __init__.py
│ └── user.py # Pydantic schemas
└── crud/
├── __init__.py
└── user.py # CRUD operations
Installation
- Install dependencies:
pip install -r requirements.txt
- Run database migrations:
alembic upgrade head
- Start the application:
uvicorn main:app --host 0.0.0.0 --port 8000 --reload
API Endpoints
GET /
- Service informationGET /health
- Health checkGET /docs
- OpenAPI documentationGET /redoc
- Alternative API documentationPOST /users/
- Create a new userGET /users/
- List all usersGET /users/{user_id}
- Get user by IDPUT /users/{user_id}
- Update userDELETE /users/{user_id}
- Delete user
Database
The application uses SQLite database stored at /app/storage/db/db.sqlite
.
Environment Variables
No environment variables are required for basic operation. The application uses SQLite with default settings.
Development
To run the application in development mode:
uvicorn main:app --reload
The API will be available at http://localhost:8000
with automatic reload on code changes.
Description
Languages
Python
93.9%
Mako
6.1%