# tactspace/complimo architecture

> Architecture diagram of the GitHub repository tactspace/complimo, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tactspace/complimo
- Repository: https://github.com/tactspace/complimo

## Overview

##### Main Components
- Frontend Component:
- Next.js application.
- Sub-components: Chat (ChatInterface, ComplianceList, FileUpload), Navigation (Navbar), and data visualization.
- React & TypeScript usage.

- Backend Component:
- Integration points with external libraries like LangChain and OpenAI.
- Dependencies on Poppler-utils for PDF processing.
- Data ingestion elements such as the CSV file with data points.

- Infrastructure:
- Dockerized environments for both frontend and backend (Dockerfiles in each directory).
- Docker Compose orchestrator (docker-compose.yml) that ties the services together.
- Environment variables configuration (e.g., API keys and URLs in .env files).

- External Services / Dependencies:
- OpenAI API: For AI functionalities.
- ChromaDB: As the vector store for handling document and compliance data.
- Optional: Any external monitoring or logging services (if applicable; but primarily focus on the documented ones).

##### Relationships and Interactions
- Bidirectional data flow between the frontend and backend.
- How the frontend makes API requests to the backend, with endpoints exposed by FastAPI.
- A data path for document uploads leading to PDF processing via Poppler-utils.
- Docker infrastructure: how the docker-compose setup launches both services and possibly links to other containers (if present).

##### Architectural Patterns and Design Principles
- Separation of concerns:
- Frontend for user interaction and rendering.
- Backend for business logic, AI integrations, and compliance checking.
- Use of containerization (Docker) to maintain isolated, scalable, and reproducible environments.
- Optionally, if there is any microservice-like boundary in the backend (for instance, if compliance checking is modular), you may note it.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        direction TB
        FE["Next.js Frontend (React + TypeScript)"]:::frontend
        subgraph "Chat Components"
            direction TB
            CI["Chat Interface"]:::chat
            CL["Compliance List"]:::chat
            FU["File Upload"]:::chat
        end
        NV["Navigation (Navbar)"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        direction TB
        BA["FastAPI Backend (Python)"]:::backend
        CC["Compliance Checker"]:::compliance
        DI["Data Ingestion (CSV)"]:::backend
        PD["PDF Processing (Poppler-utils)"]:::backend
    end

    %% External Services
    subgraph "External Services"
        direction TB
        OA["OpenAI API"]:::external
        CD["ChromaDB"]:::external
    end

    %% Docker Infrastructure
    subgraph "Docker Infrastructure"
        direction TB
        DCB["Docker Compose Orchestrator"]:::docker
        DFB["Docker - Frontend"]:::docker
        DDB["Docker - Backend"]:::docker
    end

    %% Relationships
    FE -->|"APIRequest"| BA
    BA -->|"ComplianceCheck"| CC
    BA -->|"DataIngestion"| DI
    BA -->|"PDFProcessing"| PD
    CC -->|"QueryResponseOpenAI"| OA
    CC -->|"VectorStorage"| CD
    DCB --> DFB
    DCB --> DDB
    DFB --> FE
    DDB --> BA

    %% Click Events
    click FE "https://github.com/tactspace/complimo/tree/main/frontend/"
    click CI "https://github.com/tactspace/complimo/blob/main/frontend/src/app/chat/ChatInterface.tsx"
    click CL "https://github.com/tactspace/complimo/blob/main/frontend/src/app/chat/ComplianceList.tsx"
    click FU "https://github.com/tactspace/complimo/blob/main/frontend/src/app/chat/FileUpload.tsx"
    click NV "https://github.com/tactspace/complimo/blob/main/frontend/src/app/Navbar.tsx"
    click BA "https://github.com/tactspace/complimo/blob/main/backend/main.py"
    click CC "https://github.com/tactspace/complimo/blob/main/backend/compliance_checker.py"
    click DI "https://github.com/tactspace/complimo/blob/main/backend/data_points.csv"
    click DFB "https://github.com/tactspace/complimo/tree/main/frontend/Dockerfile"
    click DDB "https://github.com/tactspace/complimo/tree/main/backend/Dockerfile"
    click DCB "https://github.com/tactspace/complimo/blob/main/docker-compose.yml"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef backend fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef external fill:#FFDAB9,stroke:#000,stroke-width:2px;
    classDef docker fill:#FFA500,stroke:#000,stroke-width:2px;
    classDef chat fill:#E0FFFF,stroke:#000,stroke-width:2px;
    classDef compliance fill:#98FB98,stroke:#000,stroke-width:2px;
```
