How waldirevora/ai-enterprise-lab works
AI Enterprise Lab is a FastAPI-based enterprise AI gateway. Clients authenticate and submit documents or questions; the product authorizes organizational and document access, ingests and retrieves RAG context, then generates grounded answers locally or through a policy-controlled external provider. Agents add tool-mediated knowledge search. PostgreSQL/pgvector, rate limiting, audit events, metrics, and readiness support the runtime. The README documents Redis and integrations; sampled source confirms only some wiring, so undocumented connections are omitted.
Main entry points: main.py FastAPI gateway · rag.py RAG routes · generation.py Generation service · service.py RAG service
Components 25
Gateway and access
- FastAPI gateway
app/main.py - RAG routes
app/api/rag.py - Agent routes
app/api/agents.py - Authentication
app/access/authentication.py - Principal context
app/access/context.py - Unit grants
app/access/unit_grants.py - Unit scope
app/access/unit_scope.py - Health and readiness
app/health/readiness.py
Knowledge retrieval
- Document ingestion
app/rag/ingestion.py - ACL retrieval
app/rag/retrieval.py - Context builder
app/rag/context_builder.py - RAG service
app/rag/service.py
Agents and generation
- Knowledge agent
app/agents/service.py - Agent tools
app/agents/tools.py - Generation service
app/services/generation.py
Security and observability
- Provider policy
app/policies/provider_policy.py - Rate limiting
app/rate_limit/http.py - Audit logging
app/audit/logger.py - Metrics
app/observability/metrics.py
Stores and providers
- PostgreSQL pgvector
app/db/postgres.py - Ollama providers
app/providers/ollama.py - Ollama embeddings
app/providers/ollama_embeddings.py - DeepSeek provider
app/providers/deepseek.py - Redis
Other components
- Client
Connections 31
- Client → FastAPI gateway: sends requests
README.md - FastAPI gateway → RAG routes: routes requests
app/main.py - FastAPI gateway → Agent routes: routes requests
app/main.py - RAG routes → Authentication: requires identity
app/api/rag.py - Authentication → Principal context: builds context
app/access/authentication.py - RAG routes → Unit grants: loads grants
app/api/rag.py - RAG routes → Unit scope: checks scope
app/api/rag.py - Agent routes → Knowledge agent: invokes agent
app/api/agents.py - Knowledge agent → Agent tools: searches knowledge
app/agents/service.py - Knowledge agent → Generation service: generates answer
app/agents/service.py - Agent tools → ACL retrieval: searches documents
app/agents/tools.py - RAG routes → RAG service: requests answer
app/api/rag.py - RAG service → ACL retrieval: retrieves chunks
app/rag/service.py - RAG service → Context builder: builds context
app/rag/service.py - RAG service → Generation service: generates answer
app/rag/service.py - Document ingestion → PostgreSQL pgvector: writes documents
app/rag/ingestion.py - Document ingestion → Ollama embeddings: creates embeddings
app/rag/ingestion.py - ACL retrieval → PostgreSQL pgvector: queries vectors
app/rag/retrieval.py - ACL retrieval → Ollama embeddings: embeds query
app/rag/retrieval.py - Generation service → Provider policy: checks egress policy
app/services/generation.py - Generation service → Ollama providers: calls local model
app/services/generation.py - Generation service → DeepSeek provider: calls external model
app/services/generation.py - Generation service → Audit logging: emits events
app/services/generation.py - RAG service → Metrics: records usage
app/rag/service.py - Knowledge agent → Audit logging: emits events
app/agents/service.py - Knowledge agent → Metrics: records runs
app/agents/service.py - RAG routes → Rate limiting: enforces limits
app/api/rag.py - Rate limiting → Redis: uses backend
README.md - FastAPI gateway → Health and readiness: serves readiness
app/main.py - FastAPI gateway → Audit logging: installs audit middleware
app/main.py - FastAPI gateway → Metrics: installs metrics middleware
app/main.py