# mubasshirahin/austwise architecture

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

- Interactive diagram: https://gitdiagram.com/mubasshirahin/austwise
- Repository: https://github.com/mubasshirahin/austwise

## Overview

#### Purpose and Runtime Shape
AUSTWise is a PWA/student utility platform for AUST: academic routines and tracking, campus/life tools, collaborative/community features, study vaults, messaging, and account services. It is a React SPA built by Vite and served with a custom Node HTTP server, which also exposes APIs and WebSockets. Primary entry points: `src/main.jsx`, `src/App.jsx`, `server/dev.mjs`.

#### Client Application Shell
`App.jsx` is the route/page composition boundary; shared navigation and responsive shell surround feature pages. Application-wide UI state is supplied through React contexts for identity, themes, routines, and Pomodoro state. Key paths: `src/App.jsx`, `src/context/AuthContext.jsx`, `src/layout/Sidebar.jsx`.

#### Feature-Domain Modules
The client is organized as independently rendered feature directories rather than a generic backend-driven CMS. Major domains include dashboard/planning, campus operations, analytics, vault, marketplace/community, and lifestyle tools. Feature pages combine local components, client storage/API utilities, and domain-specific CSS. Representative roots: `src/features/dashboard/DashboardPage.jsx`, `src/features/campus/CampusPage.jsx`, `src/features/vault/VaultPage.jsx`.

#### Academic Planning and Insight Flow
Routine context and planner/dashboard components drive schedule, attendance, deadlines, exam flow, and weekly planning. Analytics modules render CGPA, semester progress, course feedback, prerequisites, and departmental heatmaps. Course and route datasets are bundled where suitable, while runtime campus/course records may come from the server/database. Paths: `src/context/RoutineProvider.jsx`, `src/features/dashboard/RoutineAttendanceTracker.jsx`, `src/features/analytics/AnalyticsPage.jsx`.

#### Server API, Identity, and Authorization
The zero-framework Node server is the API router, SPA host in production, static/data integration point, and environment gate for dev-only APIs. Authentication uses JWTs in HttpOnly/SameSite cookies with bcrypt password hashing; middleware and rate limiting enforce request boundaries. Role/admin functions are backed by dedicated persistence modules. Paths: `server/dev.mjs`, `server/auth.mjs`, `server/middleware.mjs`, `server/rateLimiter.mjs`, `server/roleAppDB.mjs`.

#### Persistence and Sensitive Data Boundary
SQL Server is the intended relational store, accessed through `mssql`/Prisma integration and schema definitions; JSON-backed modules provide runtime/fallback persistence for users, messages, library activity, marketplace-style stores, and feature data. Password-vault records cross an explicit encryption boundary using AES-256-GCM. Paths: `server/db.mjs`, `server/prisma/schema.prisma`, `server/jsonDB.mjs`, `server/passwordCrypto.mjs`, `server/passwordVaultDB.mjs`.

#### Real-Time and External Integrations
WebSocket infrastructure supports live messaging and related notifications; client hooks consume socket and notification state. Telegram notifier/scheduler modules provide outbound notification capability. Social OAuth, Google Drive-related client utilities, payments, and routine extraction are integration boundaries requiring environment/configured credentials or service behavior. Paths: `server/wsServer.mjs`, `src/hooks/useWebSocket.js`, `server/telegramNotifier.mjs`, `server/payment.mjs`.

#### Deployment and Operational Boundaries
Development runs Vite HMR plus the API server on port 5174. Production builds the SPA and serves it from Node; TLS is explicitly terminated by a reverse proxy, which must forward WebSocket upgrades. SQL Server credentials, JWT secret, vault crypto key, cookie security, and CORS origins are environment-controlled. Deployment descriptors: `package.json`, `render.yaml`, `vercel.json`.

