# preethamak/web architecture

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

- Interactive diagram: https://gitdiagram.com/preethamak/web
- Repository: https://github.com/preethamak/web

## Overview

##### Project type and purpose
- Equdator is a full‑stack web application.
- Frontend: a mix of static HTML/CSS/JS pages (index.html, signup.html, scripts.js, signup.js) plus a React/Vite single‑page app under `/src`.
- Backend: a Node.js/TypeScript HTTP server (`server.ts`).
- Database: a managed, serverless Postgres (Neon DB) accessed via Prisma ORM (`prisma/schema.prisma`).

##### File structure
Top‑level directories and files:
- `/index.html`, `/signup.html`: public entry points for landing and auth.
- `/scripts.js`, `/signup.js`: vanilla JS logic for the static pages.
- `/src`: React application (App.jsx, landing.jsx, main.jsx) + CSS/Tailwind assets.
- `/server.ts`: the API layer handling routes, JWT auth, business logic.
- `/prisma`: database schema, migration scripts, generated Prisma client in `/src/generated/prisma`.
- Build/config: `vite.config.js`, `tsconfig.json`, `eslint.config.js`, `package.json`.

##### README for extra context
- Emphasis on HTML/CSS/JS + Tailwind + Font Awesome.
- Database feature list (Neon DB serverless).
- Environment variables: `DATABASE_URL`, `JWT_SECRET`.
- Startup: `npm run dev` launches Vite + the TS server.

a. Main components
1. User’s Browser (Client)
- Static HTML pages + React SPA served to the browser.
- Tailwind/CSS + Font‑Awesome assets.
2. CDN / Static Asset Host (optional)
- Serves index.html, signup.html, JS/CSS bundles built by Vite.
3. Frontend App
- React/Vite code under `/src`.
- Runs in the browser, calls backend APIs.
4. API Server (server.ts)
- Node.js + TypeScript HTTP server.
- Implements authentication (JWT), routing, business logic.
5. Prisma ORM Layer
- Generated client in `/src/generated/prisma`.
- Exposes JS/TS methods to query Neon DB.
6. Neon Postgres DB
- The production data store; managed, serverless.
7. Environment & Dev Tools
- .env file: `DATABASE_URL`, `JWT_SECRET`.
- Vite dev server, ESLint, TS compiler.

b. Relationships & interactions
- Browser → (HTTP/HTTPS) → CDN or directly → serves static HTML & JS bundles.
- React code / scripts.js → (XHR/fetch) → API Server endpoints.
- API Server → (Prisma client) → Neon Postgres DB.
- API Server → (JWT) → Browser (auth tokens in headers/cookies).
- Prisma migrations → DB schema changes.

c. Architectural patterns/design principles
- Layered architecture: Presentation (static + React) → Application (server.ts) → Data (Prisma → DB).
- ORM pattern: Prisma abstracts SQL away.
- Single‑page app & multi‑page hybrid: landing + signup pages alongside a React SPA.
- Dev/prod parity: same code (server.ts, Prisma) runs locally and in production.

d. Key technologies
- Vite (dev/build)
- React (+ JSX)
- Tailwind CSS
- Node.js + TypeScript
- Prisma ORM
- Neon DB (serverless Postgres)
- JWT for auth

