# lakshaysk106/refrain-addiction architecture

> Architecture diagram of the GitHub repository lakshaysk106/refrain-addiction, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-02-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lakshaysk106/refrain-addiction
- Repository: https://github.com/lakshaysk106/refrain-addiction

## Overview

##### Project type & purpose (from tree + naming)
This is a **full-stack JavaScript web application** with:
- **React (Create React App) SPA frontend** in `src/` (+ `public/` assets)
- **Node.js/Express backend** implied by `app.js` and `routes/`
- **MongoDB persistence** implied by `mongo.js` / `mongo1.js`
- A **browser extension** (Chrome-style) in `routes/Extention/` with a `manifest.json`
- Features suggested by page/component names: **Auth (Login/Register), Admin dashboard, Consultant flows, Chat, Video/Meet calls, Assessments/Tracking, “Blockweb”** (likely tied to the extension), etc.
- Deployment hints: `vercel.json` (Vercel) and `public/_redirects` (SPA routing on static hosts)

##### React SPA (CRA)
- Code: `src/App.jsx`, `src/pages/*`, `src/components/*`
- Built assets served as static files (from `build/` when deployed)
##### Static hosting/CDN (Vercel or other)
- Hint: `vercel.json`, `public/_redirects`
##### Node/Express API server
- Entry: `app.js`
- Routes: `routes/routes.js`, `routes/Extention/main.js`
##### MongoDB database
- Connection logic: `mongo.js`, `mongo1.js`
##### Browser Extension
- Manifest: `routes/Extention/manifest.json`
- Logic: `routes/Extention/main.js`

- Browser → Static Host: `GET index.html/js/css`
- SPA → API Server: `HTTPS REST/JSON` (Auth, profile, bookings, assessment, tracking, etc.)
- API Server → MongoDB: `CRUD`
- Extension → API Server: likely `HTTPS` (policies, block lists, user identity, reporting)
- Extension → Browser: “blocks/redirects sites” (local behavior; annotate as client-side enforcement)

**Important:** If Chat/Meet/Video are real-time, add:
- SPA ↔ API Server: “WebSocket/Socket.IO (signaling/chat)” if present/used
- SPA ↔ SPA: “WebRTC media path (peer-to-peer)” if video calling is WebRTC
- SPA ↔ STUN/TURN provider: if used (external infra)

Goal: show how each container is structured.

##### Frontend components (from `src/`)
- `src/index.jsx` → mounts app
- `src/App.jsx` → routing/layout root
- **Pages** (`src/pages/*`): route-level screens (AdminLogin, AdminDashboard, Chat, Meet, Assessment, Track, Blockweb, etc.)
- **Reusable UI components** (`src/components/*`): Navbar/Sidebar, cards, video call components, etc.
- **Utils** (`src/utils/*`): shared helpers
- Styling: Tailwind/PostCSS (`tailwind.config.js`, `postcss.config.cjs`) + CSS/SCSS in components/pages

##### Backend components (from root + `routes/`)
- `app.js` (Express app)
- mounts routers
- `routes/routes.js` (main API routes)
- `routes/Extention/main.js` (extension-facing API endpoints or extension script host)
- `mongo.js` / `mongo1.js` (DB connection + maybe models/helpers)

##### What relationships/interactions to capture (be extremely explicit)
- `HTTPS (JSON REST)` for standard API calls
- `WebSocket` for real-time chat/signaling (if used)
- `WebRTC SRTP` for media (if used)
- `MongoDB wire protocol` (or “MongoDB driver”)

Also label **trust boundaries**:
- Public Internet boundary
- Backend private network boundary (API ↔ DB)
- Client device boundary (browser + extension)

**Client Side**
- End User Browser
- React SPA (`src/`)
- Admin/Consultant Browser
- React SPA (same build, different routes/roles)
- Browser Extension
- Extension (`routes/Extention/manifest.json`)

**Delivery**
- Static Hosting/CDN (Vercel)
- serves SPA bundle + `public/*`

**Server Side**
- Node.js Express API Server
- `app.js`
- `routes/routes.js` (main)
- `routes/Extention/main.js` (extension endpoints)

**Data**
- MongoDB
- connection via `mongo.js` / `mongo1.js`

