# sliceofbytes/adrenaline architecture

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

- Interactive diagram: https://gitdiagram.com/sliceofbytes/adrenaline
- Repository: https://github.com/sliceofbytes/adrenaline

## Overview

##### Project type and purpose
- This is a full-stack JavaScript/TypeScript project built on Next.js and React. It delivers a rich web UI (the “Adrenaline” app) plus a companion browser extension for chatting with your codebase via static analysis, vector search, and AI.

##### File structure
- Top-level directories:
- pages/        → Next.js pages (routes, _app, _document, app entry points)
- components/   → Reusable UI components (buttons, progress bars, code snippets, etc.)
- containers/   → Smart components or feature pages (ChatBot, CodeExplorer, RepositoryInput, etc.)
- extension/    → Browser extension’s React UI, styles, and helper libraries
- library/      → Shared utility code (data.js, mixpanel analytics, utilities.js)
- styles/       → Global and component-specific CSS, custom fonts
- Patterns:
- Container-Component pattern for view logic separation
- Shared “library” for cross-cutting concerns (analytics, utilities)
- Next.js conventions for pages and static assets

##### README
- Confirms: “talk to your codebase” powered by static analysis, vector search, AI
- Publicly hosted web app plus open-source UI for extension

##### Main components and depth-5 breakdown
Depth-1 (root tier):
– Users
– Browser (hosts Web App & Extension)
Depth-2 (platform tier):
– Next.js Web Application
– Browser Extension
Depth-3 (subsystem tier):
Next.js Web App:
- pages/ (routing layer)
- containers/ (feature logic)
- components/ (stateless UI)
- library/ (shared utilities & analytics)
- styles/ & public/ (static assets)
Browser Extension:
- extension/ (UI & logic)
Depth-4 (module tier):
Next.js Web App > pages/: _app.js, app.js, extension routes, index.js
Next.js Web App > containers/: ChatBot.js, CodeExplorer.js, etc.
Next.js Web App > components/: AddCodeButton.js, GeneratedCode.tsx, Spinner.js, etc.
Browser Extension > extension/: Extension.js, Chatbot.js, MessageInput.js, styles/, lib/
Depth-5 (leaf tier):
– extension/lib: dtos.js, mixpanel.js, utilities.js
– library/: data.js, mixpanel.js, utilities.js
– pages/extension/[owner]/[name]/index.js
– styles/fonts and other per-component CSS files

##### Relationships & interactions
- User → Browser UI (Web App or Extension)
- Web App & Extension ↔ Shared library for Mixpanel analytics & utilities
- Web App & Extension → External services:
- GitHub/GitLab OAuth & repository APIs
- Static analysis & vector search back-end (AI service)
- Payment gateway for subscription management
- Data flows:
- User actions (queries, code selection) → containers → API calls → AI/analysis service → vector DB → results → containers → components → user

##### Architectural patterns/design principles
- Separation of concerns: containers (logic) vs. components (presentation)
- Shared library for cross-cutting concerns
- Next.js for server-side rendering & routing
- Modular CSS scoped per component
- Extension sandbox isolated from main app

##### Detail without overthinking
- Every directory up to five levels deep
- How each layer depends on the one below
- Be explicit about external integrations and data flows

## Diagram (Mermaid)

