# ctheface/indic-wisdom architecture

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

- Interactive diagram: https://gitdiagram.com/ctheface/indic-wisdom
- Repository: https://github.com/ctheface/indic-wisdom

## Overview

##### Project type and purpose
- This is a full-stack web application (“Indic Wisdom”) that delivers Bhagavad Gita verses with AI-powered insights and a “like” system.
- Frontend: React.js with Vite for development and Bootstrap+custom CSS for styling.
- Backend: Node.js + Express, using Supabase for database/storage and Google Gemini API for AI.

##### File structure
- Top level:
- Procfile (deployment on Heroku‐style PaaS)
- package.json / lock (npm dependencies)
- vite.config.js, eslint.config.js (build + lint config)
- bhagavad_gita_verses.csv (data seed)
- public/index.html + public assets (static hosting by Vercel)
- src/
- main.jsx, App.jsx, components/, pages/ (client-side React code)
- server.js (Express entry point)
- supabase.js (DB client initialization)

##### Extract architectural insights from the README
- Frontend deployed on Vercel (static hosting + serverless functions?).
- Backend deployed on Render (Express REST API).
- Supabase provides Postgres-based DB and authentication.
- Google Gemini API used for AI interpretation of verses.

##### Main components & their interactions
a. Client Browser (User)
b. Frontend Application (React/Vite)
c. Backend API (Node.js/Express)
d. Database Service (Supabase)
e. External AI Service (Google Gemini)

Interaction flow:
- User → HTTP(S) → Frontend (Vercel)
- Frontend → REST API calls → Backend (Render)
- Backend → Supabase client → Database (CRUD for verses + likes)
- Backend → HTTPS → Google Gemini API (AI insights)
- Backend aggregates data and returns JSON → Frontend
- Frontend renders WisdomCard components with AI text & like buttons

##### Architectural patterns & design principles
- Component-based UI (React) with separation of concerns: pages/ vs components/
- RESTful API layer (Express)
- Single-page application with client-side routing (About.jsx, infinite scroll)
- External service integration encapsulated in server.js

##### Key details to capture
- The React app’s dynamic infinite scroll fetching fresh verses
- LikedWisdom component’s interactions with the Express API for storing favorites
- The dual data sources for verse content (static CSV seed loaded into Supabase) vs AI insights (live Google Gemini calls)
- Supabase handling both data storage and user authentication (if implemented)

##### Final recommendations
- Clear client↔server↔database↔external API boundaries.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Primary Layers
    UB["User Browser"]:::frontend
    subgraph "React SPA (Vercel)" 
        direction TB
        App["App.jsx"]:::frontend
        Main["main.jsx"]:::frontend
        Index["index.html"]:::frontend
        WC["WisdomCard.jsx"]:::frontend
        LW["LikedWisdom.jsx"]:::frontend
        IS["InfiniteScroll Logic"]:::frontend
        About["About.jsx"]:::frontend
    end
    subgraph "Express API (Render)"
        direction TB
        API["server.js"]:::backend
        Verses["/verses"]:::backend
        Likes["/likes"]:::backend
        Insights["/insights"]:::backend
    end
    DB[(Supabase DB + Auth)]:::db
    Cloud(("Google Gemini API")):::external
    subgraph "Build & Config"
        direction TB
        Vite["vite.config.js"]:::config
        Package["package.json"]:::config
        ESLint["eslint.config.js"]:::config
        Procfile["Procfile"]:::config
    end

    %% Connections
    UB -->|"GET index.html"| Index
    UB -->|"HTTPS"| App
    App -->|"GET /verses"| Verses
    App -->|"POST /likes"| Likes
    App -->|"POST /insights"| Insights
    IS -->|"trigger fetch"| Verses
    WC -->|"display AI & likes"| App
    LW -->|"manage favorites"| App
    About -->|"route via React Router"| App

    Verses -->|"SQL SELECT/INSERT"| DB
    Likes -->|"SQL INSERT/UPDATE"| DB
    Insights -->|"HTTPS POST"| Cloud
    Cloud -->|"AI response"| Insights
    DB -->|"JSON data"| Verses
    DB -->|"auth verify"| Likes

    %% Click Events
    click App "https://github.com/ctheface/indic-wisdom/blob/main/src/App.jsx"
    click Main "https://github.com/ctheface/indic-wisdom/blob/main/src/main.jsx"
    click Index "https://github.com/ctheface/indic-wisdom/blob/main/public/index.html"
    click WC "https://github.com/ctheface/indic-wisdom/blob/main/src/components/WisdomCard.jsx"
    click LW "https://github.com/ctheface/indic-wisdom/blob/main/src/components/LikedWisdom.jsx"
    click IS "https://github.com/ctheface/indic-wisdom/blob/main/src/App.jsx"
    click About "https://github.com/ctheface/indic-wisdom/blob/main/src/pages/About.jsx"
    click API "https://github.com/ctheface/indic-wisdom/blob/main/src/server.js"
    click DB "https://github.com/ctheface/indic-wisdom/blob/main/src/supabase.js"
    click Vite "https://github.com/ctheface/indic-wisdom/blob/main/vite.config.js"
    click Package "https://github.com/ctheface/indic-wisdom/blob/main/package.json"
    click ESLint "https://github.com/ctheface/indic-wisdom/blob/main/eslint.config.js"
    click Procfile "https://github.com/ctheface/indic-wisdom/tree/main/Procfile"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,color:#000
    classDef backend fill:#90EE90,stroke:#000,color:#000
    classDef db fill:#FFA500,stroke:#000,color:#000
    classDef external fill:#D3D3D3,stroke:#000,color:#000
    classDef config fill:#E0E0E0,stroke:#000,color:#000
```
