graph TB
    subgraph "User"
        BROWSER["Web Browser"]
    end

    subgraph "Apache Web Server (Port 443)"
        APACHE["Apache2<br/>+ mod_proxy"]
        STATIC["Static Files<br/>(React Build)"]
    end

    subgraph "Docker Compose"
        subgraph "Backend Container"
            UVICORN["Uvicorn<br/>(ASGI Server)"]
            FASTAPI["FastAPI App<br/>(Port 8000)"]
        end
        subgraph "Database Container"
            POSTGRES["PostgreSQL 15<br/>(Port 5432)"]
            PGDATA["Persistent Volume<br/>(/var/lib/postgresql/data)"]
        end
    end

    subgraph "File Storage"
        UPLOADS["uploads/<br/>(Proof Files)"]
        KB_FILES["kb_storage/<br/>(Knowledge Base Docs)"]
    end

    subgraph "External Services"
        GEMINI["Google Gemini API"]
        AZURE["Azure AD"]
        LLAMA["LlamaParse API"]
    end

    BROWSER -->|"HTTPS"| APACHE
    APACHE -->|"Serve"| STATIC
    APACHE -->|"Proxy /api/*<br/>/ws/* /health /info"| UVICORN
    UVICORN --- FASTAPI
    FASTAPI -->|"asyncpg"| POSTGRES
    POSTGRES --- PGDATA
    FASTAPI -->|"Read/Write"| UPLOADS
    FASTAPI -->|"Read/Write"| KB_FILES
    FASTAPI -->|"HTTPS"| GEMINI
    FASTAPI -->|"HTTPS"| LLAMA
    BROWSER -->|"OAuth2"| AZURE

    classDef user fill:#006DE3,stroke:#1A2142,color:#fff
    classDef proxy fill:#C3FB5A,stroke:#1A2142,color:#1A2142
    classDef backend fill:#1A2142,stroke:#006DE3,color:#fff
    classDef db fill:#01A1A2,stroke:#1A2142,color:#fff
    classDef storage fill:#FFBA00,stroke:#1A2142,color:#1A2142
    classDef external fill:#7A0FF9,stroke:#1A2142,color:#fff

    class BROWSER user
    class APACHE,STATIC proxy
    class UVICORN,FASTAPI backend
    class POSTGRES,PGDATA db
    class UPLOADS,KB_FILES storage
    class GEMINI,AZURE,LLAMA external
