# khyathivardhan18/ai-app architecture

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

- Interactive diagram: https://gitdiagram.com/khyathivardhan18/ai-app
- Repository: https://github.com/khyathivardhan18/ai-app

## Overview

##### Project type and purpose
- This is **Edith AI App**, an open-source, AI-powered **Web IDE** built entirely as a client-side Single-Page Application (SPA).
- It’s written in **TypeScript** + **React** + **Vite**, styled with **Tailwind**, integrates with **Google Gemini AI** for intelligent coding assistance, and is deployed as static assets via **GitHub Pages / Netlify** with a **GitHub Actions** CI/CD pipeline.

##### File structure
- Top-level:
- .github/workflows/deploy.yml – CI/CD
- public/ – static assets (404.html, redirects, CSS)
- src/
– components/ (UI pieces: IDELayout, FileTree, CodeEditor, AIChat, TerminalPanel, etc.)
– context/ (global AppContext state)
– services/ (external/API layer: gemini.ts)
– utils/ (browser compatibility & in-browser file system)
– types/ (TypeScript definitions)
- Configs: package.json, vite.config.ts, tsconfig.json, tailwind.config.js, netlify.toml

##### Key insights from README
- SPA with layered architecture: UI Components → React Context → Services → External AI
- Emphasis on environment-based API key injection
- Automated deployment via GitHub Actions

##### Main components & interactions
a. **Browser / Client**
- **UI Layer** (React Components)
- IDELayout (shell)
- FileTree (file explorer)
- CodeEditor (monaco or similar)
- AIChat / AgentMode (chat interface)
- TerminalPanel
- SettingsPage, WelcomePage, etc.
- **State Layer** (AppContext)
- **Utilities**
- In-browser FileSystem API wrappers
- Browser compatibility checks
b. **Service Layer**
- gemini.ts: wraps calls to **Google Gemini AI** endpoints
c. **External Services**
- Google Gemini AI (REST/GRPC)
- (Optional) GitHub/GitLab sync (future roadmap)
d. **CI/CD & Hosting**
- GitHub Actions → build (Vite) → deploy to GitHub Pages / Netlify
e. **Static Asset Hosting**
- GitHub Pages / Netlify serving index.html + JS/CSS bundles

