# amarnathss/prepstack_ai_assistent architecture

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

- Interactive diagram: https://gitdiagram.com/amarnathss/prepstack_ai_assistent
- Repository: https://github.com/amarnathss/prepstack_ai_assistent

## Overview

##### Project type and purpose
- This is a full-stack web application acting as an AI-powered study assistant.
- Frontend: React + Vite + TypeScript + Tailwind/shadcn UI
- Backend: Node.js + Express + TypeScript
- Core functionality: Retrieval-Augmented Generation (RAG) pipeline, GitHub repo analysis, note management, authentication, placement prep.

##### File structure
- Top-level directories:
- client/ – React frontend
- server/ – Express backend
- shared/ – Shared TypeScript types/schema
- attached_assets/ – Static assets
- Config & build scripts: tsconfig.json, vite.config.ts, drizzle.config.ts, tailwind.config.ts, package.json, .env.example
- Deployment docs: VERCEL_DEPLOYMENT.md, RENDER_DEPLOYMENT.md, AZURE_DEPLOYMENT.md, etc.

##### Key README insights
- Tech stack calls out external services: Groq API, OpenAI embeddings, GitHub API, PostgreSQL (Neon), Drizzle ORM.
- Features: file uploads (PDF/DOCX/TXT), intelligent search & indexing, JWT auth, role-based access, real-time chat.

##### Main components and relationships
a. Components
– Client Application (React SPA)
– Backend API Server (Express/Node)
– Database (PostgreSQL via Drizzle ORM)
– File Storage (local or cloud storage for uploads)
– Shared Schema Layer
– External AI Services:
- Groq AI inference
- OpenAI Embeddings API
– External Integration: GitHub API
– Authentication Layer (JWT)
b. Interactions
– User’s browser ↔ React app (HTTP/WebSocket for chat)
– React app ↔ Backend API (REST/HTTP)
– Backend ↔ Database (Drizzle ORM)
– Backend ↔ File storage (Multer + disk/cloud)
– Backend ↔ External AI Services (Groq, OpenAI) for RAG pipeline
– Backend ↔ GitHub API for repo analysis
– Backend enforces JWT-based auth for protected routes
c. Architectural patterns
– Separation of concerns: UI layer vs. API layer vs. data layer
– Service-oriented modules in server/services (fileProcessor, ragService, githubService, groqService)
– Shared types for consistency (shared/schema.ts)
– TanStack Query for data-fetch caching
d. Key technologies
– Vite dev server & build
– React 18 + TypeScript + Tailwind + shadcn/ui
– Express.js with TypeScript
– PostgreSQL + Drizzle ORM
– JWT, bcrypt, Multer
– Groq API, OpenAI Embeddings
– GitHub OAuth/Personal Access Token

