# mihirbhadak/daiict architecture

> Architecture diagram of the GitHub repository mihirbhadak/daiict, 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/mihirbhadak/daiict
- Repository: https://github.com/mihirbhadak/daiict

## Overview

##### Main Components
- Frontend Interface:
– Next.js pages (see folders “app”, “app/page.tsx”, “app/chat-with-ai/page.tsx”, and corresponding pages under “video-conferancing/src/app”) provide the user interface.
– Reusable UI components (under “components” and “video-conferancing/src/components”) including FileUploader, HomePage, Chat, and various UI elements.
- Backend API Services:
– Next.js API routes (in “app/api” and “pdf scanning/app/api”) such as “parse-data/route.ts” and “prompter/route.ts” handle business logic, data parsing, and serving AI/chat functionality.
- Specialized Modules:
– PDF Scanning: A dedicated module (in the “pdf scanning” directory) for processing and extracting data from health reports.
– Video Conferencing: A separate sub-application (in “video-conferancing”) managing telemedicine functionalities like meetings, call streaming, and session management.
- Shared Libraries:
– Utility functions (in “lib” and “pdf scanning/lib”) which encapsulate common logic for different modules.
- External Integrations & Services:
– AI-driven diagnostics layer (leveraging tools such as LlamaIndex) to analyze health reports.
– Blockchain components (utilizing Solidity and tools like Palmyra Medical) for ensuring data security and integrity.
– PostgreSQL database to persist health records, user data, and other transactional details.

##### Relationships and Data Flows
- The UI layer interacts with the Backend API layer through RESTful calls or Next.js server-side functions.
- From the API endpoints, data flows to/from the database (PostgreSQL) and, where necessary, to external services such as blockchain networks and AI modules.
- Within specialized modules (PDF scanning and video conferencing), the internal API routes and pages maintain similar interactions: receiving input (file uploads, video stream initiation) and processing via dedicated utility modules.
- Communication between the cryptographically secured blockchain components and the API ensures that data integrity and access controls are maintained.

##### Architectural Patterns & Design Principles
- Modular Design: Each feature (AI diagnostics, PDF scanning, video calling) is compartmentalized into its own module, following a separation-of-concerns approach.
- Scalability & Extensibility: Emphasize how independent modules (like video conferencing and PDF scanning) can be scaled separately while still integrating with the common backend and external services.

##### Technologies, Frameworks, and Libraries
- Next.js – For rendering pages and API routes.
- React – For building UI components.
- Tailwind CSS – (as seen in “globals.css” and config files) for UI styling.
- Node.js ecosystem – Indicated by package.json and associated libraries.
- Solidity – Token or smart contract logic for blockchain security.
- LlamaIndex – For integrating AI diagnostics.
- PostgreSQL – The database layer.

