# nirmannext/nirmannext-website architecture

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

- Interactive diagram: https://gitdiagram.com/nirmannext/nirmannext-website
- Repository: https://github.com/nirmannext/nirmannext-website

## Overview

##### Project Type and Purpose
- This is a JAMstack full-stack web application: a modern, responsive marketing/site built with React (TSX), Vite, Tailwind CSS, hosted via Firebase Hosting, with a small serverless backend (Firebase Cloud Functions) for dynamic tasks (e.g., form submissions).
- Purpose: deliver a fast, easily maintainable static site (landing pages, ROI calculator, trust signals, etc.) while offloading dynamic logic (forms, data writes) to Firebase Functions and Firestore.

##### File Structure Analysis
- Top-level directories:
- src/ – React application (components/, pages/, hooks/, lib/, services/, data/)
- public/ – Static assets (robots.txt, index.html template)
- functions/ – Firebase Cloud Functions (Node.js entry point, package.json)
- Config files: firebase.json (hosting & functions), firestore.rules/indexes, tsconfig.*, vite.config.ts, tailwind.config.ts, ESLint configs.
- Patterns:
- Component-based UI (src/components/ui/*)
- Page routing via Vite/React Router or file-based imports in src/main.tsx → src/App.tsx → pages/*.tsx
- JAMstack: static build → CDN, dynamic calls → Cloud Functions + Firestore

##### README Insights
- Emphasizes static hosting deployment (Vercel, Netlify, Firebase Hosting).
- Build & dev scripts: npm run dev, build, preview.

a. Main Components
- Browser / Client (User’s device)
- CDN / Static Host (Firebase Hosting serving Vite-built assets)
- Frontend SPA (React + TypeScript + Tailwind)
- Serverless Functions (Firebase Cloud Functions)
- Database (Firestore)
- External Services (optional: Analytics, Email service, Payment gateway if used)
b. Relationships & Data Flow
1. User → Browser → requests index.html & static bundle (JS/CSS) from CDN
2. SPA loads: React components render pages (Index, Products, Contact, etc.)
3. User actions (form submits, ROI calculator) call REST endpoints on Firebase Functions via HTTPS
4. Functions perform logic (validate, write to Firestore, send emails)
5. Firestore stores/retrieves data on behalf of functions or direct client SDK usage (if applicable via src/lib/firebase.ts)
c. Architectural Patterns & Principles
- JAMstack separation: pre-built assets vs. on-demand backend.
- Component-driven UI (UI library in src/components/ui).
- Single Responsibility: services folder handles data fetching, hooks handle cross-cutting concerns, lib contains shared utils and Firebase initialization.
- Security: Firestore rules, functions restricted via firebase.json.
d. Key Technologies
- Frontend: React, TypeScript, Vite, Tailwind CSS, PostCSS
- Backend: Firebase Cloud Functions (Node.js), Firestore (NoSQL)
- Tooling: ESLint, Prettier, bun (lockfile), npm, Vite dev server

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client Layer
    Browser("Browser"):::external

    %% CDN/Hosting Layer
    CDN("Firebase Hosting (CDN)"):::infra
    static_assets["public/ & index.html"]:::infra
    firebase_config["firebase.json"]:::infra
    vite_cfg["vite.config.ts"]:::infra
    tailwind_cfg["tailwind.config.ts"]:::infra

    Browser -->|GET index.html, JS/CSS| CDN
    CDN -->|serves static assets| static_assets
    CDN -->|loads SPA bundle| entry_main

    %% Frontend SPA
    subgraph "React SPA (Vite build)" 
        direction TB
        entry_main["main.tsx"]:::frontend
        entry_app["App.tsx"]:::frontend

        subgraph "Routing & Pages"
            pages["Pages (src/pages/)"]:::frontend
        end

        subgraph "UI Components"
            ui_lib["UI Library"]:::frontend
            static_ui["Static Components"]:::frontend
            roi["ROI Calculator"]:::frontend
            formdlg["JoinFormDialog"]:::frontend
        end

        subgraph "Data & Utils"
            service["PricingDataService"]:::frontend
            firebase_init["Firebase Init"]:::frontend
            utils["Utils"]:::frontend
            hooks["Custom Hooks"]:::frontend
        end

        entry_main --> entry_app
        entry_app --> pages
        entry_app --> ui_lib
        entry_app --> static_ui
        static_ui --> roi
        static_ui --> formdlg
        entry_app --> service
        service --> firebase_init
        service --> utils
        entry_app --> hooks
    end

    %% Serverless Backend
    subgraph "Serverless Backend" 
        direction TB
        functions["Cloud Functions"]:::backend

        subgraph "Functions Config"
            func_pkg["package.json"]:::backend
            func_esl[".eslintrc.js"]:::backend
        end
    end

    entry_app -->|HTTPS REST API| functions

    %% Database Layer
    subgraph "Database & Rules"
        direction TB
        firestore["Firestore Database"]:::db
        rules["Security Rules & Indexes"]:::db
    end

    functions -->|read/write| firestore
    rules -.-> firestore

    %% Config Connections
    firebase_config --> CDN
    vite_cfg -.-> entry_main
    tailwind_cfg -.-> entry_main

    %% Click Events
    click entry_main "https://github.com/nirmannext/nirmannext-website/blob/master/src/main.tsx"
    click entry_app "https://github.com/nirmannext/nirmannext-website/blob/master/src/App.tsx"
    click ui_lib "https://github.com/nirmannext/nirmannext-website/tree/master/src/components/ui/"
    click pages "https://github.com/nirmannext/nirmannext-website/tree/master/src/pages/"
    click static_ui "https://github.com/nirmannext/nirmannext-website/tree/master/src/components/"
    click roi "https://github.com/nirmannext/nirmannext-website/blob/master/src/components/ROICalculator.tsx"
    click formdlg "https://github.com/nirmannext/nirmannext-website/blob/master/src/components/JoinFormDialog.tsx"
    click service "https://github.com/nirmannext/nirmannext-website/blob/master/src/services/pricingDataService.ts"
    click firebase_init "https://github.com/nirmannext/nirmannext-website/blob/master/src/lib/firebase.ts"
    click utils "https://github.com/nirmannext/nirmannext-website/blob/master/src/lib/utils.ts"
    click hooks "https://github.com/nirmannext/nirmannext-website/tree/master/src/hooks/"
    click static_assets "https://github.com/nirmannext/nirmannext-website/tree/master/public/"
    click firebase_config "https://github.com/nirmannext/nirmannext-website/blob/master/firebase.json"
    click rules "https://github.com/nirmannext/nirmannext-website/blob/master/firestore.rules"
    click rules "https://github.com/nirmannext/nirmannext-website/blob/master/firestore.indexes.json"
    click functions "https://github.com/nirmannext/nirmannext-website/blob/master/functions/index.js"
    click func_pkg "https://github.com/nirmannext/nirmannext-website/blob/master/functions/package.json"
    click func_esl "https://github.com/nirmannext/nirmannext-website/blob/master/functions/.eslintrc.js"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#0066cc,color:#003366
    classDef backend fill:#ffe0b3,stroke:#cc8400,color:#663d00
    classDef db fill:#d5f5e3,stroke:#27ae60,color:#145a32
    classDef infra fill:#e0e0e0,stroke:#808080,color:#333333
    classDef external fill:#f2f2f2,stroke:#999999,color:#666666
```
