How 24f2001293/universal-data-connector works
1. Overall shape
This is a single FastAPI service that exposes a unified query interface for LLMs. The repo is organized around one API boundary, a small domain layer, and three data-source adapters: CRM, Support, and Analytics. The implementation is designed for low-bandwidth, voice-oriented responses rather than raw record dumping.
2. Entry point and runtime
app/main.py is the application bootstrap for FastAPI. It likely wires routers, config, and logging together and defines the public API surface. The service is meant to run with Uvicorn, and the repo includes Docker/Docker Compose for containerized deployment.
3. API boundary
app/routers/data.py and app/routers/health.py are the HTTP boundaries. The data router is the main business endpoint surface, centered on the README’s /api/v1/query concept, while the health router provides liveness/readiness-style checks for operational use.
4. Core domain models
app/models/common.py contains the typed request/response shapes. These models are important because the repository emphasizes strict typing, Pydantic v2, and OpenAPI schema quality for LLM function calling. The response shape appears to carry both results and metadata such as counts and freshness.
5. Connector layer as strategy boundary
app/connectors/ is the main abstraction for source-specific access. base.py defines the shared connector interface, while crm_connector.py, support_connector.py, and analytics_connector.py implement source-specific retrieval and normalization. This is the main place where the “unified interface” fans out into distinct data-source strategies.
6. Business logic and orchestration
app/services/business_rules.py and app/services/data_identifier.py appear to decide which connector to use, how to normalize fuzzy user terms, and what constraints apply to the request. app/services/voice_optimizer.py is the voice UX layer: it reduces payload size, caps result counts, and summarizes analytics into speech-friendly outputs.
7. Data flow
A request enters the API router, is validated by Pydantic models, then passed into service logic that identifies the target data domain and applies business rules. The chosen connector fetches and normalizes data from local JSON-backed mock datasets in data/, then the service layer packages the result with metadata such as total vs. returned counts and staleness/freshness context.
8. Data storage and locality
The data/ directory contains JSON files for analytics, customers, and support_tickets. This means the repo is self-contained and currently uses local file-backed mock data rather than an external database or SaaS API. That makes the connector layer the primary integration boundary, even though the backing store is local in this repo.
9. LLM/tooling integration
The README and openapi_schema.json show that the service is intended to be consumed by LLMs via tool calling. The generated OpenAPI schema is part of the architecture, because it defines the contract an agent would use to call the unified query endpoint. demo-llm-intergrator.py demonstrates that external agent loop using an OpenRouter API key from .env.
10. Configuration and observability
app/config.py centralizes environment-driven settings, likely via Pydantic Settings. app/utils/logging.py provides structured logging, which is important for tracing request flow through the router, service, and connector layers in production.
11. Testing boundary
tests/test_api.py and tests/test_business_rules.py show a split between API-level validation and domain-rule enforcement. This indicates the architecture is tested at both the HTTP contract layer and the core business logic layer, which is important for a system that relies on strict response shapes and result limits.
12. Deployment footprint
Dockerfile, docker-compose.yml, and requirements.txt define a lightweight Python service deployment. There are no signs of a larger distributed system; the main architectural boundaries are inside the app itself: API, orchestration/services, connector adapters, and JSON-backed data.
Main entry points: data.py Data API · main.py Main app · base.py Connector base · business_rules.py Rules
Components 22
Application
FastAPI service runtime and internal layers
- Main app · Application entrypoint that wires routers, config, and runtime setup
app/main.py - Data API · Primary query endpoint surface
app/routers/data.py - Health API · Operational liveness and readiness checks
app/routers/health.py - Models · Typed request and response shapes for the public API
app/models/common.py - Domain ID · Maps user intent to the right data domain or connector
app/services/data_identifier.py - Rules · Applies request constraints and domain-specific handling
app/services/business_rules.py - Voice UX · Condenses results for low-bandwidth, speech-friendly responses
app/services/voice_optimizer.py - Connector base · Shared connector contract for source-specific access
app/connectors/base.py - CRM connector · Retrieves and normalizes customer data
app/connectors/crm_connector.py - Support connector · Retrieves and normalizes support ticket data
app/connectors/support_connector.py - Analytics connector · Retrieves and normalizes analytics data
app/connectors/analytics_connector.py - Config · Environment-driven application settings
app/config.py - Logging · Structured logging utilities for request tracing
app/utils/logging.py
Data Layer
Local JSON-backed source data used by connectors
Delivery
Deployment, schema, and integration artifacts
- OpenAPI · Generated schema for tool calling and client integration
openapi_schema.json - Demo agent · Example LLM client loop using the service contract
demo-llm-intergrator.py - Dockerfile · Container image definition for the service
Dockerfile - Compose · Local container orchestration definition
docker-compose.yml
Tests
API and business-rule validation
- API tests · Validates HTTP contract and endpoint behavior
tests/test_api.py - Rule tests · Validates business-rule behavior and constraints
tests/test_business_rules.py
Connections 23
- Main app → Data API: mounts · Registers the main data endpoint router
- Main app → Health API: mounts · Registers operational health endpoints
- Main app → Config: loads · Uses environment settings at startup
- Main app → Logging: configures · Initializes structured logging for runtime traces
- Data API → Models: validates · Uses Pydantic models for request and response contracts
- Data API → Domain ID: delegates · Identifies the target domain for each query
- Data API → Rules: applies · Enforces business constraints before data access
- Data API → Voice UX: formats · Returns concise voice-friendly payloads
- Domain ID → Connector base: selects · Chooses among connector implementations
- Rules → Connector base: governs · Controls what connector access is allowed
- Voice UX → Models: shapes · Produces the response structure exposed by the API
- Connector base → CRM connector: implements · CRM-specific adapter implementation
- Connector base → Support connector: implements · Support-specific adapter implementation
- Connector base → Analytics connector: implements · Analytics-specific adapter implementation
- CRM connector → Customers: reads · Loads local customer records
- Support connector → Tickets: reads · Loads local support records
- Analytics connector → Analytics: reads · Loads local analytics records
- OpenAPI → Data API: documents · Describes the query endpoint contract
- Demo agent → OpenAPI: consumes · Uses the schema for LLM tool invocation
- Dockerfile → Main app: packages · Builds the application runtime image
- Compose → Dockerfile: orchestrates · Runs the service in a local container stack
- API tests → Data API: verifies · Checks the public HTTP behavior
- Rule tests → Rules: verifies · Checks business-rule decisions and limits