##### Detailed checklist
[ ] Static HTML pages (index.html, signup.html)
[ ] React SPA component (src/\*.jsx)
[ ] Vite build & dev server
[ ] Scripts.js / signup.js logic
[ ] API Server (server.ts): list endpoints (e.g., /signup, /login, /data)
[ ] Prisma ORM layer & schema.prisma
[ ] Neon DB (migrations, connection pooling)
[ ] Environment variables (DATABASE_URL, JWT_SECRET)
[ ] JWT token flow between Client ↔ API

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client" 
        direction TB
        StaticPages["Static Pages\n(index.html, signup.html)"]:::client
        Scripts["Page Scripts\n(scripts.js, signup.js)"]:::client
        ReactSPA["React SPA\n(src/main.jsx, App.jsx,\nlanding.jsx)"]:::client
        Styles["Global Styles\n(index.css, landing.css,\nApp.css)"]:::client
        StaticPages -->|Served to Browser| Scripts
        Scripts -->|User Interaction| ReactSPA
    end

    %% API Server Layer
    APIServer["API Server\n(Node.js/TypeScript)"]:::server
    PrismaLayer["Prisma ORM\n(prisma/schema.prisma)"]:::orm
    APIServer -->|Uses| PrismaLayer

    %% Database Layer
    NeonDB["Neon Postgres DB\n(Serverless)"]:::db
    PrismaLayer -->|SQL Queries| NeonDB

    %% Environment Variables
    EnvVars["Environment Variables\n(DATABASE_URL, JWT_SECRET)"]:::env
    EnvVars -.->|Injects| APIServer

    %% Dev Tools
    subgraph "Development & Build Tools"
        direction TB
        Vite["Vite Dev Server\n(vite.config.js)"]:::dev
        ESLint["ESLint\n(eslint.config.js)"]:::dev
        TS["TypeScript\n(tsconfig.json)"]:::dev
        NPM["NPM Scripts\n(package.json\npackage-lock.json)"]:::dev
        Vite -->|Build/Serve| ReactSPA
        TS -->|Compile| APIServer
        ESLint -->|Lint| ReactSPA
    end

    %% Click Events
    click StaticPages "https://github.com/preethamak/web/blob/main//index.html"
    click StaticPages "https://github.com/preethamak/web/blob/main//signup.html"
    click Scripts "https://github.com/preethamak/web/blob/main//scripts.js"
    click Scripts "https://github.com/preethamak/web/blob/main//signup.js"
    click ReactSPA "https://github.com/preethamak/web/blob/main//src/main.jsx"
    click ReactSPA "https://github.com/preethamak/web/blob/main//src/App.jsx"
    click ReactSPA "https://github.com/preethamak/web/blob/main//src/landing.jsx"
    click Styles "https://github.com/preethamak/web/blob/main//src/index.css"
    click Styles "https://github.com/preethamak/web/blob/main//src/landing.css"
    click Styles "https://github.com/preethamak/web/blob/main//src/App.css"
    click APIServer "https://github.com/preethamak/web/blob/main//server.ts"
    click PrismaLayer "https://github.com/preethamak/web/blob/main//prisma/schema.prisma"
    click PrismaLayer "https://github.com/preethamak/web/blob/main//prisma/migrations/20250416144044_init/migration.sql"
    click PrismaLayer "https://github.com/preethamak/web/blob/main//prisma/migrations/migration_lock.toml"
    click PrismaLayer "https://github.com/preethamak/web/tree/main//src/generated/prisma"
    click EnvVars "https://github.com/preethamak/web/blob/main//.env"
    click Vite "https://github.com/preethamak/web/blob/main//vite.config.js"
    click ESLint "https://github.com/preethamak/web/blob/main//eslint.config.js"
    click TS "https://github.com/preethamak/web/blob/main//tsconfig.json"
    click NPM "https://github.com/preethamak/web/blob/main//package.json"
    click NPM "https://github.com/preethamak/web/blob/main//package-lock.json"

    %% Styles
    classDef client fill:#D0E8FF,stroke:#0366d6,color:#0366d6,stroke-width:1px;
    classDef server fill:#DFFFE0,stroke:#28a745,color:#28a745,stroke-width:1px,shape:hexagon;
    classDef orm fill:#FFF5D0,stroke:#dbab09,color:#dbab09,stroke-width:1px;
    classDef db fill:#FFE0D0,stroke:#d73a49,color:#d73a49,stroke-width:1px,shape:cylinder;
    classDef env fill:#F0F0F0,stroke:#6a737d,color:#6a737d,stroke-width:1px,stroke-dasharray: 5 5;
    classDef dev fill:#F5F5F5,stroke:#586069,color:#586069,stroke-width:1px,shape:folder;
```
