# unoplat/unoplat-code-confluence architecture

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

- Interactive diagram: https://gitdiagram.com/unoplat/unoplat-code-confluence
- Repository: https://github.com/unoplat/unoplat-code-confluence

## Overview

##### Project Type and Purpose
- This is a multi-module, full-stack, code intelligence and context-extraction engine.
- Its goal is to “extract, understand, and provide precise code context” across multiple repositories using techniques such as deterministic code grammar (via ArchGuard and Tree-sitter) and graph-based semantic models.
- The project supports deep language analysis (Python, Java, etc.), dependency parsing, and even embedding-based semantic search.

##### Main Components (as seen in the file tree)
- Documentation & Website Module:
- “code-confluence” directory contains Docusaurus configuration, docs, sidebars, and website content for the technical documentation and quick-start guides.
- Frontend Application:
- “unoplat-code-confluence-frontend” is a React/TypeScript-based UI (with pages like HomePage, OnboardingPage, etc.) meant for user interaction and visualization.
- CLI/Command-Line Tool:
- “unoplat-code-confluence-cli” provides a command-line interface (with configuration settings and API connectors) for driving tasks or integration into CI/CD pipelines.
- Commons Library:
- “unoplat-code-confluence-commons” encapsulates shared modules (e.g., graph models, changelogs, and common tasks) that are used across ingestion and CLI tools.
- Ingestion and Processing Service:
- “unoplat-code-confluence-ingestion” is the heavy-duty module performing the core work:
▪ It contains various subpackages under “code-confluence-flow-bridge” which include:
– Parsers (for Python, package manager metadata, linters, Tree-sitter based parsing, etc.),
– Processors (handling orchestration for codebase processing, dependency resolution, and graph database integration),
– Connectors (for GitHub and other external APIs),
– Logging and configuration, etc.
- This service is the engine that parses repositories, builds the underlying code graph, and then likely persists it (possibly interfacing with an external graph database).

##### Relationships and Data Flow
- External Code Repositories & Sources (like GitHub) → Ingestion Service:
- The ingestion service (inside “unoplat-code-confluence-ingestion”) pulls in data (triggered perhaps using GitHub connectors and API clients).
- Data Parsing and Processing:
- Parsed code (using multiple parser strategies and linters) feeds into a graph construction process using shared models from the commons.
- There’s a clear pipeline where “connectors” supply data, “parsers” extract structure, and “processors” apply further business logic (e.g., dependency resolution, summarization, or embedding generation).
- Data Storage & Graph Database:
- Consumption by Frontend and API layers:
- The frontend (React app) likely communicates with backend API endpoints (which might be provided via FastAPI within the ingestion module or a separate API module).
- The CLI tool offers an alternative interface for operations and possibly for triggering ingestion/processing tasks.

##### Architectural Patterns and Technologies
- Modular Architecture:
- The project uses clear separations of concerns. Each module (documentation, frontend, CLI, ingestion, and commons) is maintained as an independent unit.
- Microservice-Like Segmentation:
- The ingestion service’s separation from the frontend and CLI mimics microservices. They interact via APIs, configuration files, and shared libraries.
- Use of Containers & Deployment Scripts:
- Docker Compose files (local-docker-compose.yml, prod-docker-compose.yml) indicate containerized deployment for local development and production.
- CI/CD Integration:
- .github workflows for various builds and deployments emphasize automation around tests, releases, and documentation builds.
- Technology Stack:
- Frontend: React, TypeScript, Vite, Tailwind CSS.
- Ingestion & CLI: Python-based modules using FastAPI (implied from typical patterns and the presence of pyproject.toml, mypy, ruff, etc.), Tree-sitter for parsing, and graph models.
- Documentation: Docusaurus for the static website.

##### Elements
- Clear Labels for Each Component:
- API calls between the frontend and backend services.

## Diagram (Mermaid)

```mermaid
graph TD
    %% External Source
    A["External Repositories (e.g., GitHub)"]:::external

    %% Ingestion Service Subgraph
    subgraph "Ingestion Service (Code Parser & Processor)"
        direction TB
        B["Connector (GitHub API)"]:::ingestion
        C["Parser (Tree-sitter & Language Parsers)"]:::ingestion
        D["Processor (Graph Modeling & Dependency Analysis)"]:::ingestion
        E["Graph Database Integration"]:::storage
    end

    %% Other Modules
    F["Commons Library"]:::commons
    G["Frontend Application"]:::frontend
    H["CLI Tool"]:::cli
    I["Documentation & Website Module"]:::docs

    %% Data Flow Connections
    A -->|"pulls_code"| B
    B -->|"supplies_data"| C
    C -->|"extracts_structure"| D
    D -->|"stores_graph"| E

    %% Commons Integration with Ingestion and CLI
    F -.-> D
    F -.-> H

    %% API Communication from Ingestion to Frontend
    G -->|"consumes_API"| D

    %% CLI triggering Ingestion Tasks
    H -->|"triggers_processing"| D

    %% Documentation references (informational)
    I -.-> G
    I -.-> H

    %% Styles
    classDef external fill:#fcebbd,stroke:#f9a825,stroke-width:2px;
    classDef ingestion fill:#bbdefb,stroke:#0d47a1,stroke-width:2px;
    classDef storage fill:#c8e6c9,stroke:#388e3c,stroke-width:2px;
    classDef frontend fill:#ffcc80,stroke:#ef6c00,stroke-width:2px;
    classDef cli fill:#d1c4e9,stroke:#5e35b1,stroke-width:2px;
    classDef docs fill:#ffe082,stroke:#ff9800,stroke-width:2px;
    classDef commons fill:#f8bbd0,stroke:#d81b60,stroke-width:2px;

    %% Click Events for Component Mappings
    click I "https://github.com/unoplat/unoplat-code-confluence/tree/main/code-confluence"
    click G "https://github.com/unoplat/unoplat-code-confluence/tree/main/unoplat-code-confluence-frontend"
    click H "https://github.com/unoplat/unoplat-code-confluence/tree/main/unoplat-code-confluence-cli"
    click F "https://github.com/unoplat/unoplat-code-confluence/tree/main/unoplat-code-confluence-commons"
    click B "https://github.com/unoplat/unoplat-code-confluence/tree/main/unoplat-code-confluence-ingestion/code-confluence-flow-bridge"
    click E "https://github.com/unoplat/unoplat-code-confluence/tree/main/unoplat-code-confluence-ingestion/code-confluence-flow-bridge/src/code_confluence_flow_bridge/processor/db/graph_db"
```
