# p-thavamani/cyber-issue-sop-based-chatbot architecture

> Architecture diagram of the GitHub repository p-thavamani/cyber-issue-sop-based-chatbot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/p-thavamani/cyber-issue-sop-based-chatbot
- Repository: https://github.com/p-thavamani/cyber-issue-sop-based-chatbot

## Overview

##### Project Type and Purpose
- This is a single-page application (SPA) built with React and Vite.
- Its primary purpose is to present a dashboard and AI assistant UI in the browser and to interact directly with the Gemini API (an external AI service).

##### File Structure
- Top-level files and folders:
- index.html, index.tsx, App.tsx → entry point for the React SPA
- components/ → reusable UI components (e.g., DashboardCard, Flowchart, SopStep)
- pages/ → high-level views (DashboardPage, AIAssistantPage)
- services/geminiService.ts → API client layer for Gemini calls
- constants.ts, types.ts → shared data models and constants
- vite.config.ts, tsconfig.json → build and TypeScript configuration
- No dedicated backend folder means the app is purely client-side; it relies on an external AI API.

##### Extract Insights from the README
- The app runs locally via `npm run dev` with Vite’s dev server.
- It needs a GEMINI_API_KEY in `.env.local` to authenticate calls to the Gemini API.
- Deployment target is AI Studio hosting, which will serve the built static assets.

##### Main Components and Their Relationships
a. Browser Client (React SPA)
- Pages (pages/) orchestrate high-level flows.
- Components (components/) provide UI widgets.
- state/hooks manage user interactions.
b. Service Layer (geminiService)
- Exposes functions to make HTTP requests to the Gemini API.
- Handles request/response transformation.
c. External AI Service (Gemini API)
- Receives requests with user prompts and returns AI responses.
d. Build & Deployment
- Vite (vite.config.ts) bundles and serves code in dev.
- NPM scripts manage build, dev, and deploy workflows.
- .env.local supplies runtime secrets.

##### Architectural Patterns and Design Principles
- Layered UI & service separation: UI components call a centralized service module.
- Single page app pattern with React Router (implied by page folder).
- Configuration-driven (environment variables for API key).
- Type safety with TypeScript (types.ts, tsconfig.json).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Build & Deployment"
        VITE["Vite (vite.config.ts)"]:::build
        TS["TypeScript Config (tsconfig.json)"]:::build
        PKG["Package Config (package.json)"]:::build
        ENV["Env Vars (.env.local)"]:::build
    end

    subgraph "Browser (React SPA)"
        direction TB
        subgraph "UI - Pages"
            direction TB
            DP["DashboardPage"]:::frontend
            AA["AIAssistantPage"]:::frontend
        end

        subgraph "UI - Components"
            direction TB
            DC["DashboardCard"]:::frontend
            FC["Flowchart"]:::frontend
            SS["SopStep"]:::frontend
            HD["Header"]:::frontend
            CI["ComplianceIcon"]:::frontend
            subgraph "Icons"
                direction TB
                CIc["CheckIcon"]:::frontend
                EI["ExclamationIcon"]:::frontend
                XI["XIcon"]:::frontend
            end
        end

        GS["geminiService"]:::service
    end

    subgraph "External Service"
        GEM["Gemini API"]:::external
    end

    %% Data flows
    VITE -->|"builds and serves"| Browser
    ENV -->|"injects GEMINI_API_KEY"| GS
    DP -->|"renders"| DC
    DP -->|"renders"| FC
    DP -->|"renders"| SS
    AA -->|"renders"| HD
    AA -->|"renders"| CI
    DC -->|"uses icon"| CIc
    DC -->|"uses icon"| EI
    DC -->|"uses icon"| XI
    DP -->|"calls"| GS
    AA -->|"calls"| GS
    GS -->|"POST prompt →"| GEM
    GEM -->|"returns AI response"| GS
    GS -->|"response →"| DP
    GS -->|"response →"| AA

    %% Click Events
    click DP "https://github.com/p-thavamani/cyber-issue-sop-based-chatbot/blob/main/pages/DashboardPage.tsx"
    click AA "https://github.com/p-thavamani/cyber-issue-sop-based-chatbot/blob/main/pages/AIAssistantPage.tsx"
    click DC "https://github.com/p-thavamani/cyber-issue-sop-based-chatbot/blob/main/components/DashboardCard.tsx"
    click FC "https://github.com/p-thavamani/cyber-issue-sop-based-chatbot/blob/main/components/Flowchart.tsx"
    click SS "https://github.com/p-thavamani/cyber-issue-sop-based-chatbot/blob/main/components/SopStep.tsx"
    click HD "https://github.com/p-thavamani/cyber-issue-sop-based-chatbot/blob/main/components/Header.tsx"
    click CI "https://github.com/p-thavamani/cyber-issue-sop-based-chatbot/blob/main/components/ComplianceIcon.tsx"
    click CIc "https://github.com/p-thavamani/cyber-issue-sop-based-chatbot/blob/main/components/icons/CheckIcon.tsx"
    click EI "https://github.com/p-thavamani/cyber-issue-sop-based-chatbot/blob/main/components/icons/ExclamationIcon.tsx"
    click XI "https://github.com/p-thavamani/cyber-issue-sop-based-chatbot/blob/main/components/icons/XIcon.tsx"
    click GS "https://github.com/p-thavamani/cyber-issue-sop-based-chatbot/blob/main/services/geminiService.ts"
    click VITE "https://github.com/p-thavamani/cyber-issue-sop-based-chatbot/blob/main/vite.config.ts"
    click TS "https://github.com/p-thavamani/cyber-issue-sop-based-chatbot/blob/main/tsconfig.json"
    click PKG "https://github.com/p-thavamani/cyber-issue-sop-based-chatbot/blob/main/package.json"
    click ENV "https://github.com/p-thavamani/cyber-issue-sop-based-chatbot/blob/main/.env.local"

    %% Style Definitions
    classDef frontend fill:#D0E6FF,stroke:#0366d6,color:#0366d6;
    classDef service fill:#DFFFD0,stroke:#1a9b00,color:#1a9b00;
    classDef external fill:#FFE0B2,stroke:#e65100,color:#e65100;
    classDef build fill:#F0F0F0,stroke:#888888,color:#555555;
```