##### Detailed capture of architectural elements
- Don’t just lump “Server”: break it into Layers
- Routes (server/routes.ts)
- Services (fileProcessor, ragService, githubService, groqService, groqService)
- Storage (server/storage.ts + Drizzle ORM)
- Authentication flow:
- LoginForm.tsx → /api/auth/login → JWT issued → stored in client
- Chat subsystem:
- Deployment considerations:
- Separate deployment of frontend (Vercel) and backend (Render/Azure)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client (React SPA)"
        direction TB
        Browser["User's Browser"]:::external
        Entry["client/src/main.tsx"]:::ui
        subgraph "Pages"
            direction TB
            AuthPage["auth.tsx"]:::ui
            DashboardPage["dashboard.tsx"]:::ui
            NotFoundPage["not-found.tsx"]:::ui
        end
        subgraph "UI Components"
            direction TB
            ChatSection["ChatSection"]:::ui
            NotesSection["NotesSection"]:::ui
            GitHubSection["GitHubSection"]:::ui
        end
        subgraph "Auth & Hooks"
            direction TB
            LoginForm["LoginForm.tsx"]:::ui
            UseAuth["useAuth.tsx"]:::ui
        end
        subgraph "API Utilities"
            direction TB
            ApiClient["api.ts"]:::ui
            QueryClient["queryClient.ts"]:::ui
        end
    end

    %% API Server Layer
    subgraph "Backend API Server (Express/Node)"
        direction TB
        ServerEntry["server/index.ts"]:::backend
        Routes["server/routes.ts"]:::backend
        subgraph "Services"
            direction TB
            FileProcessor["fileProcessor.ts"]:::backend
            GitHubService["githubService.ts"]:::backend
            RAGService["ragService.ts"]:::backend
            GroqService["groqService.ts"]:::backend
        end
        Storage["server/storage.ts"]:::backend
        DBConn["server/db.ts"]:::backend
    end

    %% Shared Schema
    Shared["shared/schema.ts"]:::shared

    %% Data & Externals
    subgraph "Data & External Services"
        direction TB
        Postgres["PostgreSQL (Drizzle ORM)"]:::datastore
        FileStorage["File Storage"]:::datastore
        GroqAPI["Groq AI API"]:::external
        OpenAI["OpenAI Embeddings API"]:::external
        GitHubAPI["GitHub API"]:::external
    end

    %% Config & Deployment
    subgraph "Config & Deployment"
        direction TB
        Env[".env.example"]:::config
        VercelDoc["VERCEL_DEPLOYMENT.md"]:::config
        RenderDoc["RENDER_DEPLOYMENT.md"]:::config
        AzureDoc["AZURE_DEPLOYMENT.md"]:::config
        ViteConfig["vite.config.ts"]:::config
        TailwindConfig["tailwind.config.ts"]:::config
        DrizzleConfig["drizzle.config.ts"]:::config
        ServerVite["server/vite.ts"]:::config
    end

    %% Connections
    Browser --> Entry
    Entry --> AuthPage
    Entry --> DashboardPage
    Entry --> NotFoundPage
    DashboardPage --> ChatSection
    DashboardPage --> NotesSection
    DashboardPage --> GitHubSection
    AuthPage --> LoginForm
    LoginForm --> UseAuth
    ChatSection --> ApiClient
    NotesSection --> ApiClient
    GitHubSection --> ApiClient
    ApiClient --> ServerEntry
    ServerEntry --> Routes
    Routes --> FileProcessor
    Routes --> GitHubService
    Routes --> RAGService
    Routes --> GroqService
    Routes --> Storage
    Routes --> DBConn
    FileProcessor --> FileStorage
    RAGService --> OpenAI
    RAGService --> Postgres
    RAGService --> GroqAPI
    GitHubService --> GitHubAPI
    DBConn --> Postgres
    Shared --> FileProcessor
    Shared --> RAGService
    Shared --> Routes

    %% Class Definitions
    classDef ui fill:#D0E8FF,stroke:#0366d6,color:#0366d6;
    classDef backend fill:#DFFFE0,stroke:#28A745,color:#22863A;
    classDef datastore fill:#FFF5B1,stroke:#DBAB09,color:#735C0F;
    classDef external fill:#F5E0FF,stroke:#6F42C1,color:#6F42C1;
    classDef shared fill:#E8E8E8,stroke:#6A737D,color:#24292E;
    classDef config fill:#FFEFE6,stroke:#D73A49,color:#B31D28;

    %% Click Events
    click Entry "https://github.com/amarnathss/prepstack_ai_assistent/blob/main/client/src/main.tsx"
    click AuthPage "https://github.com/amarnathss/prepstack_ai_assistent/blob/main/client/src/pages/auth.tsx"
    click DashboardPage "https://github.com/amarnathss/prepstack_ai_assistent/blob/main/client/src/pages/dashboard.tsx"
    click NotFoundPage "https://github.com/amarnathss/prepstack_ai_assistent/blob/main/client/src/pages/not-found.tsx"
    click ChatSection "https://github.com/amarnathss/prepstack_ai_assistent/blob/main/client/src/components/dashboard/ChatSection.tsx"
    click NotesSection "https://github.com/amarnathss/prepstack_ai_assistent/blob/main/client/src/components/dashboard/NotesSection.tsx"
    click GitHubSection "https://github.com/amarnathss/prepstack_ai_assistent/blob/main/client/src/components/dashboard/GitHubSection.tsx"
    click LoginForm "https://github.com/amarnathss/prepstack_ai_assistent/blob/main/client/src/components/auth/LoginForm.tsx"
    click UseAuth "https://github.com/amarnathss/prepstack_ai_assistent/blob/main/client/src/hooks/useAuth.tsx"
    click ApiClient "https://github.com/amarnathss/prepstack_ai_assistent/blob/main/client/src/lib/api.ts"
    click QueryClient "https://github.com/amarnathss/prepstack_ai_assistent/blob/main/client/src/lib/queryClient.ts"
    click ServerEntry "https://github.com/amarnathss/prepstack_ai_assistent/blob/main/server/index.ts"
    click Routes "https://github.com/amarnathss/prepstack_ai_assistent/blob/main/server/routes.ts"
    click FileProcessor "https://github.com/amarnathss/prepstack_ai_assistent/blob/main/server/services/fileProcessor.ts"
    click Storage "https://github.com/amarnathss/prepstack_ai_assistent/blob/main/server/storage.ts"
    click GitHubService "https://github.com/amarnathss/prepstack_ai_assistent/blob/main/server/services/githubService.ts"
    click RAGService "https://github.com/amarnathss/prepstack_ai_assistent/blob/main/server/services/ragService.ts"
    click GroqService "https://github.com/amarnathss/prepstack_ai_assistent/blob/main/server/services/groqService.ts"
    click DBConn "https://github.com/amarnathss/prepstack_ai_assistent/blob/main/server/db.ts"
    click Shared "https://github.com/amarnathss/prepstack_ai_assistent/blob/main/shared/schema.ts"
    click Env "https://github.com/amarnathss/prepstack_ai_assistent/blob/main/.env.example"
    click VercelDoc "https://github.com/amarnathss/prepstack_ai_assistent/blob/main/VERCEL_DEPLOYMENT.md"
    click RenderDoc "https://github.com/amarnathss/prepstack_ai_assistent/blob/main/RENDER_DEPLOYMENT.md"
    click AzureDoc "https://github.com/amarnathss/prepstack_ai_assistent/blob/main/AZURE_DEPLOYMENT.md"
    click ViteConfig "https://github.com/amarnathss/prepstack_ai_assistent/blob/main/vite.config.ts"
    click TailwindConfig "https://github.com/amarnathss/prepstack_ai_assistent/blob/main/tailwind.config.ts"
    click DrizzleConfig "https://github.com/amarnathss/prepstack_ai_assistent/blob/main/drizzle.config.ts"
    click ServerVite "https://github.com/amarnathss/prepstack_ai_assistent/blob/main/server/vite.ts"
```