##### Final Recommendations
- Be very detailed: Don’t hesitate to break down each layer into as many components as necessary. For example, list out the individual API routes, UI modules, and even utility functions where they represent major parts of the logic.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        subgraph "Next.js Frontend"
            NPages["Pages: app/page.tsx, app/layout.tsx, app/chat-with-ai/page.tsx"]:::presentation
            NComponents["Components: FileUploader, HomePage, Chat, ChatMessage, UI Elements"]:::presentation
        end
        subgraph "Video Conferencing Client"
            VCPage["Pages: video-conferancing/src/app/page.tsx"]:::presentation
            VCProvider["ClientProvider: video-conferancing/src/app/ClientProvider.tsx"]:::presentation
            VCMeeting["Meeting Pages: MeetingLoginPage.tsx, MeetingPage.tsx"]:::presentation
            VCComponents["Components: video-conferancing/src/components"]:::presentation
        end
    end

    %% API Services
    subgraph "API Services"
        CoreAPI["Core API Endpoints (parse-data, prompter)"]:::api
        PDFAPI["PDF Scanning API Endpoints (parse-data, prompter, chat)"]:::api
    end

    %% Specialized Modules
    subgraph "Specialized Modules"
        PDFModule["PDF Scanning Module (pages, api, components, lib)"]:::module
        VCModule["Video Conferencing Module (pages, meeting, components, hooks, lib)"]:::module
    end

    %% Shared Libraries
    subgraph "Shared Libraries"
        CoreUtils["Core Utils: lib/utils.ts"]:::shared
        PDFUtils["PDF Scanning Utils: pdf scanning/lib (utils, chat)"]:::shared
        VCUtils["Video Conferencing Utils: video-conferancing/src/lib/utils.ts"]:::shared
    end

    %% External Services
    subgraph "External Services"
        AI["AI Diagnostic Engine (LlamaIndex)"]:::external
        Blockchain["Blockchain Integration (Solidity/Palmyra Medical)"]:::external
        Database["PostgreSQL Database"]:::external
    end

    %% Connections between Layers
    NPages -->|"calls"| CoreAPI
    NComponents -->|"calls"| CoreAPI
    VCPage -->|"calls"| CoreAPI
    VCProvider -->|"calls"| CoreAPI
    VCMeeting -->|"calls"| CoreAPI
    VCComponents -->|"calls"| CoreAPI

    CoreAPI -->|"storage"| Database
    CoreAPI -->|"analysis"| AI
    CoreAPI -->|"security"| Blockchain

    PDFAPI -->|"storage"| Database
    PDFAPI -->|"analysis"| AI
    PDFAPI -->|"security"| Blockchain

    PDFModule -->|"specialized API calls"| PDFAPI
    VCModule -->|"integrates with API"| CoreAPI

    CoreAPI --- CoreUtils
    PDFAPI --- PDFUtils
    PDFModule --- PDFUtils
    VCModule --- VCUtils

    %% Click Events for Frontend Interface Components
    click NPages "https://github.com/mihirbhadak/daiict/blob/main/app/page.tsx"
    click NPages "https://github.com/mihirbhadak/daiict/blob/main/app/layout.tsx"
    click NPages "https://github.com/mihirbhadak/daiict/blob/main/app/chat-with-ai/page.tsx"
    click NComponents "https://github.com/mihirbhadak/daiict/blob/main/components/FileUploader.tsx"
    click NComponents "https://github.com/mihirbhadak/daiict/blob/main/components/HomePage.tsx"
    click NComponents "https://github.com/mihirbhadak/daiict/blob/main/components/chat/Chat.tsx"
    click NComponents "https://github.com/mihirbhadak/daiict/blob/main/components/chat/ChatMessage.tsx"
    click NComponents "https://github.com/mihirbhadak/daiict/tree/main/components/ui"

    click VCPage "https://github.com/mihirbhadak/daiict/blob/main/video-conferancing/src/app/page.tsx"
    click VCProvider "https://github.com/mihirbhadak/daiict/blob/main/video-conferancing/src/app/ClientProvider.tsx"
    click VCMeeting "https://github.com/mihirbhadak/daiict/blob/main/video-conferancing/src/app/meeting/[id]/MeetingLoginPage.tsx"
    click VCMeeting "https://github.com/mihirbhadak/daiict/blob/main/MeetingPage.tsx"
    click VCComponents "https://github.com/mihirbhadak/daiict/tree/main/video-conferancing/src/components"

    %% Click Events for Backend API Services Components
    click CoreAPI "https://github.com/mihirbhadak/daiict/blob/main/app/api/parse-data/route.ts"
    click CoreAPI "https://github.com/mihirbhadak/daiict/blob/main/app/api/prompter/route.ts"
    click PDFAPI "https://github.com/mihirbhadak/daiict/blob/main/pdf scanning/app/api/parse-data/route.ts"
    click PDFAPI "https://github.com/mihirbhadak/daiict/blob/main/pdf scanning/app/api/prompter/route.ts"
    click PDFAPI "https://github.com/mihirbhadak/daiict/blob/main/pdf scanning/app/api/chat/route.ts"

    %% Click Events for Specialized Modules
    click PDFModule "https://github.com/mihirbhadak/daiict/tree/main/pdf scanning"
    click VCModule "https://github.com/mihirbhadak/daiict/tree/main/video-conferancing"

    %% Click Events for Shared Libraries
    click CoreUtils "https://github.com/mihirbhadak/daiict/blob/main/lib/utils.ts"
    click PDFUtils "https://github.com/mihirbhadak/daiict/blob/main/pdf scanning/lib/utils.ts"
    click PDFUtils "https://github.com/mihirbhadak/daiict/tree/main/pdf scanning/lib/chat"
    click VCUtils "https://github.com/mihirbhadak/daiict/blob/main/video-conferancing/src/lib/utils.ts"

    %% Styles
    classDef presentation fill:#a1d99b,stroke:#31a354,stroke-width:2px;
    classDef api fill:#9ecae1,stroke:#3182bd,stroke-width:2px;
    classDef module fill:#fdae6b,stroke:#e6550d,stroke-width:2px;
    classDef shared fill:#dadaeb,stroke:#756bb1,stroke-width:2px;
    classDef external fill:#fdd0a2,stroke:#ff7f00,stroke-width:2px;
```
