# reltadev/github-assistant architecture

> Architecture diagram of the GitHub repository reltadev/github-assistant, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/reltadev/github-assistant
- Repository: https://github.com/reltadev/github-assistant

## Overview

##### Main Components Identification

a) Frontend Layer (client-poc):
- Next.js application
- React components
- UI components (shadcn/ui)
- Flow visualization components
- API routes

b) Backend Layer (server-poc):
- FastAPI server
- Data pipelines
- Semantic layer
- Models

c) External Services:
- GitHub API
- OpenAI API
- PostgreSQL Database

**┌─ Client Layer ─────────────────────┐**
- Next.js + React                    │
- ┌─────────────┐    ┌────────────┐ │
- UI/Flow   │    │  API Routes│ │
- ┘    └────────────┘ │
- ┬────────────┬───────┘

**┌───────────────▼────────────▼───────┐**
- Server Layer                       │
- ┌─────────────┐    ┌────────────┐ │
- FastAPI Server│    │   Relta    │ │
- ┘    └────────────┘ │
- ┌─────────────┐    ┌────────────┐ │
- Data Pipeline│    │  Semantic  │ │
- (DLT)     │    │   Layer    │ │
- ┘    └────────────┘ │
- ┬────────────┬──────────┘

**┌───────────▼─┐  ┌──────▼───────┐**
- GitHub API │  │ PostgreSQL DB │
- ┘  └──────────────┘

##### Important Flows to Highlight

a) Data Ingestion Flow:
- GitHub API → Data Pipeline → PostgreSQL
- How the DLT pipeline processes GitHub data

b) Query Flow:
- Frontend → API Routes → FastAPI Server → Relta → Semantic Layer → PostgreSQL
- OpenAI integration for natural language processing

##### Key Architectural Patterns to Emphasize

- Client-Server architecture
- API-first design
- ETL pipeline pattern
- Semantic layer abstraction
- Microservices-like separation of concerns

##### Infrastructure Components

AWS infrastructure components from the infra directory:
- ECS (Elastic Container Service)
- RDS (Relational Database Service)
- Networking components

##### Additional Details

- Authentication flow (SSO callback)
- Environment configurations
- Component dependencies
- Deployment boundaries

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        FE[Next.js + React]:::frontend
        UI[UI Components]:::frontend
        Flow[Flow Visualization]:::frontend
        APIRoutes["API Routes"]:::frontend
        Assistant[Assistant UI]:::frontend
        Auth[SSO Authentication]:::frontend
        
        FE --> UI
        FE --> Flow
        FE --> APIRoutes
        FE --> Assistant
        FE --> Auth
    end

    subgraph Server
        FastAPI[FastAPI Server]:::backend
        Relta[Relta Engine]:::backend
        Pipeline[Data Pipeline]:::backend
        Semantic[Semantic Layer]:::backend
        Models[Backend Models]:::backend
    end

    subgraph Infrastructure
        ECS[ECS Service]:::infra
        RDS[RDS Instance]:::infra
        Network[Network Components]:::infra
        
        ECS --> RDS
        ECS --> Network
    end

    subgraph External
        GitHub[GitHub API]:::external
        OpenAI[OpenAI API]:::external
        PostgreSQL[(PostgreSQL DB)]:::database
    end

    APIRoutes --> FastAPI
    FastAPI --> Relta
    Relta --> Semantic
    Semantic --> PostgreSQL
    Pipeline --> PostgreSQL
    Pipeline --> GitHub
    FastAPI --> OpenAI
    Models --> PostgreSQL

    %% Click events for component mapping
    click FE "https://github.com/reltadev/github-assistant/tree/main/client-poc/app"
    click UI "https://github.com/reltadev/github-assistant/tree/main/client-poc/components/ui"
    click Flow "https://github.com/reltadev/github-assistant/tree/main/client-poc/components/flow"
    click APIRoutes "https://github.com/reltadev/github-assistant/tree/main/client-poc/app/api"
    click FastAPI "https://github.com/reltadev/github-assistant/blob/main/server-poc/server_poc/server.py"
    click Pipeline "https://github.com/reltadev/github-assistant/blob/main/server-poc/data_pipelines/github_pipeline.py"
    click Semantic "https://github.com/reltadev/github-assistant/tree/main/server-poc/semantic_layer"
    click Models "https://github.com/reltadev/github-assistant/tree/main/server-poc/server_poc/models"
    click ECS "https://github.com/reltadev/github-assistant/tree/main/server-poc/infra/app/ecs"
    click RDS "https://github.com/reltadev/github-assistant/tree/main/server-poc/infra/app/rds"
    click Network "https://github.com/reltadev/github-assistant/tree/main/server-poc/infra/app/network"
    click GitHub "https://github.com/reltadev/github-assistant/tree/main/server-poc/data_pipelines/github"
    click Assistant "https://github.com/reltadev/github-assistant/blob/main/client-poc/components/MyAssistant.tsx"
    click PostgreSQL "https://github.com/reltadev/github-assistant/blob/main/server-poc/server_poc/models/githubrepoinfo.py"
    click Auth "https://github.com/reltadev/github-assistant/blob/main/client-poc/app/sso-callback/page.tsx"

    %% Styling
    classDef frontend fill:#2196F3,stroke:#1565C0,color:white
    classDef backend fill:#4CAF50,stroke:#2E7D32,color:white
    classDef infra fill:#FF9800,stroke:#EF6C00,color:white
    classDef external fill:#9C27B0,stroke:#6A1B9A,color:white
    classDef database fill:#795548,stroke:#4E342E,color:white

    %% Legend
    subgraph Legend
        Frontend[Frontend]:::frontend
        Backend[Backend]:::backend
        Infrastructure[Infrastructure]:::infra
        ExternalService[External Service]:::external
        DB[(Database)]:::database
    end
```
