# human-bee/present architecture

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

- Interactive diagram: https://gitdiagram.com/human-bee/present
- Repository: https://github.com/human-bee/present

## Overview

##### Main Components
- Frontend Application: Representing the Next.js app which handles the UI, routing, and rendering.
- API Layer: The API routes under src/app/api (e.g., create-agent, get-token, livekit-diagnostics, livekit, refresh-token) that handle authentication and token management.
- Whiteboard Module: A dedicated component (e.g., TLDraw integration found in src/app/whiteboard and related components) for collaborative drawing.
- Video Conferencing Module: Components and API integration for video (located in src/app/videoconference and src/components/videoconference) that interface with LiveKit.
- Transcription/ Speech-to-Text Module: Components for transcription (e.g., src/app/transcription-board, src/components/transcription) and corresponding contexts.
- Context Providers: Global state management (e.g., TranscriptionContext, VideoConferenceContext) for sharing state across components.
- External Services: LiveKit’s external service for video and possibly any third-party speech-to-text service if applicable.

##### Relationships & Interactions
- The Frontend (Next.js) interacts with API routes (backend) to manage authentication and to retrieve/generate LiveKit tokens.
- The Whiteboard and Video Conferencing modules, although presented side by side in the UI, are integrated by sharing room/participant information (joined through URL parameters such as roomId).
- The speech-to-text transcription module feeds data (notes/annotations) back to the whiteboard.
- Context providers ensure that state (e.g., transcription data or video room status) is shared consistently across the UI components.
- External communication flows out to LiveKit, with directional data flows for video calls and token validation.

##### Architectural Patterns and Design Principles
- Modularized UI: Separation of concerns between components (whiteboard, videoconference, transcription) and API endpoints.
- Client-Server Interaction: Clear distinction between frontend and backend API routes makes for an edge-based, token-secure architecture.
- Use of Contexts: For state management in React, ensuring components remain loosely coupled.
- Layered Design: Present API endpoints in one layer and UI components in another, with a clear gateway for external LiveKit services.

##### Relevant Technologies and Frameworks
- Next.js as the frontend framework with React.
- TLDraw for the collaborative whiteboard.
- LiveKit for WebRTC–based video conferencing.
- Node.js for server-side operations.
- Testing libraries (Jest) are present and may be represented as a supporting quality assurance layer.
- ESLint and Prettier configurations indicate adherence to coding standards.

##### Specific Elements
- Use clear labels for:
- Frontend Application (Next.js + React)
- API Endpoints (create-agent, get-token, livekit, etc.)
- Whiteboard Module (TLDraw integration)
- Video Conferencing Module (LiveKit integration)
- Transcription Module (speech recognition and transcription board)
- Context Providers (for state management)
- External Services (LiveKit Cloud)
- From the Frontend to the API endpoints (authentication and token requests).
- From the API to the External LiveKit services.
- Between the Whiteboard, Video Conferencing, and Transcription components (indicating shared room state and real-time updates).
- Interdependencies such as the requirement of LiveKit tokens as a dependency for secure room access.

- Within the Frontend cluster, further subdivide areas into the whiteboard, video conferencing, and transcription modules, each connected by context or direct interactions.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Cluster
    subgraph "Frontend (Next.js)"
        A1("Frontend Application"):::ui
        %% Whiteboard Module
        subgraph "Whiteboard Module"
            WB("Whiteboard Page"):::ui
            CB("Collaborative Board"):::ui
        end
        %% Video Conferencing Module
        subgraph "Video Conferencing Module"
            VC("Videoconference Page"):::ui
            VCC("Video Conference Component"):::ui
        end
        %% Transcription Module
        subgraph "Transcription Module"
            TB("Transcription Board Page"):::ui
            TBC("Transcription Board Component"):::ui
            TC("Transcription Canvas"):::ui
        end
        %% Context Providers
        subgraph "Context Providers"
            TCX("Transcription Context"):::ui
            VCCX("Video Conference Context"):::ui
        end
    end

    %% API Layer Cluster
    subgraph "API Layer"
        API("API Endpoints"):::api
        LKA("LiveKit API"):::api
    end

    %% External Services Cluster
    subgraph "External Services"
        LKCloud("LiveKit Cloud"):::ext
        LKDebug("LiveKit Debug Page"):::ext
        LKDebugComp("LiveKit Debugger"):::ext
        LKInit("LiveKit Initializer"):::ext
    end

    %% Connections between Frontend and API Layer
    A1 -->|"calls"| API
    API -->|"calls"| LKA
    LKA -->|"connects"| LKCloud

    %% Internal Frontend Connections
    A1 -->|"loads"| WB
    A1 -->|"loads"| VC
    A1 -->|"loads"| TB

    WB -->|"sharedRoom"| VC
    VC -->|"sharedRoom"| WB
    TB -->|"feedsTranscription"| WB

    TCX -->|"provides state"| TBC
    VCCX -->|"provides state"| VCC

    %% Click Events
    click A1 "https://github.com/human-bee/present/tree/main/src/app"
    click API "https://github.com/human-bee/present/tree/main/src/app/api"
    click WB "https://github.com/human-bee/present/blob/main/src/app/whiteboard/[roomId]/page.tsx"
    click CB "https://github.com/human-bee/present/blob/main/src/components/CollaborativeBoard.tsx"
    click VC "https://github.com/human-bee/present/blob/main/src/app/videoconference/page.tsx"
    click VCC "https://github.com/human-bee/present/blob/main/src/components/videoconference/VideoConference.tsx"
    click TB "https://github.com/human-bee/present/blob/main/src/app/transcription-board/page.tsx"
    click TBC "https://github.com/human-bee/present/blob/main/src/components/TranscriptionBoard.tsx"
    click TC "https://github.com/human-bee/present/blob/main/src/components/TranscriptionCanvas.tsx"
    click TCX "https://github.com/human-bee/present/blob/main/src/contexts/TranscriptionContext.tsx"
    click VCCX "https://github.com/human-bee/present/blob/main/src/contexts/VideoConferenceContext.tsx"
    click LKA "https://github.com/human-bee/present/blob/main/src/app/api/livekit/route.ts"
    click LKDebug "https://github.com/human-bee/present/blob/main/src/app/livekit-debug/page.tsx"
    click LKDebugComp "https://github.com/human-bee/present/blob/main/src/components/LiveKitDebugger.tsx"
    click LKInit "https://github.com/human-bee/present/blob/main/src/components/LiveKitInitializer.tsx"

    %% Styles
    classDef ui fill:#BBDEFB,stroke:#1E88E5,stroke-width:2px;
    classDef api fill:#C8E6C9,stroke:#43A047,stroke-width:2px;
    classDef ext fill:#FFCDD2,stroke:#E53935,stroke-width:2px;
```
