Automated Action f24dc4e301 Create simple inventory application with FastAPI and SQLite
- Set up FastAPI project structure
- Configure SQLite database with SQLAlchemy
- Create Item model and schemas
- Implement CRUD endpoints for inventory items
- Set up Alembic for database migrations
- Add comprehensive documentation
2025-06-17 01:50:57 +00:00
2025-06-17 01:43:49 +00:00

Simple Inventory App

A FastAPI-based inventory management application that provides CRUD operations for managing inventory items.

Features

  • Create, read, update, and delete inventory items
  • Filter items by category
  • Pagination support
  • SQLite database for data persistence
  • Alembic for database migrations
  • Health check endpoint

API Endpoints

  • GET /: Root endpoint with basic app information
  • GET /health: Health check endpoint
  • GET /api/v1/items: List all items (with optional filtering and pagination)
  • POST /api/v1/items: Create a new item
  • GET /api/v1/items/{item_id}: Get a specific item by ID
  • PUT /api/v1/items/{item_id}: Update an existing item
  • DELETE /api/v1/items/{item_id}: Delete an item

Project Structure

.
├── alembic.ini                  # Alembic configuration
├── app                          # Application package
│   ├── api                      # API module
│   │   ├── v1                   # API version 1
│   │   │   ├── api.py           # API router
│   │   │   └── endpoints        # API endpoints
│   │   │       └── items.py     # Items endpoints
│   ├── core                     # Core application code
│   │   └── config.py            # Configuration settings
│   ├── db                       # Database module
│   │   ├── base.py              # SQLAlchemy Base
│   │   ├── base_model.py        # Models import for Alembic
│   │   └── session.py           # DB session
│   ├── models                   # SQLAlchemy models
│   │   └── item.py              # Item model
│   └── schemas                  # Pydantic schemas
│       └── item.py              # Item schemas
├── main.py                      # FastAPI application
├── migrations                   # Alembic migrations
│   ├── env.py                   # Alembic environment
│   ├── README                   # Migrations readme
│   ├── script.py.mako           # Migration script template
│   └── versions                 # Migration versions
│       └── 20240512_initial_tables.py  # Initial migration
└── requirements.txt             # Project dependencies

Setup and Installation

  1. Install the dependencies:

    pip install -r requirements.txt
    
  2. Apply database migrations:

    alembic upgrade head
    
  3. Run the application:

    uvicorn main:app --reload
    
  4. Access the application:

Environment Variables

The application uses the following environment variables:

  • PROJECT_NAME: Name of the project (default: "Simple Inventory App")
  • BACKEND_CORS_ORIGINS: List of allowed CORS origins (default: ["*"])

Inventory Item Model

Each inventory item has the following attributes:

  • id: Unique identifier (integer)
  • name: Item name (string, required)
  • description: Item description (string, optional)
  • quantity: Available quantity (integer, default: 0)
  • price: Item price (float, optional)
  • category: Item category (string, optional)
  • created_at: Creation timestamp (datetime)
  • updated_at: Last update timestamp (datetime)

Development

Linting

To lint the code with Ruff:

ruff check .

To automatically fix linting issues:

ruff check --fix .
Description
Project: Simple Inventory App
Readme 39 KiB
Languages
Python 95.3%
Mako 4.7%