```mermaid
graph TB
    %% Depth-1: Users and Platforms
    Users["Users"]:::external
    Users -->|"uses"| NextApp
    Users -->|"uses"| Ext

    %% Depth-2: Platforms
    subgraph "Next.js Web App"
        direction TB
        NextApp["Next.js Web App"]:::ui

        %% Depth-3: Subsystems
        subgraph "pages/ (Routing Layer)"
            direction TB
            P_app["_app.js"]:::ui
            P_document["_document.js"]:::ui
            P_appjs["app.js"]:::ui
            P_index["index.js"]:::ui
            P_extroute["extension/[owner]/[name]/index.js"]:::ui
        end

        subgraph "containers/ (Feature Logic)"
            direction TB
            C_ChatBot["ChatBot.js"]:::ui
            C_CodeExplorer["CodeExplorer.js"]:::ui
            C_RepoInput["RepositoryInput.js"]:::ui
        end

        subgraph "components/ (Stateless UI)"
            direction TB
            CP_AddCode["AddCodeButton.js"]:::ui
            CP_Generated["GeneratedCode.tsx"]:::ui
            CP_Spinner["Spinner.js"]:::ui
        end

        subgraph "library/ (Shared Logic)"
            direction TB
            L_util["utilities.js"]:::logic
            L_mixpanel["mixpanel.js"]:::logic
            L_data["data.js"]:::logic
        end

        subgraph "styles/ & public/ (Static Assets)"
            direction TB
            subgraph "styles/"
                direction TB
                S_globals["globals.css"]:::static
                subgraph "fonts/"
                    direction TB
                    S_font["Gilroy-ExtraBold.otf"]:::static
                end
                S_AddCSS["AddCodeButton.css"]:::static
            end
            subgraph "public/"
                direction TB
                Pub_html["index.html"]:::static
                Pub_manifest["manifest.json"]:::static
                Pub_robots["robots.txt"]:::static
            end
        end

        %% Data flows within Next.js Web App
        P_app -->|routes to| C_ChatBot
        C_ChatBot -->|renders| CP_AddCode
        C_CodeExplorer -->|renders| CP_Spinner
        C_RepoInput -->|uses| CP_Generated
        C_ChatBot -->|calls| L_util
        C_ChatBot -->|analytics| L_mixpanel
    end

    %% Depth-2: Browser Extension
    subgraph "Browser Extension"
        direction TB
        Ext["Browser Extension"]:::ui

        subgraph "extension/ (UI & Logic)"
            direction TB
            E_Ext["Extension.js"]:::ui
            E_Chat["Chatbot.js"]:::ui
            E_Input["MessageInput.js"]:::ui
        end

        subgraph "extension/lib (Shared Logic)"
            direction TB
            EL_util["utilities.js"]:::logic
            EL_mixpanel["mixpanel.js"]:::logic
            EL_dtos["dtos.js"]:::logic
        end

        subgraph "extension/styles (Static Assets)"
            direction TB
            ES_chatcss["Chatbot.css"]:::static
            ES_inputcss["MessageInput.css"]:::static
            ES_msgcss["Messages.css"]:::static
        end

        %% Data flows within Extension
        E_Ext -->|spawns| E_Chat
        E_Chat -->|reads input| E_Input
        E_Chat -->|calls| EL_util
        E_Chat -->|analytics| EL_mixpanel
    end

    %% External Services
    subgraph "External Services"
        direction TB
        GitHub["GitHub/GitLab API"]:::external
        AI["AI/Vector Search Service"]:::external
        Payment["Payment Gateway"]:::external
    end

    %% Data flow between platforms and external
    NextApp -->|OAuth & repo calls| GitHub
    NextApp -->|AI queries| AI
    NextApp -->|subscription| Payment
    Ext -->|AI queries| AI
    Ext -->|analytics| GitHub

    %% Click Events
    click P_app "https://github.com/sliceofbytes/adrenaline/blob/master/_app.js"
    click P_document "https://github.com/sliceofbytes/adrenaline/blob/master/_document.js"
    click P_appjs "https://github.com/sliceofbytes/adrenaline/blob/master/pages/app.js"
    click P_index "https://github.com/sliceofbytes/adrenaline/blob/master/pages/index.js"
    click P_extroute "https://github.com/sliceofbytes/adrenaline/blob/master/pages/extension/[owner]/[name]/index.js"
    click C_ChatBot "https://github.com/sliceofbytes/adrenaline/blob/master/containers/ChatBot.js"
    click C_CodeExplorer "https://github.com/sliceofbytes/adrenaline/blob/master/containers/CodeExplorer.js"
    click C_RepoInput "https://github.com/sliceofbytes/adrenaline/blob/master/containers/RepositoryInput.js"
    click CP_AddCode "https://github.com/sliceofbytes/adrenaline/blob/master/components/AddCodeButton.js"
    click CP_Generated "https://github.com/sliceofbytes/adrenaline/blob/master/components/GeneratedCode.tsx"
    click CP_Spinner "https://github.com/sliceofbytes/adrenaline/blob/master/components/Spinner.js"
    click L_util "https://github.com/sliceofbytes/adrenaline/blob/master/library/utilities.js"
    click L_mixpanel "https://github.com/sliceofbytes/adrenaline/blob/master/library/mixpanel.js"
    click L_data "https://github.com/sliceofbytes/adrenaline/blob/master/library/data.js"
    click Pub_html "https://github.com/sliceofbytes/adrenaline/blob/master/public/index.html"
    click Pub_manifest "https://github.com/sliceofbytes/adrenaline/blob/master/public/manifest.json"
    click Pub_robots "https://github.com/sliceofbytes/adrenaline/blob/master/public/robots.txt"
    click S_globals "https://github.com/sliceofbytes/adrenaline/blob/master/styles/globals.css"
    click S_font "https://github.com/sliceofbytes/adrenaline/blob/master/styles/fonts/Gilroy-ExtraBold.otf"
    click S_AddCSS "https://github.com/sliceofbytes/adrenaline/blob/master/styles/AddCodeButton.css"
    click E_Ext "https://github.com/sliceofbytes/adrenaline/blob/master/extension/Extension.js"
    click E_Chat "https://github.com/sliceofbytes/adrenaline/blob/master/extension/Chatbot.js"
    click E_Input "https://github.com/sliceofbytes/adrenaline/blob/master/extension/MessageInput.js"
    click EL_util "https://github.com/sliceofbytes/adrenaline/blob/master/extension/lib/utilities.js"
    click EL_mixpanel "https://github.com/sliceofbytes/adrenaline/blob/master/extension/lib/mixpanel.js"
    click EL_dtos "https://github.com/sliceofbytes/adrenaline/blob/master/extension/lib/dtos.js"
    click ES_chatcss "https://github.com/sliceofbytes/adrenaline/blob/master/extension/styles/Chatbot.css"
    click ES_inputcss "https://github.com/sliceofbytes/adrenaline/blob/master/extension/styles/MessageInput.css"
    click ES_msgcss "https://github.com/sliceofbytes/adrenaline/blob/master/extension/styles/Messages.css"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#1E90FF;
    classDef logic fill:#90EE90,stroke:#228B22;
    classDef external fill:#FFA500,stroke:#FF8C00;
    classDef static fill:#D3D3D3,stroke:#696969;
```
