REST API Service

A RESTful API service built with FastAPI and SQLite.

Features

  • FastAPI framework for efficient API development
  • SQLite database for data storage
  • Alembic for database migrations
  • Pydantic for data validation
  • SQLAlchemy ORM for database interactions
  • OpenAPI documentation (Swagger UI and ReDoc)
  • Health endpoint for application monitoring

Project Structure

.
├── alembic.ini                  # Alembic configuration
├── app/                         # Application package
│   ├── api/                     # API endpoints
│   │   ├── endpoints/           # Route handlers
│   │   └── api.py               # API router
│   ├── core/                    # Core modules
│   │   └── config.py            # Application settings
│   ├── db/                      # Database modules
│   │   ├── base.py              # Import all models for Alembic
│   │   ├── base_class.py        # SQLAlchemy Base class
│   │   └── session.py           # Database session management
│   ├── models/                  # SQLAlchemy models
│   ├── schemas/                 # Pydantic schemas
│   └── services/                # Business logic
├── main.py                      # Application entry point
├── migrations/                  # Alembic migrations
│   └── versions/                # Migration scripts
├── requirements.txt             # Project dependencies
└── tests/                       # Test modules

API Endpoints

  • /api/v1/users - User CRUD operations
  • /api/v1/items - Item CRUD operations
  • /health - Health check endpoint
  • /docs - Swagger UI documentation
  • /redoc - ReDoc documentation

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/restapiservice.git
cd restapiservice
  1. Install dependencies:
pip install -r requirements.txt
  1. Run database migrations:
alembic upgrade head
  1. Start the server:
uvicorn main:app --reload

The API will be available at http://localhost:8000.

Development

Database Migrations

To create a new migration after modifying models:

alembic revision --autogenerate -m "Description of changes"

To apply migrations:

alembic upgrade head

Linting

The project uses Ruff for linting and formatting:

ruff check .
ruff format .

API Documentation

Once the server is running, you can access:

License

This project is licensed under the MIT License.

Description
Project: REST API Service
Readme 48 KiB
Languages
Python 97.7%
Mako 2.3%