Automated Action 16d63c4168 Create FastAPI REST API service with SQLite database
- Set up FastAPI application with CORS support
- Implement SQLite database with SQLAlchemy ORM
- Create User model with CRUD operations
- Add Alembic for database migrations
- Include health check and documentation endpoints
- Set up proper project structure with organized modules
- Add comprehensive README with setup instructions
- Configure Ruff for code linting and formatting
2025-07-03 18:56:01 +00:00
2025-07-03 18:52:19 +00:00

REST API Service

A REST API service built with FastAPI and SQLite, providing user management functionality.

Features

  • FastAPI web framework
  • SQLite database with SQLAlchemy ORM
  • Alembic database migrations
  • CRUD operations for users
  • Health check endpoint
  • Auto-generated OpenAPI documentation
  • CORS support

Project Structure

├── main.py                 # FastAPI application entry point
├── requirements.txt        # Python dependencies
├── alembic.ini            # Alembic configuration
├── alembic/               # Database migrations
│   ├── env.py
│   ├── script.py.mako
│   └── versions/
│       └── 001_initial_migration.py
└── app/
    ├── __init__.py
    ├── db/
    │   ├── __init__.py
    │   ├── base.py        # SQLAlchemy base
    │   └── session.py     # Database session configuration
    ├── models/
    │   ├── __init__.py
    │   └── user.py        # User model
    ├── schemas/
    │   ├── __init__.py
    │   └── user.py        # Pydantic schemas
    └── crud/
        ├── __init__.py
        └── user.py        # CRUD operations

Installation

  1. Install dependencies:
pip install -r requirements.txt
  1. Run database migrations:
alembic upgrade head
  1. Start the application:
uvicorn main:app --host 0.0.0.0 --port 8000 --reload

API Endpoints

  • GET / - Service information
  • GET /health - Health check
  • GET /docs - OpenAPI documentation
  • GET /redoc - Alternative API documentation
  • POST /users/ - Create a new user
  • GET /users/ - List all users
  • GET /users/{user_id} - Get user by ID
  • PUT /users/{user_id} - Update user
  • DELETE /users/{user_id} - Delete user

Database

The application uses SQLite database stored at /app/storage/db/db.sqlite.

Environment Variables

No environment variables are required for basic operation. The application uses SQLite with default settings.

Development

To run the application in development mode:

uvicorn main:app --reload

The API will be available at http://localhost:8000 with automatic reload on code changes.

Description
Project: REST API Service
Readme 36 KiB
Languages
Python 93.9%
Mako 6.1%