# guilherme-viana-ey/compliance-checker architecture

> Architecture diagram of the GitHub repository guilherme-viana-ey/compliance-checker, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/guilherme-viana-ey/compliance-checker
- Repository: https://github.com/guilherme-viana-ey/compliance-checker

## Overview

Compliance Checker automatically evaluates Brazilian financial investment recommendations against ANBIMA/CVM guidance, returning a decision with cited sources. Its main workflow is document intake, profile/text extraction, retrieval and reranking of regulatory passages, grounded LLM analysis, then approval or referral for human review. It supports both HTTP analysis and autonomous batch/watch processing, with file routing, alerts, execution logs, and automation metrics. The map combines README-described capabilities with shown source relationships; ingestion-to-retrieval storage wiring and some runtime details are documented but not fully sampled.

Main entry points: [`projects/compliance-checker/src/main.py`](https://github.com/guilherme-viana-ey/compliance-checker/blob/main/projects/compliance-checker/src/main.py) (FastAPI Entry), [`projects/compliance-checker/src/agents/tools.py`](https://github.com/guilherme-viana-ey/compliance-checker/blob/main/projects/compliance-checker/src/agents/tools.py) (Document Tools), [`projects/compliance-checker/src/services/compliance_service.py`](https://github.com/guilherme-viana-ey/compliance-checker/blob/main/projects/compliance-checker/src/services/compliance_service.py) (Analysis Orchestrator), [`projects/compliance-checker/src/agents/compliance_agent.py`](https://github.com/guilherme-viana-ey/compliance-checker/blob/main/projects/compliance-checker/src/agents/compliance_agent.py) (Decision Workflow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and Contracts"]
  node_api_entry["FastAPI Entry<br/>[main.py]"]
  node_contracts["Analysis Schemas<br/>[schemas.py]"]
end

subgraph group_rag["Regulatory Knowledge"]
  node_knowledge["Regulatory Documents"]
  node_ingestion["Document Ingestion<br/>[ingestion.py]"]
  node_vector_store[("ChromaDB Index<br/>[retrieval.py]")]
  node_retrieval["Retrieve and Rerank<br/>[retrieval.py]"]
end

subgraph group_analysis["Compliance Analysis"]
  node_analysis_service["Analysis Orchestrator"]
  node_llm["Azure OpenAI Client<br/>[llm_client.py]"]
end

subgraph group_agent["Autonomous Processing"]
  node_input_files["Incoming Recommendations"]
  node_watcher["File Watcher<br/>[watcher.py]"]
  node_runner["Batch and Watch Runner<br/>[runner.py]"]
  node_agent_graph["Decision Workflow"]
  node_tools["Document Tools<br/>[tools.py]"]
  node_approved["Approved Documents"]
  node_review["Review Queue"]
end

subgraph group_ops["Audit and Metrics"]
  node_logs[("Execution and Alert Logs")]
  node_observability["Tracing and Metrics<br/>[observability.py]"]
end

node_user(("API Client"))
node_operator(("Compliance Operator"))
node_prometheus(("Prometheus Scraper"))

node_user -->|"submits analysis"| node_api_entry
node_api_entry -->|"validates payload"| node_contracts
node_api_entry -->|"invokes analysis"| node_analysis_service
node_analysis_service -->|"retrieves passages"| node_retrieval
node_retrieval -->|"queries index"| node_vector_store
node_ingestion -->|"writes chunks"| node_vector_store
node_knowledge -->|"provides documents"| node_ingestion
node_analysis_service -->|"requests analysis"| node_llm
node_analysis_service -->|"returns result"| node_contracts
node_operator -->|"places files"| node_input_files
node_input_files -->|"triggers on arrival"| node_watcher
node_runner -->|"runs batch"| node_agent_graph
node_runner -->|"starts watch mode"| node_watcher
node_watcher -->|"runs workflow"| node_agent_graph
node_api_entry -->|"processes uploaded file"| node_agent_graph
node_agent_graph -->|"uses tools"| node_tools
node_tools -->|"analyzes recommendation"| node_analysis_service
node_tools -->|"moves approved file"| node_approved
node_tools -->|"moves rejected file"| node_review
node_tools -->|"records alerts"| node_logs
node_agent_graph -->|"writes execution logs"| node_logs
node_api_entry -->|"records metrics"| node_observability
node_prometheus -->|"scrapes metrics"| node_api_entry

click node_api_entry "https://github.com/guilherme-viana-ey/compliance-checker/blob/main/projects/compliance-checker/src/main.py"
click node_contracts "https://github.com/guilherme-viana-ey/compliance-checker/blob/main/projects/compliance-checker/src/api/schemas.py"
click node_knowledge "https://github.com/guilherme-viana-ey/compliance-checker/tree/main/projects/compliance-checker/knowledge_base"
click node_ingestion "https://github.com/guilherme-viana-ey/compliance-checker/blob/main/projects/compliance-checker/src/rag/ingestion.py"
click node_vector_store "https://github.com/guilherme-viana-ey/compliance-checker/blob/main/projects/compliance-checker/src/rag/retrieval.py"
click node_retrieval "https://github.com/guilherme-viana-ey/compliance-checker/blob/main/projects/compliance-checker/src/rag/retrieval.py"
click node_analysis_service "https://github.com/guilherme-viana-ey/compliance-checker/blob/main/projects/compliance-checker/src/services/compliance_service.py"
click node_llm "https://github.com/guilherme-viana-ey/compliance-checker/blob/main/projects/compliance-checker/src/core/llm_client.py"
click node_input_files "https://github.com/guilherme-viana-ey/compliance-checker/tree/main/projects/compliance-checker/data/input"
click node_watcher "https://github.com/guilherme-viana-ey/compliance-checker/blob/main/projects/compliance-checker/src/agents/watcher.py"
click node_runner "https://github.com/guilherme-viana-ey/compliance-checker/blob/main/projects/compliance-checker/src/agents/runner.py"
click node_agent_graph "https://github.com/guilherme-viana-ey/compliance-checker/blob/main/projects/compliance-checker/src/agents/compliance_agent.py"
click node_tools "https://github.com/guilherme-viana-ey/compliance-checker/blob/main/projects/compliance-checker/src/agents/tools.py"
click node_approved "https://github.com/guilherme-viana-ey/compliance-checker/tree/main/projects/compliance-checker/data/output/approved"
click node_review "https://github.com/guilherme-viana-ey/compliance-checker/tree/main/projects/compliance-checker/data/output/rejected_for_review"
click node_logs "https://github.com/guilherme-viana-ey/compliance-checker/tree/main/projects/compliance-checker/data/logs"
click node_observability "https://github.com/guilherme-viana-ey/compliance-checker/blob/main/projects/compliance-checker/src/agents/observability.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_api_entry,node_contracts,node_user toneBlue
class node_knowledge,node_ingestion,node_vector_store,node_retrieval toneAmber
class node_analysis_service,node_llm toneMint
class node_input_files,node_watcher,node_runner,node_agent_graph,node_tools,node_approved,node_review toneRose
class node_logs,node_observability,node_operator,node_prometheus toneIndigo
```

## Components

### API and Contracts

- [FastAPI Entry](https://github.com/guilherme-viana-ey/compliance-checker/blob/main/projects/compliance-checker/src/main.py): `projects/compliance-checker/src/main.py`
- [Analysis Schemas](https://github.com/guilherme-viana-ey/compliance-checker/blob/main/projects/compliance-checker/src/api/schemas.py): `projects/compliance-checker/src/api/schemas.py`

### Regulatory Knowledge

- [Regulatory Documents](https://github.com/guilherme-viana-ey/compliance-checker/tree/main/projects/compliance-checker/knowledge_base): `projects/compliance-checker/knowledge_base`
- [Document Ingestion](https://github.com/guilherme-viana-ey/compliance-checker/blob/main/projects/compliance-checker/src/rag/ingestion.py): `projects/compliance-checker/src/rag/ingestion.py`
- [ChromaDB Index](https://github.com/guilherme-viana-ey/compliance-checker/blob/main/projects/compliance-checker/src/rag/retrieval.py): `projects/compliance-checker/src/rag/retrieval.py`
- [Retrieve and Rerank](https://github.com/guilherme-viana-ey/compliance-checker/blob/main/projects/compliance-checker/src/rag/retrieval.py): `projects/compliance-checker/src/rag/retrieval.py`

### Compliance Analysis

- [Analysis Orchestrator](https://github.com/guilherme-viana-ey/compliance-checker/blob/main/projects/compliance-checker/src/services/compliance_service.py): `projects/compliance-checker/src/services/compliance_service.py`
- [Azure OpenAI Client](https://github.com/guilherme-viana-ey/compliance-checker/blob/main/projects/compliance-checker/src/core/llm_client.py): `projects/compliance-checker/src/core/llm_client.py`

### Autonomous Processing

- [Incoming Recommendations](https://github.com/guilherme-viana-ey/compliance-checker/tree/main/projects/compliance-checker/data/input): `projects/compliance-checker/data/input`
- [File Watcher](https://github.com/guilherme-viana-ey/compliance-checker/blob/main/projects/compliance-checker/src/agents/watcher.py): `projects/compliance-checker/src/agents/watcher.py`
- [Batch and Watch Runner](https://github.com/guilherme-viana-ey/compliance-checker/blob/main/projects/compliance-checker/src/agents/runner.py): `projects/compliance-checker/src/agents/runner.py`
- [Decision Workflow](https://github.com/guilherme-viana-ey/compliance-checker/blob/main/projects/compliance-checker/src/agents/compliance_agent.py): `projects/compliance-checker/src/agents/compliance_agent.py`
- [Document Tools](https://github.com/guilherme-viana-ey/compliance-checker/blob/main/projects/compliance-checker/src/agents/tools.py): `projects/compliance-checker/src/agents/tools.py`
- [Approved Documents](https://github.com/guilherme-viana-ey/compliance-checker/tree/main/projects/compliance-checker/data/output/approved): `projects/compliance-checker/data/output/approved`
- [Review Queue](https://github.com/guilherme-viana-ey/compliance-checker/tree/main/projects/compliance-checker/data/output/rejected_for_review): `projects/compliance-checker/data/output/rejected_for_review`

### Audit and Metrics

- [Execution and Alert Logs](https://github.com/guilherme-viana-ey/compliance-checker/tree/main/projects/compliance-checker/data/logs): `projects/compliance-checker/data/logs`
- [Tracing and Metrics](https://github.com/guilherme-viana-ey/compliance-checker/blob/main/projects/compliance-checker/src/agents/observability.py): `projects/compliance-checker/src/agents/observability.py`

### Other components

- **API Client**
- **Compliance Operator**
- **Prometheus Scraper**

## Connections

- API Client → FastAPI Entry: submits analysis (evidence: `README.md`)
- FastAPI Entry → Analysis Schemas: validates payload (evidence: `projects/compliance-checker/src/main.py`)
- FastAPI Entry → Analysis Orchestrator: invokes analysis (evidence: `projects/compliance-checker/src/main.py`)
- Analysis Orchestrator → Retrieve and Rerank: retrieves passages (evidence: `projects/compliance-checker/src/services/compliance_service.py`)
- Retrieve and Rerank → ChromaDB Index: queries index (evidence: `README.md`)
- Document Ingestion → ChromaDB Index: writes chunks (evidence: `projects/compliance-checker/src/rag/ingestion.py`)
- Regulatory Documents → Document Ingestion: provides documents (evidence: `projects/compliance-checker/src/rag/ingestion.py`)
- Analysis Orchestrator → Azure OpenAI Client: requests analysis (evidence: `projects/compliance-checker/src/services/compliance_service.py`)
- Analysis Orchestrator → Analysis Schemas: returns result (evidence: `projects/compliance-checker/src/services/compliance_service.py`)
- Compliance Operator → Incoming Recommendations: places files (evidence: `README.md`)
- Incoming Recommendations → File Watcher: triggers on arrival (evidence: `projects/compliance-checker/src/agents/watcher.py`)
- Batch and Watch Runner → Decision Workflow: runs batch (evidence: `projects/compliance-checker/src/agents/runner.py`)
- Batch and Watch Runner → File Watcher: starts watch mode (evidence: `projects/compliance-checker/src/agents/runner.py`)
- File Watcher → Decision Workflow: runs workflow (evidence: `projects/compliance-checker/src/agents/watcher.py`)
- FastAPI Entry → Decision Workflow: processes uploaded file (evidence: `projects/compliance-checker/src/main.py`)
- Decision Workflow → Document Tools: uses tools (evidence: `projects/compliance-checker/src/agents/compliance_agent.py`)
- Document Tools → Analysis Orchestrator: analyzes recommendation (evidence: `projects/compliance-checker/src/agents/tools.py`)
- Document Tools → Approved Documents: moves approved file (evidence: `README.md`)
- Document Tools → Review Queue: moves rejected file (evidence: `README.md`)
- Document Tools → Execution and Alert Logs: records alerts (evidence: `README.md`)
- Decision Workflow → Execution and Alert Logs: writes execution logs (evidence: `README.md`)
- FastAPI Entry → Tracing and Metrics: records metrics (evidence: `projects/compliance-checker/src/main.py`)
- Prometheus Scraper → FastAPI Entry: scrapes metrics (evidence: `projects/compliance-checker/src/main.py`)
