graph TB
    subgraph Client["Client Layer"]
        WEB["🌐 Next.js 14 Frontend<br/>shadcn/ui<br/>Port: 3000"]
    end

    subgraph API["API & Backend Layer"]
        APIGW["📡 API Gateway<br/>NestJS<br/>Port: 3001"]
        AUTH["🔐 Auth Service<br/>API Key + Secret<br/>(POC)"]
        WORKFLOW["⚙️ Workflow Service<br/>NestJS Module"]
        APPROVAL["✅ Approval Service<br/>NestJS Module"]
        DOCUMENT["📄 Document Service<br/>NestJS Module"]
    end

    subgraph Data["Data Layer"]
        DB["🗄️ PostgreSQL<br/>Port: 5432<br/>license_requests<br/>approvals, documents<br/>audit_logs"]
        CACHE["⚡ Redis Cache<br/>Port: 6379<br/>Session, Workflow State"]
        STORAGE["📦 MinIO<br/>Port: 9000<br/>Document Files<br/>License PDFs"]
    end

    subgraph Blockchain["Blockchain Layer"]
        BESU["⛓️ Hyperledger Besu<br/>QBFT Consensus<br/>Port: 8545"]
        CONTRACTS["📋 Smart Contracts<br/>• LicenseRequestNFT<br/>• ApprovalManager<br/>• DepartmentRegistry<br/>• WorkflowRegistry"]
        BCDB["📚 Chain State<br/>Account Balances<br/>NFT Metadata"]
    end

    subgraph Integrations["External Integrations"]
        DIGILOCKER["📱 DigiLocker Mock<br/>Document Verification"]
        LEGACY["💼 Legacy Systems<br/>Data Integration"]
        WEBHOOK["🔔 Webhook Service<br/>Event Notifications"]
    end

    WEB -->|REST/GraphQL| APIGW
    APIGW -->|Validate Token| AUTH
    APIGW -->|Route Request| WORKFLOW
    APIGW -->|Route Request| APPROVAL
    APIGW -->|Route Request| DOCUMENT

    WORKFLOW -->|Read/Write| DB
    WORKFLOW -->|Cache State| CACHE
    WORKFLOW -->|Submit TX| BESU

    APPROVAL -->|Read/Write| DB
    APPROVAL -->|Cache| CACHE
    APPROVAL -->|Smart Contract Call| BESU

    DOCUMENT -->|Store Files| STORAGE
    DOCUMENT -->|Hash Generation| DOCUMENT
    DOCUMENT -->|Record Hash| BESU

    BESU -->|Execute| CONTRACTS
    CONTRACTS -->|Update State| BCDB

    APIGW -->|Verify Docs| DIGILOCKER
    APIGW -->|Query Legacy| LEGACY
    APPROVAL -->|Send Event| WEBHOOK

    style WEB fill:#10b981,stroke:#059669,stroke-width:2px,color:#fff
    style APIGW fill:#3b82f6,stroke:#1e40af,stroke-width:2px,color:#fff
    style AUTH fill:#f59e0b,stroke:#d97706,stroke-width:2px,color:#fff
    style DB fill:#8b5cf6,stroke:#6d28d9,stroke-width:2px,color:#fff
    style STORAGE fill:#ec4899,stroke:#be123c,stroke-width:2px,color:#fff
    style CACHE fill:#06b6d4,stroke:#0891b2,stroke-width:2px,color:#fff
    style BESU fill:#ef4444,stroke:#991b1b,stroke-width:2px,color:#fff
    style CONTRACTS fill:#dc2626,stroke:#7f1d1d,stroke-width:2px,color:#fff
