Automated Action 629ba0ee1c Create REST API with FastAPI and SQLite
- Set up project structure with FastAPI app
- Implement SQLAlchemy models and async database connection
- Create CRUD endpoints for items resource
- Add health endpoint for monitoring
- Configure Alembic for database migrations
- Create comprehensive documentation

generated with BackendIM... (backend.im)
2025-05-15 15:49:28 +00:00

63 lines
1.6 KiB
Markdown

# Generic REST API Service
A RESTful API service built with FastAPI and SQLite for database storage.
## Features
- RESTful API endpoints for CRUD operations on items
- Async SQLAlchemy with SQLite database
- Database migrations with Alembic
- Health check endpoint
- Pydantic schemas for validation
- Comprehensive API documentation
## Project Structure
```
├── alembic/ # Database migration files
├── app/ # Application package
│ ├── api/ # API endpoints and routes
│ ├── db/ # Database connection and utilities
│ ├── models/ # SQLAlchemy ORM models
│ └── schemas/ # Pydantic schemas for validation and serialization
├── main.py # Application entry point
├── requirements.txt # Project dependencies
└── README.md # This file
```
## API Endpoints
- `GET /health`: Check API health status
- `GET /api/items`: List all items
- `GET /api/items/{item_id}`: Get a specific item
- `POST /api/items`: Create a new item
- `PUT /api/items/{item_id}`: Update an existing item
- `DELETE /api/items/{item_id}`: Delete an item
## Getting Started
1. Install dependencies:
```
pip install -r requirements.txt
```
2. Run the application:
```
uvicorn main:app --reload
```
3. Access the API documentation:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
## Database Migrations
Database migrations are managed with Alembic:
```
# Apply migrations
alembic upgrade head
# Create a new migration
alembic revision --autogenerate -m "description"
```