# ayash-bera/inkei architecture

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

- Interactive diagram: https://gitdiagram.com/ayash-bera/inkei
- Repository: https://github.com/ayash-bera/inkei

## Overview

##### Project type and purpose
- Zenith is a full-stack SaaS platform with a React/Vite frontend, a Node/Express backend, a MongoDB database, and a Python-based AI microservice.
- It integrates AI throughout the Secure Software Development Life Cycle by providing features such as GitHub PR review bot, real-time chat, AI‐powered sprint planning, document upload and analysis.

##### File structure
- Top level:
- Dockerfile, nginx.config, documentation.html, README.md
- AIModels/… (Python AI microservice using Streamlit, with components for file handling, model selection, QA chain, image/text parsing)
- backend/… (Node.js/Express REST & WebSocket server, MongoDB models, auth routes, DB manager util)
- src/, public/, index.html, vite.config.js, tailwind.config.js (React/Vite single-page-app)
- .github/workflows/docker_publish.yml (CI/CD for Docker publishing)
- Patterns:
- Microservice boundaries between frontend, backend, AIModels
- MVC-style backend (routes, models, utils)
- Component-driven React UI
- Deployment artifacts: Dockerfile, nginx.config, vercel.json

##### Readme insights
- Core features: GitHub Bot, real-time chat (WebSocket), AI Dashboard (upload & analyze docs), Delta Branch Detection, AI Canvas.
- Tech stack: React, Node/Express, MongoDB, Python (AI).

##### Main components and their interactions
a. Client browser (React SPA)
b. Frontend hosting (Vercel or Nginx + Docker) serving static assets
c. Backend API & WebSocket service (Express + Node.js)
d. MongoDB cluster(s) (MONGO_URI, various role-based DB URIs)
e. Python AI microservice (Streamlit app on port 8501 or wrapped as internal service)
f. External integrations: GitHub API

Data flows:
- User interacts with SPA → HTTP REST calls to Express (login, signup, fetch dashboards)
- SPA establishes WebSocket with backend for real-time chat
- For AI features (upload doc, analyze tasks) → HTTP POST from frontend or backend to Python AI service → returns analysis results → SPA renders on dashboard
- Backend triggers GitHubHandler to call GitHub API for PR reviews → results pushed back to SPA or stored in DB
- All state persisted in MongoDB

