
- Set up FastAPI project structure with best practices - Implemented SQLAlchemy models with SQLite database - Added Alembic for database migrations - Created CRUD API endpoints for items - Added health check endpoint - Updated documentation generated with BackendIM... (backend.im)
1.9 KiB
1.9 KiB
FastAPI Endpoint Service
This is a FastAPI application bootstrapped by BackendIM, the AI-powered backend generation platform.
Features
- Fast API endpoints with FastAPI framework
- SQLite database with SQLAlchemy ORM
- Database migrations with Alembic
- Health endpoint for monitoring
- CRUD operations for items
- Input validation with Pydantic
- Interactive API documentation with Swagger UI and ReDoc
Project Structure
├── alembic/ # Database migration files
├── app/ # Application source code
│ ├── api/ # API endpoints
│ │ ├── endpoints/ # API route handlers
│ │ └── dependencies/ # API dependencies
│ ├── core/ # Core application modules
│ ├── models/ # SQLAlchemy models
│ └── schemas/ # Pydantic schemas
├── main.py # Application entry point
└── requirements.txt # Project dependencies
Installation
- Clone the repository
- Install dependencies:
pip install -r requirements.txt
Running the Application
uvicorn main:app --host 0.0.0.0 --port 8000 --reload
API Documentation
API documentation is available at:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
API Endpoints
GET /health
: Health check endpointGET /api/v1/items/
: List all itemsPOST /api/v1/items/
: Create a new itemGET /api/v1/items/{item_id}
: Get a specific itemPUT /api/v1/items/{item_id}
: Update an itemDELETE /api/v1/items/{item_id}
: Delete an item
Database Migrations
Run the following commands to apply or create migrations:
# Apply migrations
alembic upgrade head
# Create a new migration
alembic revision --autogenerate -m "Migration message"