Automated Action a4ffe78f61 Create REST API with FastAPI and SQLAlchemy
- Set up project structure with FastAPI
- Create SQLite database with SQLAlchemy
- Implement Alembic for database migrations
- Add CRUD operations for items resource
- Create health endpoint
- Update documentation

generated with BackendIM... (backend.im)
2025-05-14 10:26:10 +00:00

Generic REST API

A RESTful API built with FastAPI and SQLAlchemy.

Features

  • FastAPI for high-performance API with automatic OpenAPI documentation
  • SQLAlchemy ORM for database operations
  • SQLite database for storage
  • Alembic for database migrations
  • Pydantic models for request/response validation
  • CRUD operations for the 'items' resource
  • Health check endpoint

Project Structure

├── alembic/               # Database migration scripts
├── app/                   # Application source code
│   ├── api/               # API endpoints
│   │   ├── endpoints/     # API routes
│   ├── crud/              # CRUD operations
│   ├── db/                # Database configurations
│   ├── models/            # SQLAlchemy models
│   └── schemas/           # Pydantic schemas
├── storage/               # Storage directory
│   └── db/                # Database files
├── alembic.ini            # Alembic configuration
├── main.py                # Application entry point
└── requirements.txt       # Project dependencies

Installation and Setup

  1. Clone the repository

  2. Install the dependencies:

    pip install -r requirements.txt
    
  3. Apply the database migrations:

    alembic upgrade head
    
  4. Run the application:

    uvicorn main:app --reload
    

API Documentation

Once the application is running, you can access the API documentation at:

API Endpoints

Items Resource

  • GET /items: Get all items (paginated)
  • POST /items: Create a new item
  • GET /items/{item_id}: Get a specific item by ID
  • PUT /items/{item_id}: Update an item
  • DELETE /items/{item_id}: Delete an item

Health Check

  • GET /health: Check API health status
Description
Project: Generic REST API
Readme 35 KiB
Languages
Python 94.4%
Mako 5.6%