##### Architectural patterns & design principles
- Separation of concerns: UI layer (React), API layer (Express), AI logic (Python)
- Microservice style for AIModels, allows independent scaling & deployment
- MVC-inspired backend (routes → controllers → utils/dbManager → models)
- Component-driven UI with layout, sections, dashboard modules
- Streamlit used as a quick UI for AI features in dev; can be containerized
- CI/CD flows via GitHub Actions and Docker

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    subgraph "Client Layer"
        Browser["User Browser"]:::ui
    end

    %% Frontend Layer
    subgraph "Frontend (React SPA)"
        direction TB
        Vite["Vite Config"]:::ui
        Public["public/index.html"]:::ui
        Tailwind["tailwind.config.js"]:::ui

        subgraph "Source Code"
            direction TB
            Main["src/main.jsx"]:::ui
            App["src/App.jsx"]:::ui

            subgraph "Pages"
                Home["Home.jsx"]:::ui
                Login["Login.jsx"]:::ui
                SignUp["SignUp.jsx"]:::ui
                DashboardPage["Dashboard.jsx"]:::ui
                Teams["Teams.jsx"]:::ui
            end

            subgraph "UI Components"
                direction TB
                LayoutDir["layout/"]:::ui
                DashboardLayout["DashboardLayout.jsx"]:::ui
                Header["Header.jsx"]:::ui
                Footer["Footer.jsx"]:::ui

                DashboardCompDir["dashboard/"]:::ui
                ApiEndpoints["ApiEndpoints.jsx"]:::ui
                DocumentList["DocumentList.jsx"]:::ui
                DocumentUploader["DocumentUploaderModal.jsx"]:::ui
                GitHubModal["GitHubRepoModal.jsx"]:::ui
                RepositoryList["RepositoryList.jsx"]:::ui
                SprintDashboard["SprintDashboard.jsx"]:::ui
                WelcomeCard["WelcomeCard.jsx"]:::ui

                SectionsDir["sections/"]:::ui
                UIkitDir["ui/"]:::ui
            end

            Utils["src/lib/utils.js"]:::ui
        end
    end

    %% Backend Layer
    subgraph "Backend (Node/Express)" 
        direction TB
        Server["server.js"]:::core
        AuthRoutes["routes/auth.js"]:::core
        UserModel["models/userModel.js"]:::core
        DBManager["utils/dbManager.js"]:::core
    end

    %% AI Microservice Layer
    subgraph "AI Microservice (Python)"
        direction TB
        MainPy["AIModels/main.py"]:::core
        StreamlitApp["AIModels/app.py"]:::core

        subgraph "AI Components"
            direction TB
            ChatInterface["chat_interface.py"]:::core
            FileHandler["file_handler.py"]:::core
            ModelSelector["model_selector.py"]:::core
            QAChain["qa_chain.py"]:::core
            TextParser["text_parser.py"]:::core
            ImageParser["image_parser.py"]:::core
            GitHubHandler["github_handler.py"]:::core
        end

        subgraph "Data & Prompts"
            DataDir["data/uploaded_data/"]:::core
            Prompts["prompts/task_analysis.py"]:::core
        end
    end

    %% Database
    subgraph "Database (MongoDB)"
        MongoDB["MongoDB Cluster"]:::data
    end

    %% External Integrations
    subgraph "External Services"
        GitHubAPI["GitHub API"]:::external
    end

    %% Deployment Artifacts
    subgraph "Deployment Configs"
        Dockerfile["Dockerfile"]:::external
        Nginx["nginx.config"]:::external
        Vercel["vercel.json"]:::external
        Docs["documentation.html"]:::external
        Readme["README.md"]:::external
        CI[".github/workflows/docker_publish.yml"]:::external
    end

    %% Connections
    Browser -->|"HTTP 5173"| Vite
    Browser -->|loads HTML| Public
    Vite -->|bundles| Main
    Main -->|renders| App
    App -->|navigates| Home
    App -->|navigates| Login
    App -->|navigates| SignUp
    App -->|navigates| DashboardPage
    App -->|navigates| Teams
    App -->|uses| DashboardLayout
    App -->|uses| Header
    App -->|uses| Footer
    App -->|uses| Utils

    App -->|"REST HTTPS"| Server
    App -->|"WebSocket 3000"| Server
    App -->|"AI HTTP 8501"| StreamlitApp

    Server -->|"MongoDB Driver"| MongoDB
    Server -->|"HTTP 8501"| StreamlitApp
    Server -->|"HTTPS"| GitHubAPI

    StreamlitApp -->|uses| FileHandler
    StreamlitApp -->|uses| ModelSelector
    StreamlitApp -->|uses| QAChain
    StreamlitApp -->|uses| TextParser
    StreamlitApp -->|uses| ImageParser
    StreamlitApp -->|uses| GitHubHandler
    StreamlitApp -->|stores/reads| DataDir
    StreamlitApp -->|reads| Prompts

    %% Click Events
    click Main "https://github.com/ayash-bera/inkei/blob/main/src/main.jsx"
    click App "https://github.com/ayash-bera/inkei/blob/main/src/App.jsx"
    click Home "https://github.com/ayash-bera/inkei/blob/main/src/pages/Home.jsx"
    click Login "https://github.com/ayash-bera/inkei/blob/main/src/pages/Login.jsx"
    click SignUp "https://github.com/ayash-bera/inkei/blob/main/src/pages/SignUp.jsx"
    click DashboardPage "https://github.com/ayash-bera/inkei/blob/main/src/pages/Dashboard.jsx"
    click Teams "https://github.com/ayash-bera/inkei/blob/main/src/pages/Teams.jsx"
    click LayoutDir "https://github.com/ayash-bera/inkei/tree/main/src/components/layout/"
    click DashboardLayout "https://github.com/ayash-bera/inkei/blob/main/src/components/layout/DashboardLayout.jsx"
    click Header "https://github.com/ayash-bera/inkei/blob/main/src/components/layout/Header.jsx"
    click Footer "https://github.com/ayash-bera/inkei/blob/main/src/components/layout/Footer.jsx"
    click DashboardCompDir "https://github.com/ayash-bera/inkei/tree/main/src/components/dashboard/"
    click ApiEndpoints "https://github.com/ayash-bera/inkei/blob/main/src/components/dashboard/ApiEndpoints.jsx"
    click DocumentList "https://github.com/ayash-bera/inkei/blob/main/src/components/dashboard/DocumentList.jsx"
    click DocumentUploader "https://github.com/ayash-bera/inkei/blob/main/src/components/dashboard/DocumentUploaderModal.jsx"
    click GitHubModal "https://github.com/ayash-bera/inkei/blob/main/src/components/dashboard/GitHubRepoModal.jsx"
    click RepositoryList "https://github.com/ayash-bera/inkei/blob/main/src/components/dashboard/RepositoryList.jsx"
    click SprintDashboard "https://github.com/ayash-bera/inkei/blob/main/src/components/dashboard/SprintDashboard.jsx"
    click WelcomeCard "https://github.com/ayash-bera/inkei/blob/main/src/components/dashboard/WelcomeCard.jsx"
    click SectionsDir "https://github.com/ayash-bera/inkei/tree/main/src/components/sections/"
    click UIkitDir "https://github.com/ayash-bera/inkei/tree/main/src/components/ui/"
    click Utils "https://github.com/ayash-bera/inkei/blob/main/src/lib/utils.js"
    click Server "https://github.com/ayash-bera/inkei/blob/main/backend/server.js"
    click AuthRoutes "https://github.com/ayash-bera/inkei/blob/main/backend/routes/auth.js"
    click UserModel "https://github.com/ayash-bera/inkei/blob/main/backend/models/userModel.js"
    click DBManager "https://github.com/ayash-bera/inkei/blob/main/backend/utils/dbManager.js"
    click MainPy "https://github.com/ayash-bera/inkei/blob/main/AIModels/main.py"
    click StreamlitApp "https://github.com/ayash-bera/inkei/blob/main/AIModels/app.py"
    click ChatInterface "https://github.com/ayash-bera/inkei/blob/main/AIModels/fuckaround/components/chat_interface.py"
    click FileHandler "https://github.com/ayash-bera/inkei/blob/main/AIModels/fuckaround/core/file_handler.py"
    click ModelSelector "https://github.com/ayash-bera/inkei/blob/main/AIModels/fuckaround/core/model_selector.py"
    click QAChain "https://github.com/ayash-bera/inkei/blob/main/AIModels/fuckaround/core/qa_chain.py"
    click TextParser "https://github.com/ayash-bera/inkei/blob/main/AIModels/fuckaround/core/text_parser.py"
    click ImageParser "https://github.com/ayash-bera/inkei/blob/main/AIModels/fuckaround/core/image_parser.py"
    click GitHubHandler "https://github.com/ayash-bera/inkei/blob/main/AIModels/fuckaround/core/github_handler.py"
    click DataDir "https://github.com/ayash-bera/inkei/tree/main/AIModels/fuckaround/data/uploaded_data/"
    click Prompts "https://github.com/ayash-bera/inkei/blob/main/AIModels/fuckaround/prompts/task_analysis.py"
    click CI "https://github.com/ayash-bera/inkei/blob/main/.github/workflows/docker_publish.yml"
    click Dockerfile "https://github.com/ayash-bera/inkei/tree/main/Dockerfile"
    click Nginx "https://github.com/ayash-bera/inkei/blob/main/nginx.config"
    click Vercel "https://github.com/ayash-bera/inkei/blob/main/vercel.json"
    click Docs "https://github.com/ayash-bera/inkei/blob/main/documentation.html"
    click Readme "https://github.com/ayash-bera/inkei/blob/main/README.md"

    %% Styles
    classDef ui fill:#D0E8FF,stroke:#333,stroke-width:1px
    classDef core fill:#D0FFD0,stroke:#333,stroke-width:1px
    classDef data fill:#FFDFA0,stroke:#333,stroke-width:1px
    classDef external fill:#E0E0E0,stroke:#333,stroke-width:1px
```
