File size: 3,801 Bytes
bb0c63f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# Project Structure

> **Primary Responsibility:** Directory layout and codebase organization

Directory layout for the Enterprise AI Gateway.

```
Enterprise-AI-Gateway/
β”œβ”€β”€ src/                        # Source code
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ main.py                 # FastAPI application entry point
β”‚   β”œβ”€β”€ config.py               # Configuration and LLM client
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   └── routes.py           # API route definitions
β”‚   β”œβ”€β”€ llm/
β”‚   β”‚   └── client.py           # LLM provider client
β”‚   β”œβ”€β”€ metrics/
β”‚   β”‚   └── __init__.py         # Metrics tracking
β”‚   β”œβ”€β”€ models/
β”‚   β”‚   └── __init__.py         # Pydantic models
β”‚   β”œβ”€β”€ providers/
β”‚   β”‚   └── __init__.py         # Provider configuration
β”‚   └── security/
β”‚       └── __init__.py         # Security utilities (auth, PII, toxicity)
β”‚
β”œβ”€β”€ static/
β”‚   └── index.html              # Interactive demo dashboard
β”‚
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ unit/
β”‚   β”‚   └── test_security_models.py
β”‚   └── integration/
β”‚       └── test_gateway.py
β”‚
β”œβ”€β”€ docs/                       # Documentation (MECE structure)
β”‚   β”œβ”€β”€ README.md               # Index + Quick Start
β”‚   β”œβ”€β”€ api_reference.md        # API endpoints & functions
β”‚   β”œβ”€β”€ architecture.md         # System design & data flow
β”‚   β”œβ”€β”€ configuration.md        # Environment variables
β”‚   β”œβ”€β”€ deployment.md           # Deployment procedures
β”‚   β”œβ”€β”€ faq.md                  # Q&A format help
β”‚   β”œβ”€β”€ project_structure.md    # This file
β”‚   β”œβ”€β”€ security_overview.md    # Security architecture
β”‚   β”œβ”€β”€ testing.md              # Testing procedures
β”‚   └── troubleshooting.md      # Problem resolution
β”‚
β”œβ”€β”€ examples/
β”‚   └── basic_usage.py          # Usage examples
β”‚
β”œβ”€β”€ scripts/
β”‚   └── health_check.py         # Health check script
β”‚
β”œβ”€β”€ Dockerfile                  # Docker build configuration
β”œβ”€β”€ requirements.txt            # Python dependencies
β”œβ”€β”€ README.md                   # Project overview (root)
└── BUSINESS_README.md          # HuggingFace Spaces README
```

## Key Directories

### `src/` - Source Code

| Module | Purpose |
|--------|---------|
| `main.py` | FastAPI app initialization, middleware setup |
| `config.py` | Environment config, LLM client initialization |
| `api/routes.py` | HTTP endpoint handlers |
| `llm/client.py` | Multi-provider LLM client with cascade |
| `security/__init__.py` | Auth, PII detection, AI safety (Gemini + Lakera) |
| `models/__init__.py` | Request/response Pydantic models |
| `metrics/__init__.py` | Performance metrics tracking |
| `providers/__init__.py` | Provider pricing and configuration |

### `static/` - Frontend

Single-page interactive dashboard with:
- Real-time pipeline visualization
- Security gate status indicators
- Rate limiting controls
- Test scenario selector

### `tests/` - Test Suite

| Directory | Purpose |
|-----------|---------|
| `unit/` | Unit tests for individual functions |
| `integration/` | API endpoint integration tests |

### `docs/` - Documentation

See [Documentation Index](README.md) for the complete MECE documentation structure.

## Data Flow

```
Request β†’ src/main.py
           ↓
         src/security/ (auth, PII, toxicity check)
           ↓
         src/llm/client.py (provider cascade)
           ↓
         Response
```

## Related Docs

- [Architecture](architecture.md) - Detailed system design
- [API Reference](api_reference.md) - Endpoint documentation
- [Configuration](configuration.md) - Environment setup