Main entry points: [`server/dev.mjs`](https://github.com/mubasshirahin/austwise/blob/main/server/dev.mjs) (Node HTTP server), [`src/App.jsx`](https://github.com/mubasshirahin/austwise/blob/main/src/App.jsx) (App shell & routes), [`src/features/dashboard/DashboardPage.jsx`](https://github.com/mubasshirahin/austwise/blob/main/src/features/dashboard/DashboardPage.jsx) (Dashboard & planner), [`server/wsServer.mjs`](https://github.com/mubasshirahin/austwise/blob/main/server/wsServer.mjs) (WebSocket server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["React PWA Client"]
  node_entry["Client entry<br/>React bootstrap<br/>[main.jsx]"]
  node_app["App shell &amp; routes<br/>route composition<br/>[App.jsx]"]
  node_authctx["Identity context<br/>React context<br/>[AuthContext.jsx]"]
  node_sidebar["Sidebar navigation<br/>shared layout<br/>[Sidebar.jsx]"]
  node_routine["Routine state<br/>React context"]
  node_wsclient["Socket client hook<br/>React hook<br/>[useWebSocket.js]"]
end

subgraph group_domains["Client Domains"]
  node_dashboard["Dashboard &amp; planner<br/>feature page<br/>[DashboardPage.jsx]"]
  node_attendance["Routine attendance<br/>planner component"]
  node_campus["Campus operations<br/>feature page<br/>[CampusPage.jsx]"]
  node_analytics["Academic analytics<br/>feature page<br/>[AnalyticsPage.jsx]"]
  node_vault["Study vault<br/>feature page<br/>[VaultPage.jsx]"]
end

subgraph group_server["Node API Runtime"]
  node_http{{"Node HTTP server<br/>[dev.mjs]"}}
  node_auth["Authentication<br/>JWT cookie auth<br/>[auth.mjs]"]
  node_middleware["Request protection<br/>middleware<br/>[middleware.mjs]"]
  node_ratelimit["Rate limiter<br/>request guard<br/>[rateLimiter.mjs]"]
end

subgraph group_data["Persistence &amp; Security"]
  node_sqldb[("SQL Server / Prisma<br/>relational persistence<br/>[db.mjs]")]
  node_schema["Prisma schema<br/>data schema<br/>[schema.prisma]"]
  node_jsondb[("JSON feature stores<br/>fallback persistence<br/>[jsonDB.mjs]")]
  node_roledb[("Role/admin store<br/>authorization persistence<br/>[roleAppDB.mjs]")]
  node_vaultdb[("Password vault store<br/>encrypted persistence")]
  node_crypto["Vault encryption<br/>AES-256-GCM<br/>[passwordCrypto.mjs]"]
end

subgraph group_integrations["Realtime &amp; External Services"]
  node_wsserver{{"WebSocket server<br/>realtime gateway<br/>[wsServer.mjs]"}}
  node_telegram["Telegram notifications<br/>outbound notifier"]
  node_payments["Payment integration<br/>external service boundary<br/>[payment.mjs]"]
end

node_entry -->|"mounts"| node_app
node_app -->|"uses"| node_authctx
node_app -->|"renders"| node_sidebar
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_campus
node_app -->|"routes to"| node_analytics
node_app -->|"routes to"| node_vault
node_dashboard -->|"consumes"| node_routine
node_dashboard -->|"includes"| node_attendance
node_analytics -.->|"reads runtime data"| node_http
node_campus -.->|"uses APIs"| node_http
node_vault -.->|"uses APIs"| node_http
node_wsclient -->|"WebSocket"| node_wsserver
node_http -->|"applies"| node_middleware
node_middleware -->|"validates identity"| node_auth
node_http -->|"limits requests"| node_ratelimit
node_auth -->|"loads roles"| node_roledb
node_http -->|"queries"| node_sqldb
node_sqldb -->|"defined by"| node_schema
node_http -->|"uses fallback stores"| node_jsondb
node_http -->|"stores vault records"| node_vaultdb
node_vaultdb -->|"encrypts through"| node_crypto
node_http -->|"hosts"| node_wsserver
node_wsserver -.->|"persists messages"| node_jsondb
node_http -.->|"sends notifications"| node_telegram
node_http -.->|"initiates payments"| node_payments

click node_entry "https://github.com/mubasshirahin/austwise/blob/main/src/main.jsx"
click node_app "https://github.com/mubasshirahin/austwise/blob/main/src/App.jsx"
click node_authctx "https://github.com/mubasshirahin/austwise/blob/main/src/context/AuthContext.jsx"
click node_sidebar "https://github.com/mubasshirahin/austwise/blob/main/src/layout/Sidebar.jsx"
click node_routine "https://github.com/mubasshirahin/austwise/blob/main/src/context/RoutineProvider.jsx"
click node_dashboard "https://github.com/mubasshirahin/austwise/blob/main/src/features/dashboard/DashboardPage.jsx"
click node_attendance "https://github.com/mubasshirahin/austwise/blob/main/src/features/dashboard/RoutineAttendanceTracker.jsx"
click node_campus "https://github.com/mubasshirahin/austwise/blob/main/src/features/campus/CampusPage.jsx"
click node_analytics "https://github.com/mubasshirahin/austwise/blob/main/src/features/analytics/AnalyticsPage.jsx"
click node_vault "https://github.com/mubasshirahin/austwise/blob/main/src/features/vault/VaultPage.jsx"
click node_wsclient "https://github.com/mubasshirahin/austwise/blob/main/src/hooks/useWebSocket.js"
click node_http "https://github.com/mubasshirahin/austwise/blob/main/server/dev.mjs"
click node_auth "https://github.com/mubasshirahin/austwise/blob/main/server/auth.mjs"
click node_middleware "https://github.com/mubasshirahin/austwise/blob/main/server/middleware.mjs"
click node_ratelimit "https://github.com/mubasshirahin/austwise/blob/main/server/rateLimiter.mjs"
click node_wsserver "https://github.com/mubasshirahin/austwise/blob/main/server/wsServer.mjs"
click node_sqldb "https://github.com/mubasshirahin/austwise/blob/main/server/db.mjs"
click node_schema "https://github.com/mubasshirahin/austwise/blob/main/server/prisma/schema.prisma"
click node_jsondb "https://github.com/mubasshirahin/austwise/blob/main/server/jsonDB.mjs"
click node_roledb "https://github.com/mubasshirahin/austwise/blob/main/server/roleAppDB.mjs"
click node_vaultdb "https://github.com/mubasshirahin/austwise/blob/main/server/passwordVaultDB.mjs"
click node_crypto "https://github.com/mubasshirahin/austwise/blob/main/server/passwordCrypto.mjs"
click node_telegram "https://github.com/mubasshirahin/austwise/blob/main/server/telegramNotifier.mjs"
click node_payments "https://github.com/mubasshirahin/austwise/blob/main/server/payment.mjs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_entry,node_app,node_authctx,node_sidebar,node_routine,node_wsclient toneBlue
class node_dashboard,node_attendance,node_campus,node_analytics,node_vault toneAmber
class node_http,node_auth,node_middleware,node_ratelimit toneMint
class node_sqldb,node_schema,node_jsondb,node_roledb,node_vaultdb,node_crypto toneRose
class node_wsserver,node_telegram,node_payments toneIndigo
```

## Components

### React PWA Client

Vite-built single-page application.

- [Client entry](https://github.com/mubasshirahin/austwise/blob/main/src/main.jsx): React bootstrap · `src/main.jsx`
- [App shell & routes](https://github.com/mubasshirahin/austwise/blob/main/src/App.jsx): route composition · Shared responsive navigation surrounds feature pages. · `src/App.jsx`
- [Identity context](https://github.com/mubasshirahin/austwise/blob/main/src/context/AuthContext.jsx): React context · `src/context/AuthContext.jsx`
- [Sidebar navigation](https://github.com/mubasshirahin/austwise/blob/main/src/layout/Sidebar.jsx): shared layout · `src/layout/Sidebar.jsx`
- [Routine state](https://github.com/mubasshirahin/austwise/blob/main/src/context/RoutineProvider.jsx): React context · Drives planning, schedules, and attendance state. · `src/context/RoutineProvider.jsx`
- [Socket client hook](https://github.com/mubasshirahin/austwise/blob/main/src/hooks/useWebSocket.js): React hook · `src/hooks/useWebSocket.js`

### Client Domains

- [Dashboard & planner](https://github.com/mubasshirahin/austwise/blob/main/src/features/dashboard/DashboardPage.jsx): feature page · `src/features/dashboard/DashboardPage.jsx`
- [Routine attendance](https://github.com/mubasshirahin/austwise/blob/main/src/features/dashboard/RoutineAttendanceTracker.jsx): planner component · `src/features/dashboard/RoutineAttendanceTracker.jsx`
- [Campus operations](https://github.com/mubasshirahin/austwise/blob/main/src/features/campus/CampusPage.jsx): feature page · `src/features/campus/CampusPage.jsx`
- [Academic analytics](https://github.com/mubasshirahin/austwise/blob/main/src/features/analytics/AnalyticsPage.jsx): feature page · CGPA, progress, feedback, prerequisites, and heatmaps. · `src/features/analytics/AnalyticsPage.jsx`
- [Study vault](https://github.com/mubasshirahin/austwise/blob/main/src/features/vault/VaultPage.jsx): feature page · `src/features/vault/VaultPage.jsx`

### Node API Runtime

Hosts production SPA, APIs, and sockets.

- [Node HTTP server](https://github.com/mubasshirahin/austwise/blob/main/server/dev.mjs): API router & SPA host · Dev API gate and production static host. · `server/dev.mjs`
- [Authentication](https://github.com/mubasshirahin/austwise/blob/main/server/auth.mjs): JWT cookie auth · Uses HttpOnly/SameSite JWT cookies and bcrypt passwords. · `server/auth.mjs`
- [Request protection](https://github.com/mubasshirahin/austwise/blob/main/server/middleware.mjs): middleware · Authorization and request-boundary enforcement. · `server/middleware.mjs`
- [Rate limiter](https://github.com/mubasshirahin/austwise/blob/main/server/rateLimiter.mjs): request guard · `server/rateLimiter.mjs`

### Persistence & Security

- [SQL Server / Prisma](https://github.com/mubasshirahin/austwise/blob/main/server/db.mjs): relational persistence · Intended relational store and schema boundary. · `server/db.mjs`
- [Prisma schema](https://github.com/mubasshirahin/austwise/blob/main/server/prisma/schema.prisma): data schema · `server/prisma/schema.prisma`
- [JSON feature stores](https://github.com/mubasshirahin/austwise/blob/main/server/jsonDB.mjs): fallback persistence · Runtime stores for users, messages, library, marketplace, and features. · `server/jsonDB.mjs`
- [Role/admin store](https://github.com/mubasshirahin/austwise/blob/main/server/roleAppDB.mjs): authorization persistence · `server/roleAppDB.mjs`
- [Password vault store](https://github.com/mubasshirahin/austwise/blob/main/server/passwordVaultDB.mjs): encrypted persistence · Vault records cross AES-256-GCM encryption. · `server/passwordVaultDB.mjs`
- [Vault encryption](https://github.com/mubasshirahin/austwise/blob/main/server/passwordCrypto.mjs): AES-256-GCM · `server/passwordCrypto.mjs`

### Realtime & External Services

- [WebSocket server](https://github.com/mubasshirahin/austwise/blob/main/server/wsServer.mjs): realtime gateway · Live messaging and notification transport. · `server/wsServer.mjs`
- [Telegram notifications](https://github.com/mubasshirahin/austwise/blob/main/server/telegramNotifier.mjs): outbound notifier · `server/telegramNotifier.mjs`
- [Payment integration](https://github.com/mubasshirahin/austwise/blob/main/server/payment.mjs): external service boundary · `server/payment.mjs`

## Connections

- Client entry → App shell & routes: mounts
- App shell & routes → Identity context: uses
- App shell & routes → Sidebar navigation: renders
- App shell & routes → Dashboard & planner: routes to
- App shell & routes → Campus operations: routes to
- App shell & routes → Academic analytics: routes to
- App shell & routes → Study vault: routes to
- Dashboard & planner → Routine state: consumes
- Dashboard & planner → Routine attendance: includes
- Academic analytics → Node HTTP server: reads runtime data
- Campus operations → Node HTTP server: uses APIs
- Study vault → Node HTTP server: uses APIs
- Socket client hook → WebSocket server: WebSocket
- Node HTTP server → Request protection: applies
- Request protection → Authentication: validates identity
- Node HTTP server → Rate limiter: limits requests
- Authentication → Role/admin store: loads roles
- Node HTTP server → SQL Server / Prisma: queries
- SQL Server / Prisma → Prisma schema: defined by
- Node HTTP server → JSON feature stores: uses fallback stores
- Node HTTP server → Password vault store: stores vault records
- Password vault store → Vault encryption: encrypts through
- Node HTTP server → WebSocket server: hosts
- WebSocket server → JSON feature stores: persists messages
- Node HTTP server → Telegram notifications: sends notifications
- Node HTTP server → Payment integration: initiates payments