**Optional / verify**
- Realtime gateway (Socket.IO) for Chat/Signaling (if present)
- WebRTC STUN/TURN (if video calling is WebRTC)
- Notifications (email/SMS/push) if used

##### Open `app.js` and list
- mounted routes
- middleware (auth, CORS)
- server type (Express only? serverless?)
2. Open `routes/routes.js` and enumerate endpoints by feature bucket (auth, users, bookings, assessments, tracking, etc.)
##### Open `mongo.js` / `mongo1.js` to confirm
- DB name/collections usage pattern
- whether Mongoose or native driver
##### Check `package.json` for
- server start scripts (single process vs separate client/server)
- dependencies like `express`, `mongoose`, `socket.io`, `webrtc`, etc.

## Diagram (Mermaid)

```mermaid
flowchart TD

%% =========================
%% Level 1 — System Context
%% =========================
subgraph "C4 Level 1: System Context"
direction TB

U["End User<br/>(Patient/User)"]:::actor
C["Consultant/Counselor"]:::actor
A["Admin"]:::actor

WB["Web Browser"]:::client
EB["Browser w/ Extension"]:::client

SPA_CTX["Web App<br/>React SPA (CRA)"]:::frontend
EXT_CTX["Browser Extension<br/>(Chrome-style)"]:::extension
API_CTX["Backend API<br/>Node.js/Express"]:::backend
DB_CTX[("MongoDB")]:::database

EXT_SVC1["Realtime/Chat Gateway<br/>(WebSocket/Socket.IO?)<br/><i>Verify</i>"]:::external
EXT_SVC2["Video Calling Infra<br/>(WebRTC STUN/TURN or Provider?)<br/><i>Verify</i>"]:::external

U -->|"uses"| WB
C -->|"uses"| WB
A -->|"uses"| WB
U -->|"uses"| EB

WB -->|"runs"| SPA_CTX
EB -->|"runs"| SPA_CTX
EB -->|"runs"| EXT_CTX

SPA_CTX -->|"HTTPS (JSON REST)"| API_CTX
EXT_CTX -->|"HTTPS (policy/reporting)"| API_CTX
API_CTX -->|"CRUD"| DB_CTX

SPA_CTX -.->|"WebSocket (chat/signaling?)"| EXT_SVC1
SPA_CTX -.->|"WebRTC media/signaling?"| EXT_SVC2
end

%% =========================
%% Level 2 — Container Diagram (Main)
%% =========================
subgraph "C4 Level 2: Container Diagram (Main Runtime Pieces)"
direction TB

subgraph "Client Device Boundary"
direction TB
B1["User/Admin/Consultant Browser"]:::client
SPA["React SPA (CRA)"]:::frontend
EXT["Browser Extension"]:::extension
B1 -->|"executes"| SPA
B1 -->|"hosts"| EXT
end

subgraph "Public Internet / Delivery"
direction TB
CDN["Static Hosting/CDN<br/>(Vercel or similar)"]:::delivery
end

subgraph "Server Side"
direction TB
API["Express API Server"]:::backend

subgraph "Routing Layer (Express)"
direction TB
R_MAIN["Main API Routes<br/>(routes/routes.js)"]:::backend
R_EXT["Extension Endpoints/Logic<br/>(routes/Extention/main.js)"]:::backend
end

API -->|"mounts"| R_MAIN
API -->|"mounts"| R_EXT

end

subgraph "Data Layer (Private Network Boundary)"
direction TB
MDB[("MongoDB")]:::database
end

%% --- Main flows (explicit protocols) ---
B1 -->|"GET static assets"| CDN
CDN -->|"Serve index.html/js/css"| SPA

SPA -->|"HTTPS (JSON REST)<br/>Auth/Roles/Admin/Assessment/Track/Blockweb"| API
EXT -->|"HTTPS (policy fetch/report)"| API
API -->|"MongoDB driver CRUD"| MDB

%% --- Extension local enforcement ---
EXT -->|"blocks/redirects sites<br/>(client-side enforcement)"| B1

%% --- Optional/Verify: realtime + video ---
WS["WebSocket/Socket.IO<br/>Chat/Signaling<br/><i>Verify</i>"]:::external
STUN["STUN/TURN or Video Provider<br/><i>Verify</i>"]:::external

SPA -.->|"WebSocket (chat/signaling?)"| WS
SPA -.->|"ICE/STUN/TURN or SDK"| STUN
end

%% =========================
%% Level 3 — Component Diagram (Internals)
%% =========================
subgraph "C4 Level 3: Component Diagram (Key Internals)"
direction TB

subgraph "Frontend: React SPA (src/)"
direction TB
FE_INDEX["Entry/Mount<br/>index.jsx"]:::frontend
FE_APP["App Shell / Routing<br/>App.jsx"]:::frontend

subgraph "Pages (src/pages/)"
direction TB
P_AUTH["Auth Pages<br/>Login/Register<br/>+ Consultant variants"]:::frontend
P_ADMIN["Admin Pages<br/>AdminLogin/AdminDashboard"]:::frontend
P_CHAT["Chat Page"]:::frontend
P_MEET["Meet/Video Pages<br/>(Meet/MeetCounc)"]:::frontend
P_ASSESS["Assessment Page"]:::frontend
P_TRACK["Track Page"]:::frontend
P_BLOCK["Blockweb Page"]:::frontend
end

subgraph "Reusable Components (src/components/)"
direction TB
CMP_NAV["Navbar"]:::frontend
CMP_SID_A["Admin Sidebar"]:::frontend
CMP_SID_U["User Sidebar"]:::frontend
CMP_SID_C["Counselor Sidebar"]:::frontend
CMP_JOIN["JoinCall Component"]:::frontend
CMP_VCALL["VideoCall Component"]:::frontend
end

ASSETS["Assets Bundle<br/>(src/assets/)"]:::frontend
UTILS["Utilities<br/>(src/utils/)"]:::frontend
STYLE["Styling Tooling<br/>(Tailwind/PostCSS)"]:::tooling

FE_INDEX -->|"mounts"| FE_APP
FE_APP -->|"routes to"| P_AUTH
FE_APP -->|"routes to"| P_ADMIN
FE_APP -->|"routes to"| P_CHAT
FE_APP -->|"routes to"| P_MEET
FE_APP -->|"routes to"| P_ASSESS
FE_APP -->|"routes to"| P_TRACK
FE_APP -->|"routes to"| P_BLOCK

P_ADMIN -->|"uses"| CMP_NAV
P_ADMIN -->|"uses"| CMP_SID_A
P_CHAT -->|"uses"| CMP_NAV
P_CHAT -->|"uses"| CMP_SID_U
P_MEET -->|"uses"| CMP_JOIN
P_MEET -->|"uses"| CMP_VCALL
P_BLOCK -->|"uses"| CMP_SID_U

FE_APP -->|"imports"| ASSETS
FE_APP -->|"imports"| UTILS
FE_APP -->|"styled by"| STYLE
end

subgraph "Backend: Express API (app.js + routes/)"
direction TB
BE_APP["Express App Entry<br/>app.js"]:::backend
BE_ROUTES["Main Router<br/>routes/routes.js"]:::backend
BE_EXT["Extension Router/Logic<br/>routes/Extention/main.js"]:::backend
BE_DB["MongoDB Connection Layer<br/>mongo.js / mongo1.js"]:::backend

BE_APP -->|"mounts"| BE_ROUTES
BE_APP -->|"mounts"| BE_EXT
BE_ROUTES -->|"CRUD via"| BE_DB
BE_EXT -->|"CRUD via"| BE_DB
end

subgraph "Static Assets / Hosting"
direction TB
PUB["public/ (static)"]:::delivery
PUB_HTML["public/index.html"]:::delivery
PUB_RED["public/_redirects"]:::delivery
PUB_MAN["public/manifest.json"]:::delivery
VERCEL["vercel.json"]:::delivery

PUB -->|"contains"| PUB_HTML
PUB -->|"contains"| PUB_RED
PUB -->|"contains"| PUB_MAN
end

%% Cross-container dependencies (explicit)
FE_APP -->|"HTTPS (JSON REST)"| BE_APP
BE_DB -->|"connects to"| MDB_INT[("MongoDB")]:::database
end

%% =========================
%% Click Events (from component_mapping)
%% =========================
click SPA "https://github.com/lakshaysk106/refrain-addiction/tree/main/src/"
click FE_INDEX "https://github.com/lakshaysk106/refrain-addiction/blob/main/src/index.jsx"
click FE_APP "https://github.com/lakshaysk106/refrain-addiction/blob/main/src/App.jsx"
click P_AUTH "https://github.com/lakshaysk106/refrain-addiction/tree/main/src/pages/"
click P_ADMIN "https://github.com/lakshaysk106/refrain-addiction/tree/main/src/pages/"
click P_CHAT "https://github.com/lakshaysk106/refrain-addiction/blob/main/src/pages/Chat.jsx"
click P_MEET "https://github.com/lakshaysk106/refrain-addiction/blob/main/src/pages/Meet.jsx"
click P_ASSESS "https://github.com/lakshaysk106/refrain-addiction/blob/main/src/pages/Assessment.jsx"
click P_TRACK "https://github.com/lakshaysk106/refrain-addiction/blob/main/src/pages/Track.jsx"
click P_BLOCK "https://github.com/lakshaysk106/refrain-addiction/blob/main/src/pages/Blockweb.jsx"

click CMP_NAV "https://github.com/lakshaysk106/refrain-addiction/blob/main/src/components/Navbar.jsx"
click CMP_SID_A "https://github.com/lakshaysk106/refrain-addiction/blob/main/src/components/Sideadmin.jsx"
click CMP_SID_U "https://github.com/lakshaysk106/refrain-addiction/blob/main/src/components/Sidebar.jsx"
click CMP_SID_C "https://github.com/lakshaysk106/refrain-addiction/blob/main/src/components/Sidecounc.jsx"
click CMP_JOIN "https://github.com/lakshaysk106/refrain-addiction/blob/main/src/components/JoinCall.js"
click CMP_VCALL "https://github.com/lakshaysk106/refrain-addiction/blob/main/src/components/VideoCall.js"

click ASSETS "https://github.com/lakshaysk106/refrain-addiction/tree/main/src/assets/"
click UTILS "https://github.com/lakshaysk106/refrain-addiction/tree/main/src/utils/"

click PUB "https://github.com/lakshaysk106/refrain-addiction/tree/main/public/"
click PUB_HTML "https://github.com/lakshaysk106/refrain-addiction/blob/main/public/index.html"
click PUB_RED "https://github.com/lakshaysk106/refrain-addiction/tree/main/public/_redirects"
click PUB_MAN "https://github.com/lakshaysk106/refrain-addiction/blob/main/public/manifest.json"
click VERCEL "https://github.com/lakshaysk106/refrain-addiction/blob/main/vercel.json"

click BE_APP "https://github.com/lakshaysk106/refrain-addiction/blob/main/app.js"
click BE_ROUTES "https://github.com/lakshaysk106/refrain-addiction/blob/main/routes/routes.js"
click BE_EXT "https://github.com/lakshaysk106/refrain-addiction/blob/main/routes/Extention/main.js"
click BE_DB "https://github.com/lakshaysk106/refrain-addiction/blob/main/mongo.js"
click EXT "https://github.com/lakshaysk106/refrain-addiction/tree/main/routes/Extention/"
click EXT_CTX "https://github.com/lakshaysk106/refrain-addiction/blob/main/routes/Extention/manifest.json"

%% =========================
%% Styles (Color Coding)
%% =========================
classDef actor fill:#ffffff,stroke:#111827,stroke-width:1px,color:#111827
classDef client fill:#dbeafe,stroke:#1d4ed8,stroke-width:1px,color:#0f172a
classDef frontend fill:#bfdbfe,stroke:#2563eb,stroke-width:1px,color:#0f172a
classDef extension fill:#c7d2fe,stroke:#4338ca,stroke-width:1px,color:#0f172a
classDef delivery fill:#e0f2fe,stroke:#0284c7,stroke-width:1px,color:#0f172a
classDef backend fill:#bbf7d0,stroke:#16a34a,stroke-width:1px,color:#052e16
classDef database fill:#fed7aa,stroke:#c2410c,stroke-width:1px,color:#431407
classDef external fill:#e5e7eb,stroke:#6b7280,stroke-width:1px,color:#111827,stroke-dasharray: 4 4
classDef tooling fill:#fef9c3,stroke:#ca8a04,stroke-width:1px,color:#422006
```
