# 24f2001293/universal-data-connector architecture

> Architecture diagram of the GitHub repository 24f2001293/universal-data-connector, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/24f2001293/universal-data-connector
- Repository: https://github.com/24f2001293/universal-data-connector

## Overview

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: [`app/routers/data.py`](https://github.com/24f2001293/universal-data-connector/blob/main/app/routers/data.py) (Data API), [`app/main.py`](https://github.com/24f2001293/universal-data-connector/blob/main/app/main.py) (Main app), [`app/connectors/base.py`](https://github.com/24f2001293/universal-data-connector/blob/main/app/connectors/base.py) (Connector base), [`app/services/business_rules.py`](https://github.com/24f2001293/universal-data-connector/blob/main/app/services/business_rules.py) (Rules)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_main["Main app<br/>fastapi bootstrap<br/>[main.py]"]
  node_router_data["Data API<br/>http router<br/>[data.py]"]
  node_router_health["Health API<br/>http router<br/>[health.py]"]
  node_models_common["Models<br/>pydantic schemas<br/>[common.py]"]
  node_svc_identifier{{"Domain ID<br/>routing service<br/>[data_identifier.py]"}}
  node_svc_rules{{"Rules<br/>business logic<br/>[business_rules.py]"}}
  node_svc_voice{{"Voice UX<br/>response optimizer<br/>[voice_optimizer.py]"}}
  node_conn_base["Connector base<br/>adapter interface<br/>[base.py]"]
  node_conn_crm["CRM connector<br/>source adapter<br/>[crm_connector.py]"]
  node_conn_support["Support connector<br/>source adapter"]
  node_conn_analytics["Analytics connector<br/>source adapter"]
  node_config["Config<br/>settings<br/>[config.py]"]
  node_logging["Logging<br/>observability<br/>[logging.py]"]
end

subgraph group_data["Data Layer"]
  node_crm_data[("Customers<br/>json dataset<br/>[customers.json]")]
  node_support_data[("Tickets<br/>json dataset")]
  node_analytics_data[("Analytics<br/>json dataset<br/>[analytics.json]")]
end

subgraph group_ops["Delivery"]
  node_openapi["OpenAPI<br/>api contract"]
  node_demo_agent["Demo agent<br/>integration script"]
  node_dockerfile["Dockerfile<br/>container build"]
  node_compose["Compose<br/>deployment spec<br/>[docker-compose.yml]"]
end

subgraph group_tests["Tests"]
  node_tests_api["API tests<br/>test suite<br/>[test_api.py]"]
  node_tests_rules["Rule tests<br/>test suite"]
end

node_main -->|"mounts"| node_router_data
node_main -->|"mounts"| node_router_health
node_main -->|"loads"| node_config
node_main -->|"configures"| node_logging
node_router_data -->|"validates"| node_models_common
node_router_data -->|"delegates"| node_svc_identifier
node_router_data -->|"applies"| node_svc_rules
node_router_data -->|"formats"| node_svc_voice
node_svc_identifier -->|"selects"| node_conn_base
node_svc_rules -->|"governs"| node_conn_base
node_svc_voice -->|"shapes"| node_models_common
node_conn_base -->|"implements"| node_conn_crm
node_conn_base -->|"implements"| node_conn_support
node_conn_base -->|"implements"| node_conn_analytics
node_conn_crm -->|"reads"| node_crm_data
node_conn_support -->|"reads"| node_support_data
node_conn_analytics -->|"reads"| node_analytics_data
node_openapi -->|"documents"| node_router_data
node_demo_agent -->|"consumes"| node_openapi
node_dockerfile -->|"packages"| node_main
node_compose -->|"orchestrates"| node_dockerfile
node_tests_api -->|"verifies"| node_router_data
node_tests_rules -->|"verifies"| node_svc_rules

click node_main "https://github.com/24f2001293/universal-data-connector/blob/main/app/main.py"
click node_router_data "https://github.com/24f2001293/universal-data-connector/blob/main/app/routers/data.py"
click node_router_health "https://github.com/24f2001293/universal-data-connector/blob/main/app/routers/health.py"
click node_models_common "https://github.com/24f2001293/universal-data-connector/blob/main/app/models/common.py"
click node_svc_identifier "https://github.com/24f2001293/universal-data-connector/blob/main/app/services/data_identifier.py"
click node_svc_rules "https://github.com/24f2001293/universal-data-connector/blob/main/app/services/business_rules.py"
click node_svc_voice "https://github.com/24f2001293/universal-data-connector/blob/main/app/services/voice_optimizer.py"
click node_conn_base "https://github.com/24f2001293/universal-data-connector/blob/main/app/connectors/base.py"
click node_conn_crm "https://github.com/24f2001293/universal-data-connector/blob/main/app/connectors/crm_connector.py"
click node_conn_support "https://github.com/24f2001293/universal-data-connector/blob/main/app/connectors/support_connector.py"
click node_conn_analytics "https://github.com/24f2001293/universal-data-connector/blob/main/app/connectors/analytics_connector.py"
click node_config "https://github.com/24f2001293/universal-data-connector/blob/main/app/config.py"
click node_logging "https://github.com/24f2001293/universal-data-connector/blob/main/app/utils/logging.py"
click node_crm_data "https://github.com/24f2001293/universal-data-connector/blob/main/data/customers.json"
click node_support_data "https://github.com/24f2001293/universal-data-connector/blob/main/data/support_tickets.json"
click node_analytics_data "https://github.com/24f2001293/universal-data-connector/blob/main/data/analytics.json"
click node_openapi "https://github.com/24f2001293/universal-data-connector/blob/main/openapi_schema.json"
click node_demo_agent "https://github.com/24f2001293/universal-data-connector/blob/main/demo-llm-intergrator.py"
click node_dockerfile "https://github.com/24f2001293/universal-data-connector/tree/main/Dockerfile"
click node_compose "https://github.com/24f2001293/universal-data-connector/blob/main/docker-compose.yml"
click node_tests_api "https://github.com/24f2001293/universal-data-connector/blob/main/tests/test_api.py"
click node_tests_rules "https://github.com/24f2001293/universal-data-connector/blob/main/tests/test_business_rules.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_router_data,node_router_health,node_models_common,node_svc_identifier,node_svc_rules,node_svc_voice,node_conn_base,node_conn_crm,node_conn_support,node_conn_analytics,node_config,node_logging toneBlue
class node_crm_data,node_support_data,node_analytics_data toneAmber
class node_openapi,node_demo_agent,node_dockerfile,node_compose toneMint
class node_tests_api,node_tests_rules toneRose
```

## Components

### Application

FastAPI service runtime and internal layers

- [Main app](https://github.com/24f2001293/universal-data-connector/blob/main/app/main.py): fastapi bootstrap · Application entrypoint that wires routers, config, and runtime setup · `app/main.py`
- [Data API](https://github.com/24f2001293/universal-data-connector/blob/main/app/routers/data.py): http router · Primary query endpoint surface · `app/routers/data.py`
- [Health API](https://github.com/24f2001293/universal-data-connector/blob/main/app/routers/health.py): http router · Operational liveness and readiness checks · `app/routers/health.py`
- [Models](https://github.com/24f2001293/universal-data-connector/blob/main/app/models/common.py): pydantic schemas · Typed request and response shapes for the public API · `app/models/common.py`
- [Domain ID](https://github.com/24f2001293/universal-data-connector/blob/main/app/services/data_identifier.py): routing service · Maps user intent to the right data domain or connector · `app/services/data_identifier.py`
- [Rules](https://github.com/24f2001293/universal-data-connector/blob/main/app/services/business_rules.py): business logic · Applies request constraints and domain-specific handling · `app/services/business_rules.py`
- [Voice UX](https://github.com/24f2001293/universal-data-connector/blob/main/app/services/voice_optimizer.py): response optimizer · Condenses results for low-bandwidth, speech-friendly responses · `app/services/voice_optimizer.py`
- [Connector base](https://github.com/24f2001293/universal-data-connector/blob/main/app/connectors/base.py): adapter interface · Shared connector contract for source-specific access · `app/connectors/base.py`
- [CRM connector](https://github.com/24f2001293/universal-data-connector/blob/main/app/connectors/crm_connector.py): source adapter · Retrieves and normalizes customer data · `app/connectors/crm_connector.py`
- [Support connector](https://github.com/24f2001293/universal-data-connector/blob/main/app/connectors/support_connector.py): source adapter · Retrieves and normalizes support ticket data · `app/connectors/support_connector.py`
- [Analytics connector](https://github.com/24f2001293/universal-data-connector/blob/main/app/connectors/analytics_connector.py): source adapter · Retrieves and normalizes analytics data · `app/connectors/analytics_connector.py`
- [Config](https://github.com/24f2001293/universal-data-connector/blob/main/app/config.py): settings · Environment-driven application settings · `app/config.py`
- [Logging](https://github.com/24f2001293/universal-data-connector/blob/main/app/utils/logging.py): observability · Structured logging utilities for request tracing · `app/utils/logging.py`

### Data Layer

Local JSON-backed source data used by connectors

- [Customers](https://github.com/24f2001293/universal-data-connector/blob/main/data/customers.json): json dataset · Local customer data used by the CRM connector · `data/customers.json`
- [Tickets](https://github.com/24f2001293/universal-data-connector/blob/main/data/support_tickets.json): json dataset · Local support ticket data used by the support connector · `data/support_tickets.json`
- [Analytics](https://github.com/24f2001293/universal-data-connector/blob/main/data/analytics.json): json dataset · Local analytics data used by the analytics connector · `data/analytics.json`

### Delivery

Deployment, schema, and integration artifacts

- [OpenAPI](https://github.com/24f2001293/universal-data-connector/blob/main/openapi_schema.json): api contract · Generated schema for tool calling and client integration · `openapi_schema.json`
- [Demo agent](https://github.com/24f2001293/universal-data-connector/blob/main/demo-llm-intergrator.py): integration script · Example LLM client loop using the service contract · `demo-llm-intergrator.py`
- [Dockerfile](https://github.com/24f2001293/universal-data-connector/tree/main/Dockerfile): container build · Container image definition for the service · `Dockerfile`
- [Compose](https://github.com/24f2001293/universal-data-connector/blob/main/docker-compose.yml): deployment spec · Local container orchestration definition · `docker-compose.yml`

### Tests

API and business-rule validation

- [API tests](https://github.com/24f2001293/universal-data-connector/blob/main/tests/test_api.py): test suite · Validates HTTP contract and endpoint behavior · `tests/test_api.py`
- [Rule tests](https://github.com/24f2001293/universal-data-connector/blob/main/tests/test_business_rules.py): test suite · Validates business-rule behavior and constraints · `tests/test_business_rules.py`

## Connections

- 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
