# adarshukla3005/portfolio architecture

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

- Interactive diagram: https://gitdiagram.com/adarshukla3005/portfolio
- Repository: https://github.com/adarshukla3005/portfolio

## Overview

##### Project Type and Purpose
- Type: Full-stack portfolio website with a static frontend, serverless API endpoints, and a small Node.js backend for AI chatbot integration.
- Purpose: Serve static portfolio content (HTML/CSS/JS), provide an AI-powered chatbot via Google Gemini, implement RAG with an in-memory vector store, and deploy on Netlify (or any hosting).

##### Main Components
a. Frontend
– index.html, css/, scss/, js/, lib/, images/, fonts/
– Bundled SCSS→CSS build step (Prepros or npm scripts)
– Served as static assets via CDN/Netlify
b. Serverless Functions (Netlify Functions)
– netlify/functions/chatbot.js & test.js
– Exposed as HTTPS endpoints (e.g., `/.netlify/functions/chatbot`)
– Handle incoming user prompts, call backend logic
c. Node.js Backend (Express)
– server.js, package.json
– Also provides a dev server, fallback API routes, and RAG logic
– Depends on environment vars (PORT, GEMINI_API_KEY)
d. In-Memory Vector Store
– Stores indexed text snippets from portfolio content
– Performs vector similarity lookups for RAG
e. External AI Service
– Google Gemini API (Generative AI)
– Invoked by serverless functions / Express routes
f. Deployment & Hosting
– Netlify for static frontend & functions (netlify.toml)
– Optionally AWS/Azure/GCP or traditional hosting for server.js

##### Relationships and Data Flows
1. User’s Browser → CDN/Netlify
- Requests static HTML, CSS, JS
2. Frontend Chat Widget → Serverless Function Endpoint
- AJAX call to `/chatbot` function with user message
3. Serverless Function → In-Memory Vector Store
- Lookup top-K relevant snippets via cosine similarity
4. Serverless Function → Gemini API
- Send retrieved context + user question → receive generated answer
5. Serverless Function → Frontend
- Return response JSON to be rendered in chat UI
6. (Fallback) Frontend/API → Express Server
- During local dev or non-Netlify deploy, calls hit Express routes in server.js

##### Architectural Patterns and Principles
- Static Site + Serverless Backend (Jamstack)
- Retrieval-Augmented Generation (RAG) for chatbot
- Separation of Concerns:
– Static assets isolated from compute functions
– AI logic encapsulated in functions or Express middleware
- In-memory vector store for low-latency retrieval (no external DB)

##### Final Checklist
- Components: Frontend, Serverless Fns, Express Server, Vector Store, Gemini API
- Labels: Protocols, file/folder names (optional) for clarity

## Diagram (Mermaid)

```mermaid
flowchart TB
    UB["User Browser"]:::external
    CDN["Netlify CDN"]:::external

    subgraph "Frontend Layer"
        HTML["index.html"]:::frontend
        CSS["css/"]:::frontend
        SCSS["scss/"]:::frontend
        JS["js/"]:::frontend
        LIB["lib/"]:::frontend
        IMG["images/"]:::frontend
        FONTS["fonts/"]:::frontend
    end

    subgraph "Jamstack Compute (Netlify Functions)"
        FnChat["chatbot.js"]:::compute
        FnTest["test.js"]:::compute
    end

    subgraph "Express Server (Local Dev)"
        Server["server.js"]:::compute
    end

    Store["In-Memory Vector Store"]:::storage
    AI["Google Gemini API"]:::external

    subgraph "Configuration"
        NetlifyToml["netlify.toml"]:::config
        Prepros["prepros-6.config"]:::config
        DeployMd["NETLIFY_DEPLOY.md"]:::config
        Readme["README.md"]:::config
    end

    UB -->|"HTTPS"| CDN
    CDN -->|"Serves static assets"| HTML
    CDN --> CSS
    CDN --> SCSS
    CDN --> JS
    CDN --> LIB
    CDN --> IMG
    CDN --> FONTS

    JS -->|"AJAX to /functions/chatbot"| FnChat
    FnChat -->|"lookup context"| Store
    FnChat -->|"call API"| AI
    AI -->|"response"| FnChat
    FnChat -->|"JSON response"| UB

    UB -->|"Fallback API (Local Dev)"| Server
    Server -->|"lookup context"| Store
    Server -->|"call API"| AI
    AI -->|"response"| Server
    Server -->|"JSON response"| UB

    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef compute fill:#90EE90,stroke:#333,stroke-width:1px
    classDef external fill:#FFA500,stroke:#333,stroke-width:1px
    classDef storage fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef config fill:#EEEEEE,stroke:#333,stroke-width:1px

    click HTML "https://github.com/adarshukla3005/portfolio/blob/main//index.html"
    click CSS "https://github.com/adarshukla3005/portfolio/tree/main/css/"
    click SCSS "https://github.com/adarshukla3005/portfolio/tree/main/scss/"
    click JS "https://github.com/adarshukla3005/portfolio/tree/main/js/"
    click LIB "https://github.com/adarshukla3005/portfolio/tree/main/lib/"
    click IMG "https://github.com/adarshukla3005/portfolio/tree/main/images/"
    click FONTS "https://github.com/adarshukla3005/portfolio/tree/main/fonts/"
    click FnChat "https://github.com/adarshukla3005/portfolio/blob/main/netlify/functions/chatbot.js"
    click FnTest "https://github.com/adarshukla3005/portfolio/blob/main/netlify/functions/test.js"
    click Server "https://github.com/adarshukla3005/portfolio/blob/main/server.js"
    click NetlifyToml "https://github.com/adarshukla3005/portfolio/blob/main/netlify.toml"
    click Prepros "https://github.com/adarshukla3005/portfolio/blob/main/prepros-6.config"
    click DeployMd "https://github.com/adarshukla3005/portfolio/blob/main/NETLIFY_DEPLOY.md"
    click Readme "https://github.com/adarshukla3005/portfolio/blob/main/README.md"
```
