# coutinho-ey/compliance-viewer architecture

> Architecture diagram of the GitHub repository coutinho-ey/compliance-viewer, 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/coutinho-ey/compliance-viewer
- Repository: https://github.com/coutinho-ey/compliance-viewer

## Overview

Compliance Viewer is a FastAPI service that accepts an investment recommendation and client risk profile, retrieves relevant regulatory material, and returns a structured compliance assessment. Its runtime path runs from the API through the compliance service, which coordinates retrieval and Azure OpenAI analysis. A separate ingestion capability extracts and chunks PDFs from the knowledge base for persistent vector storage. The README describes RAG as a future project, but the sampled ingestion and retrieval modules implement that capability. Relationships reflect shown calls and documented API behavior; no agent workflow is shown.

Main entry points: [`src/services/complience_service.py`](https://github.com/coutinho-ey/compliance-viewer/blob/main/src/services/complience_service.py) (Compliance Service), [`src/api/router.py`](https://github.com/coutinho-ey/compliance-viewer/blob/main/src/api/router.py) (API Routes), [`src/rag/ingestion.py`](https://github.com/coutinho-ey/compliance-viewer/blob/main/src/rag/ingestion.py) (PDF Ingestion), [`src/rag/retrieval.py`](https://github.com/coutinho-ey/compliance-viewer/blob/main/src/rag/retrieval.py) (Chunk Retrieval)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API"]
  node_app["FastAPI App<br/>[main.py]"]
  node_router["API Routes<br/>[router.py]"]
  node_schemas["Analysis Schemas<br/>[analysis.py]"]
end

subgraph group_analysis["Compliance Analysis"]
  node_service["Compliance Service"]
end

subgraph group_rag["Knowledge Retrieval"]
  node_ingestion["PDF Ingestion<br/>[ingestion.py]"]
  node_retrieval["Chunk Retrieval<br/>[retrieval.py]"]
  node_vectorstore[("ChromaDB Collection")]
end

subgraph group_sources["Knowledge Sources"]
  node_knowledge["Knowledge Base"]
end

node_client(("API Client"))
node_azure["Azure OpenAI"]

node_app -->|"mounts routes"| node_router
node_client -->|"submits analysis"| node_router
node_router -->|"accepts and returns"| node_schemas
node_router -->|"calls analysis"| node_service
node_service -->|"retrieves context"| node_retrieval
node_service -->|"requests assessment"| node_azure
node_service -->|"uses result model"| node_schemas
node_ingestion -->|"reads PDFs"| node_knowledge
node_ingestion -->|"stores chunks"| node_vectorstore
node_retrieval -->|"queries chunks"| node_vectorstore

click node_app "https://github.com/coutinho-ey/compliance-viewer/blob/main/src/main.py"
click node_router "https://github.com/coutinho-ey/compliance-viewer/blob/main/src/api/router.py"
click node_schemas "https://github.com/coutinho-ey/compliance-viewer/blob/main/src/api/schemas/analysis.py"
click node_service "https://github.com/coutinho-ey/compliance-viewer/blob/main/src/services/complience_service.py"
click node_ingestion "https://github.com/coutinho-ey/compliance-viewer/blob/main/src/rag/ingestion.py"
click node_retrieval "https://github.com/coutinho-ey/compliance-viewer/blob/main/src/rag/retrieval.py"
click node_knowledge "https://github.com/coutinho-ey/compliance-viewer/tree/main/knowledge_base"

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_app,node_router,node_schemas,node_client toneBlue
class node_service toneAmber
class node_ingestion,node_retrieval,node_vectorstore toneMint
class node_knowledge toneRose
class node_azure toneIndigo
```

## Components

### API

- [FastAPI App](https://github.com/coutinho-ey/compliance-viewer/blob/main/src/main.py): `src/main.py`
- [API Routes](https://github.com/coutinho-ey/compliance-viewer/blob/main/src/api/router.py): `src/api/router.py`
- [Analysis Schemas](https://github.com/coutinho-ey/compliance-viewer/blob/main/src/api/schemas/analysis.py): `src/api/schemas/analysis.py`

### Compliance Analysis

- [Compliance Service](https://github.com/coutinho-ey/compliance-viewer/blob/main/src/services/complience_service.py): `src/services/complience_service.py`

### Knowledge Retrieval

- [PDF Ingestion](https://github.com/coutinho-ey/compliance-viewer/blob/main/src/rag/ingestion.py): `src/rag/ingestion.py`
- [Chunk Retrieval](https://github.com/coutinho-ey/compliance-viewer/blob/main/src/rag/retrieval.py): `src/rag/retrieval.py`
- **ChromaDB Collection**

### Knowledge Sources

- [Knowledge Base](https://github.com/coutinho-ey/compliance-viewer/tree/main/knowledge_base): `knowledge_base`

### Other components

- **API Client**
- **Azure OpenAI**

## Connections

- FastAPI App → API Routes: mounts routes (evidence: `src/main.py`)
- API Client → API Routes: submits analysis (evidence: `README.md`)
- API Routes → Analysis Schemas: accepts and returns (evidence: `src/api/router.py`)
- API Routes → Compliance Service: calls analysis (evidence: `src/api/router.py`)
- Compliance Service → Chunk Retrieval: retrieves context (evidence: `src/services/complience_service.py`)
- Compliance Service → Azure OpenAI: requests assessment (evidence: `src/services/complience_service.py`)
- Compliance Service → Analysis Schemas: uses result model (evidence: `src/services/complience_service.py`)
- PDF Ingestion → Knowledge Base: reads PDFs (evidence: `src/rag/ingestion.py`)
- PDF Ingestion → ChromaDB Collection: stores chunks (evidence: `src/rag/ingestion.py`)
- Chunk Retrieval → ChromaDB Collection: queries chunks (evidence: `src/rag/retrieval.py`)