##### Architectural patterns & design principles
- **SPA Layering**: UI → State → Services
- **Component-Driven**: each IDE feature is a self-contained React component
- **Separation of Concerns**:
- components/ only render UI
- context/ holds application state & dispatchers
- services/ handle all external API communication
- utils/ encapsulate low-level browser APIs
- **Environment-Based Configuration**: VITE_API_KEY injected at build time
- **Static First**: no backend—everything runs in the browser

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% CI/CD & Hosting Layer
    subgraph "CI/CD & Hosting" 
        direction TB
        CI["GitHub Actions Pipeline"]:::ci
        Netlify["Netlify Config"]:::ci
        StaticHost["Static Host (GitHub Pages / Netlify)"]:::ci
        CI -->|"build (Vite)"| StaticHost
        Netlify -->|"configures deploy"| StaticHost
    end

    %% User Browser Layer
    subgraph "User Browser"
        direction TB

        %% UI Layer
        subgraph "UI Layer" 
            direction TB
            IDELayout["IDELayout Component"]:::ui
            FileTree["FileTree Component"]:::ui
            CodeEditor["CodeEditor Component"]:::ui
            AIChat["AIChat Component"]:::ui
            AgentMode["AgentMode Component"]:::ui
            ChatInterface["ChatInterface Component"]:::ui
            IDEChatInterface["IDEChatInterface Component"]:::ui
            TerminalPanel["TerminalPanel Component"]:::ui
            SettingsPage["SettingsPage Component"]:::ui
            WelcomePage["WelcomePage Component"]:::ui
            EnhancedWelcomePage["EnhancedWelcomePage Component"]:::ui
        end

        %% State & Utils Layer
        subgraph "State & Utils" 
            direction TB
            AppContext["AppContext (State)"]:::state
            BrowserCompat["Browser Compatibility Utility"]:::state
            FileSystem["In-browser FileSystem Utility"]:::state
        end

        %% Service Layer
        subgraph "Service Layer"
            direction TB
            GeminiService["Gemini Service (gemini.ts)"]:::service
        end

        %% Entry & Template
        Entry["Application Entry (src/main.tsx)"]:::state
        HTML["HTML Template (index.html)"]:::state

        %% Flows within Browser
        IDELayout -->|"renders"| FileTree
        IDELayout -->|"renders"| CodeEditor
        IDELayout -->|"renders"| TerminalPanel
        IDELayout -->|"renders"| AIChat
        AIChat -->|uses| ChatInterface
        AIChat -->|uses| AgentMode
        IDELayout -->|"routes to"| SettingsPage
        IDELayout -->|"routes to"| WelcomePage
        IDELayout -->|"routes to"| EnhancedWelcomePage
        IDELayout -->|"wraps in"| AppContext

        %% Data flows
        IDELayout -->|"dispatch actions"| AppContext
        FileTree -->|"dispatch actions"| AppContext
        CodeEditor -->|"dispatch actions"| AppContext
        AIChat -->|"dispatch actions"| AppContext
        AppContext -->|"calls"| GeminiService
        GeminiService -->|"HTTPS request / JSON"| GoogleGemini

        %% Utilities usage
        AppContext -->|"checks"| BrowserCompat
        AppContext -->|"reads/writes"| FileSystem

        %% Bootstrapping
        HTML -->|"loads"| Entry
        Entry -->|"initializes"| IDELayout

    end

    %% External AI Service
    subgraph "External Services"
        direction TB
        GoogleGemini["Google Gemini AI"]:::external
    end

    %% Hosting serving to browser
    StaticHost -->|"serves index.html + bundles"| HTML

    %% Click Events
    click IDELayout "https://github.com/khyathivardhan18/ai-app/blob/main/src/components/IDELayout.tsx"
    click FileTree "https://github.com/khyathivardhan18/ai-app/blob/main/src/components/FileTree.tsx"
    click CodeEditor "https://github.com/khyathivardhan18/ai-app/blob/main/src/components/CodeEditor.tsx"
    click AIChat "https://github.com/khyathivardhan18/ai-app/blob/main/src/components/AIChat.tsx"
    click AgentMode "https://github.com/khyathivardhan18/ai-app/blob/main/src/components/AgentMode.tsx"
    click ChatInterface "https://github.com/khyathivardhan18/ai-app/blob/main/src/components/ChatInterface.tsx"
    click IDEChatInterface "https://github.com/khyathivardhan18/ai-app/blob/main/src/components/IDEChatInterface.tsx"
    click TerminalPanel "https://github.com/khyathivardhan18/ai-app/blob/main/src/components/TerminalPanel.tsx"
    click SettingsPage "https://github.com/khyathivardhan18/ai-app/blob/main/src/components/SettingsPage.tsx"
    click WelcomePage "https://github.com/khyathivardhan18/ai-app/blob/main/src/components/WelcomePage.tsx"
    click EnhancedWelcomePage "https://github.com/khyathivardhan18/ai-app/blob/main/src/components/EnhancedWelcomePage.tsx"
    click AppContext "https://github.com/khyathivardhan18/ai-app/blob/main/src/context/AppContext.tsx"
    click GeminiService "https://github.com/khyathivardhan18/ai-app/blob/main/src/services/gemini.ts"
    click BrowserCompat "https://github.com/khyathivardhan18/ai-app/blob/main/src/utils/browserCompat.ts"
    click FileSystem "https://github.com/khyathivardhan18/ai-app/blob/main/src/utils/fileSystem.ts"
    click StaticHost "https://github.com/khyathivardhan18/ai-app/tree/main/public/"
    click CI "https://github.com/khyathivardhan18/ai-app/blob/main/.github/workflows/deploy.yml"
    click Netlify "https://github.com/khyathivardhan18/ai-app/blob/main/netlify.toml"

    %% Styles
    classDef ui fill:#D0E8FF,stroke:#0366d6,color:#0366d6;
    classDef state fill:#E6F4EA,stroke:#22863A,color:#22863A;
    classDef service fill:#E0F2F1,stroke:#00796B,color:#00796B;
    classDef external fill:#FFF4E5,stroke:#D9822B,color:#D9822B;
    classDef ci fill:#F1F8FF,stroke:#6A737D,color:#6A737D;
```
