govorov/backend/README.md

1.4 KiB

Backend for Glass Cutting Optimization

This directory contains the FastAPI backend application.

Setup

  1. Create a virtual environment:
    python -m venv venv
    source venv/bin/activate  # On Windows use `venv\Scripts\activate`
    
  2. Install dependencies:
    pip install -r requirements.txt
    
  3. Configure environment variables: Create a .env file in this directory based on .env.example (you'll create this later).
  4. Run database migrations (using Alembic):
    # Initialize alembic (only once)
    # alembic init alembic
    
    # Edit alembic.ini and alembic/env.py to point to your models and database URL
    # ...
    
    # Create a migration
    # alembic revision --autogenerate -m "Initial migration"
    
    # Apply the migration
    # alembic upgrade head
    
  5. Run the development server:
    uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
    

Project Structure

  • app/: Main application code
    • core/: Configuration, settings, dependencies
    • db/: Database session management
    • models/: SQLAlchemy models
    • schemas/: Pydantic schemas
    • routers/: API route handlers
    • services/: Business logic
  • alembic/: Database migration scripts
  • tests/: Application tests
  • .env: Environment variables (local)
  • alembic.ini: Alembic configuration
  • requirements.txt: Python dependencies