Automated Action 852e0a32b1 Create simple FastAPI application with SQLite and Alembic
- Set up project structure
- Create FastAPI app with health endpoint
- Implement SQLAlchemy with SQLite database
- Set up Alembic for database migrations
- Create CRUD operations for items
- Add comprehensive documentation
2025-05-20 14:20:21 +00:00
2025-05-20 14:16:01 +00:00

Simple FastAPI Application

This is a simple FastAPI application with SQLite database integration, built to demonstrate best practices for API development with FastAPI.

Features

  • RESTful API with FastAPI
  • SQLite database with SQLAlchemy ORM
  • Database migrations with Alembic
  • CRUD operations for items
  • Health check endpoint
  • OpenAPI documentation
  • Code linting with Ruff

Project Structure

├── app/
│   ├── api/
│   │   ├── endpoints/
│   │   │   ├── health.py
│   │   │   └── items.py
│   ├── core/
│   │   └── config.py
│   ├── db/
│   │   └── session.py
│   ├── models/
│   │   └── models.py
│   ├── schemas/
│   │   └── item.py
│   └── storage/
│       └── db/
├── migrations/
│   ├── versions/
│   │   └── 47e3b63e1a20_create_items_table.py
│   ├── env.py
│   └── script.py.mako
├── alembic.ini
├── main.py
├── README.md
└── requirements.txt

Installation

  1. Clone the repository
  2. Install dependencies:
pip install -r requirements.txt

Running the Application

Start the application with uvicorn:

uvicorn main:app --host 0.0.0.0 --port 8000 --reload

API Documentation

Once the application is running, you can access:

API Endpoints

Health Check

  • GET /health - Check if the API and database are running

Items

  • GET /api/v1/items - Get all items
  • GET /api/v1/items/{item_id} - Get an item by ID
  • POST /api/v1/items - Create a new item
  • PATCH /api/v1/items/{item_id} - Update an item
  • DELETE /api/v1/items/{item_id} - Delete an item

Database Migrations

Run migrations:

alembic upgrade head

Create a new migration:

alembic revision --autogenerate -m "description"

License

MIT

Description
Project: Simple FastAPI Application
Readme 38 KiB
Languages
Python 95.5%
Mako 4.5%