# Architecture Diagram

```
┌─────────────────────────────────────────────────────────────────────┐
│                         DEVELOPER                                   │
│                      (Web Browser)                                  │
└──────────────────────────────┬──────────────────────────────────────┘
                               │
                               ▼
┌─────────────────────────────────────────────────────────────────────┐
│                    FRONTEND DASHBOARD                               │
│              React + TypeScript + Vite                              │
│  ┌─────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐  │
│  │Dashboard │ │ Service  │ │Template  │ │Scaffold  │ │Provision │  │
│  │         │ │ Catalog  │ │  View    │ │  New Svc │ │Environ.  │  │
│  └─────────┘ └──────────┘ └──────────┘ └──────────┘ └──────────┘  │
│  ┌──────────────┐ ┌────────────────┐ ┌────────────────────────┐   │
│  │Provisioning  │ │  Audit Logs    │ │  Service Details       │   │
│  │History       │ │                │ │                        │   │
│  └──────────────┘ └────────────────┘ └────────────────────────┘   │
└──────────────────────────────┬──────────────────────────────────────┘
                               │ HTTP API
                               ▼
┌─────────────────────────────────────────────────────────────────────┐
│                      BACKEND API                                    │
│                 FastAPI (Python)                                    │
│  ┌──────────────────────────────────────────────────────────────┐   │
│  │                     API ROUTERS                              │   │
│  │  /api/auth  /api/services  /api/templates                   │   │
│  │  /api/provisioning  /api/audit  /api/dashboard              │   │
│  └──────────────────────────────────────────────────────────────┘   │
│                               │                                     │
│  ┌──────────────────────────────────────────────────────────────┐   │
│  │              AUTHENTICATION / RBAC                           │   │
│  │  ┌─────────┐ ┌───────────────┐ ┌──────────────────────┐     │   │
│  │  │ Header  │ │  Role Check   │ │  Permission Verify   │     │   │
│  │  │ Auth    │ │  (4 roles)    │ │  (per-endpoint)      │     │   │
│  │  └─────────┘ └───────────────┘ └──────────────────────┘     │   │
│  └──────────────────────────────────────────────────────────────┘   │
│                               │                                     │
│  ┌──────────────────────────────────────────────────────────────┐   │
│  │              ★ POLICY VALIDATION ★                           │   │
│  │              (NO BYPASS PATH)                                 │   │
│  │  ┌────────────┐ ┌────────────┐ ┌──────────────────────┐     │   │
│  │  │  Role      │ │ Environment│ │  Template Approval   │     │   │
│  │  │  Check     │ │ Restriction│ │  Verification        │     │   │
│  │  └────────────┘ └────────────┘ └──────────────────────┘     │   │
│  │  ┌────────────┐ ┌────────────┐ ┌──────────────────────┐     │   │
│  │  │  Resource  │ │  Naming    │ │  Service Name        │     │   │
│  │  │  Limits    │ │  Convention│ │  Validation          │     │   │
│  │  └────────────┘ └────────────┘ └──────────────────────┘     │   │
│  └──────────────────────────────────────────────────────────────┘   │
│                               │                                     │
│                               ▼                                     │
│  ┌──────────────────────────────────────────────────────────────┐   │
│  │              PROVISIONING ENGINE                             │   │
│  │  ┌──────────────────────────────────────────────────────┐    │   │
│  │  │              SAFE SANDBOX PROVISIONER                │    │   │
│  │  │  • Creates local project structure from templates    │    │   │
│  │  │  • Generates CI/CD configuration                     │    │   │
│  │  │  • NO unrestricted shell access                      │    │   │
│  │  │  • NO arbitrary infrastructure commands              │    │   │
│  │  └──────────────────────────────────────────────────────┘    │   │
│  │                                                              │   │
│  │  Status: PENDING → VALIDATING → APPROVED → PROVISIONING     │   │
│  │          → COMPLETED (or REJECTED / FAILED)                  │   │
│  └──────────────────────────────────────────────────────────────┘   │
│                               │                                     │
│  ┌──────────────────────────────────────────────────────────────┐   │
│  │              APPROVED TEMPLATES                              │   │
│  │  ┌─────────────────────┐  ┌──────────────────────┐          │   │
│  │  │ Python FastAPI Svc  │  │ Node.js Express Svc  │          │   │
│  │  │ • src/main.py       │  │ • src/index.js       │          │   │
│  │  │ • tests/            │  │ • tests/             │          │   │
│  │  │ • Dockerfile        │  │ • Dockerfile         │          │   │
│  │  │ • CI/CD config      │  │ • CI/CD config       │          │   │
│  │  │ • requirements.txt  │  │ • package.json       │          │   │
│  │  └─────────────────────┘  └──────────────────────┘          │   │
│  └──────────────────────────────────────────────────────────────┘   │
│                               │                                     │
│  ┌──────────────────────────────────────────────────────────────┐   │
│  │              AUDIT LOG                                       │   │
│  │  • Every action logged with user, role, action, timestamp   │   │
│  │  • Persisted in SQLite                                      │   │
│  │  • Viewable by authorized users                             │   │
│  └──────────────────────────────────────────────────────────────┘   │
│                               │                                     │
│                               ▼                                     │
│  ┌──────────────────────────────────────────────────────────────┐   │
│  │              DATABASE (SQLite)                               │   │
│  │  ┌────────┐ ┌─────────┐ ┌──────────┐ ┌─────────────────┐   │   │
│  │  │ users  │ │services │ │templates │ │provision_reqs   │   │   │
│  │  ├────────┤ ├─────────┤ ├──────────┤ ├─────────────────┤   │   │
│  │  │ roles  │ │         │ │          │ │  audit_logs     │   │   │
│  │  └────────┘ └─────────┘ └──────────┘ └─────────────────┘   │   │
│  └──────────────────────────────────────────────────────────────┘   │
└─────────────────────────────────────────────────────────────────────┘

KEY: ★ = CRITICAL - No bypass possible around policy validation
```