# prasannaspa/sg architecture

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

- Interactive diagram: https://gitdiagram.com/prasannaspa/sg
- Repository: https://github.com/prasannaspa/sg

## Overview

##### Project Type and Purpose
- This is a single-page frontend application built with React and Vite. It has no custom backend code in the repo; instead it relies on environment variables and interacts with third-party services (HubSpot, PostHog, etc.). Its primary purpose is to deliver a fast, hot-reload-enabled developer workflow and a production-ready static bundle.

##### File Structure Analysis
- Top-level files:
- `.env` / `.env.example` – environment variables for HubSpot, PostHog, etc.
- `index.html` – HTML entry point for the SPA.
- `package.json` / `package-lock.json` – Node scripts, dependencies (React, Vite, plugins).
- `vite.config.js` (plus timestamped variants) – Vite build/dev server configuration.
- `postcss.config.js`, `tailwind.config.js` – CSS processing.
- `eslint.config.js`, `Development.yml` – linting rules and CI/dev workflow.
- No “backend” folder: everything lives client-side.
- Key patterns:
- SPA architecture
- Build & dev phases orchestrated by Vite (with React/Babel or SWC plugins)
- Static asset pipeline for CSS (Tailwind + PostCSS)

##### Important README Insights
- HMR via `@vitejs/plugin-react` or `@vitejs/plugin-react-swc`
- Environment-driven configuration for OAuth and analytics
- Emphasis on not committing `.env`

##### Components
a. Main Components
- Developer Machine & Dev Tools (Node.js, Vite Dev Server, ESLint)
- Build Pipeline (Vite + plugins, PostCSS/Tailwind, Babel or SWC)
- Static Asset Output (Production bundle served by CDN or static host)
- Browser (User’s client running the React SPA)
- External Services (HubSpot OAuth API, PostHog Analytics API, other third-party endpoints)
b. Relationships & Data Flows
- Dev Machine → (start) → Vite Dev Server → (serves) → Browser
- Browser ↔ (API calls) ↔ HubSpot & PostHog
- Vite Build → (transpile & bundle) → `dist/` → Static Host/CDN → Browser
- Environment Variables → picked up by Vite at build/dev time
c. Architectural Patterns & Design Principles
- Single-Page Application (client-side routing, React component tree)
- Plugin-based build system (Vite core + React plugins)
- Configuration-as-Code (ESLint, PostCSS, Tailwind, Vite configs)
- Twelve-Factor App principle for environment variables
d. Key Technologies & Frameworks
- React (UI layer)
- Vite (bundler & dev server)
- @vitejs/plugin-react or plugin-react-swc (Fast Refresh/HMR)
- Tailwind CSS + PostCSS (utility-first styling pipeline)
- ESLint (code quality)

##### Detail Without Overthinking
- Break the frontend into sub-components only if it helps (e.g., UI Layer vs. State Management)
- Stages (Dev → Build → Runtime) and the external integrations
- Config/tool (Tailwind, PostCSS, ESLint) as part of the build or dev toolchain

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Developer Machine & Dev Tools"
        A1["package.json"]:::dev
        A2["eslint.config.js"]:::dev
        A3["Development.yml"]:::dev
        Dm1["README.md"]:::dev
        Dm2[".gitignore"]:::dev
        Dm3["package-lock.json"]:::dev
    end

    subgraph "Environment Variables"
        EV1[".env"]:::dev
        EV2[".env.example"]:::dev
    end

    subgraph "Vite Configurations"
        C1["vite.config.js"]:::build
        C2["vite.config.js.timestamp-*.mjs"]:::build
    end

    subgraph "Dev Phase"
        D1["Vite Dev Server"]:::build
    end

    subgraph "Build Phase"
        B1["Vite Build"]:::build
        subgraph "CSS Processing"
            B2["postcss.config.js"]:::build
            B3["tailwind.config.js"]:::build
        end
    end

    subgraph "Runtime Phase"
        R1["dist/"]:::runtime
        R2["Static Host/CDN"]:::runtime
        R3["index.html"]:::runtime
        R4["React SPA"]:::runtime
        R5["Browser"]:::runtime
    end

    subgraph "External Services"
        E1["HubSpot OAuth API"]:::external
        E2["PostHog Analytics API"]:::external
    end

    A1 & A2 & A3 & Dm1 & Dm2 & Dm3 --> D1
    EV1 & EV2 --> D1
    C1 & C2 --> D1

    A1 & A2 & A3 & EV1 & EV2 --> B1
    C1 & C2 --> B1
    B2 & B3 --> B1

    D1 -->|"serves"| R5
    B1 -->|"outputs dist bundle"| R1
    R1 --> R2
    R2 --> R3
    R3 --> R5

    R5 -->|"HTTP calls"| E1
    R5 -->|"HTTP calls"| E2

    click A1 "https://github.com/prasannaspa/sg/blob/main/package.json"
    click A2 "https://github.com/prasannaspa/sg/blob/main/eslint.config.js"
    click A3 "https://github.com/prasannaspa/sg/blob/main/Development.yml"
    click Dm1 "https://github.com/prasannaspa/sg/blob/main/README.md"
    click Dm2 "https://github.com/prasannaspa/sg/blob/main/.gitignore"
    click Dm3 "https://github.com/prasannaspa/sg/blob/main/package-lock.json"
    click EV1 "https://github.com/prasannaspa/sg/blob/main/.env"
    click EV2 "https://github.com/prasannaspa/sg/blob/main/.env.example"
    click C1 "https://github.com/prasannaspa/sg/blob/main/vite.config.js"
    click C2 "https://github.com/prasannaspa/sg/blob/main/vite.config.js.timestamp-*.mjs"
    click B2 "https://github.com/prasannaspa/sg/blob/main/postcss.config.js"
    click B3 "https://github.com/prasannaspa/sg/blob/main/tailwind.config.js"
    click R3 "https://github.com/prasannaspa/sg/blob/main/index.html"

    classDef dev fill:#add8e6,stroke:#000,stroke-width:1px
    classDef build fill:#90ee90,stroke:#000,stroke-width:1px
    classDef runtime fill:#d3d3d3,stroke:#000,stroke-width:1px
    classDef external fill:#fff8dc,stroke:#000,stroke-width:1px
```
