Spaces:
Sleeping
Sleeping
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
|