# ayman2162k7/saasc architecture

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

- Interactive diagram: https://gitdiagram.com/ayman2162k7/saasc
- Repository: https://github.com/ayman2162k7/saasc

## Overview

saasc is a campus forum with student and administrator experiences. A user registers or logs in, then reaches a protected department feed to create posts, comment, or report content; administrators review reports and manage posts, users, and banned words. The React client calls an Express API backed by PostgreSQL, while authenticated Socket.IO events provide live feed and moderation updates. The README gives no further product detail, so major capabilities are represented where supported by sampled routes and client modules; unsampled route behavior is not expanded.

Main entry points: [`frontend/src/App.jsx`](https://github.com/ayman2162k7/saasc/blob/main/frontend/src/App.jsx) (App routing), [`backend/routes/posts.js`](https://github.com/ayman2162k7/saasc/blob/main/backend/routes/posts.js) (Posts and reports), [`frontend/src/components/StudentFeed.jsx`](https://github.com/ayman2162k7/saasc/blob/main/frontend/src/components/StudentFeed.jsx) (Student feed), [`backend/routes/admin.js`](https://github.com/ayman2162k7/saasc/blob/main/backend/routes/admin.js) (Admin controls)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_app["App routing<br/>[App.jsx]"]
  node_authui["Auth screens"]
  node_authstate["Session context<br/>[AuthContext.jsx]"]
  node_guard["Route guard<br/>[ProtectedRoute.jsx]"]
  node_navbar["Navigation<br/>[Navbar.jsx]"]
  node_feed["Student feed<br/>[StudentFeed.jsx]"]
  node_composer["Post composer<br/>[PostComposer.jsx]"]
  node_postcard["Post interactions<br/>[PostCard.jsx]"]
  node_dashboard["Admin dashboard<br/>[AdminDashboard.jsx]"]
  node_socketclient["Realtime client<br/>[socket.js]"]
end

subgraph group_api["API and access"]
  node_server["HTTP and socket server<br/>[server.js]"]
  node_authroutes["Authentication API<br/>[auth.js]"]
  node_authmw["Token and role checks<br/>[auth.js]"]
end

subgraph group_forum["Forum and moderation"]
  node_postroutes["Posts and reports<br/>[posts.js]"]
  node_adminroutes["Admin controls<br/>[admin.js]"]
end

subgraph group_state["Persistence and realtime"]
  node_dbpool["Database pool<br/>[db.js]"]
  node_postgres[("Forum database<br/>[schema.sql]")]
  node_socketserver["Realtime rooms<br/>[server.js]"]
end

node_visitor(("Campus user"))

node_visitor -->|"uses"| node_app
node_app -->|"reads session"| node_authstate
node_app -->|"routes to"| node_authui
node_app -->|"protects routes"| node_guard
node_app -->|"renders"| node_navbar
node_app -->|"routes to"| node_feed
node_app -->|"routes to"| node_dashboard
node_authui -->|"authenticates via"| node_authstate
node_guard -->|"checks access"| node_authstate
node_authstate -->|"calls auth API"| node_authroutes
node_feed -->|"loads posts"| node_postroutes
node_feed -->|"connects and listens"| node_socketclient
node_feed -->|"renders"| node_composer
node_feed -->|"renders"| node_postcard
node_composer -.->|"submits posts"| node_postroutes
node_postcard -.->|"post actions"| node_postroutes
node_dashboard -->|"manages content"| node_adminroutes
node_dashboard -.->|"receives live updates"| node_socketclient
node_server -->|"mounts route"| node_authroutes
node_server -->|"mounts route"| node_postroutes
node_server -->|"mounts route"| node_adminroutes
node_server -->|"configures"| node_socketserver
node_authroutes -->|"verifies profile token"| node_authmw
node_adminroutes -->|"checks roles"| node_authmw
node_postroutes -->|"checks tokens and roles"| node_authmw
node_authroutes -->|"queries"| node_dbpool
node_postroutes -->|"queries and updates"| node_dbpool
node_adminroutes -->|"queries and updates"| node_dbpool
node_dbpool -.->|"connects to"| node_postgres
node_adminroutes -->|"emits moderation events"| node_socketserver
node_socketclient -->|"opens authenticated connection"| node_socketserver

click node_app "https://github.com/ayman2162k7/saasc/blob/main/frontend/src/App.jsx"
click node_authui "https://github.com/ayman2162k7/saasc/tree/main/frontend/src/pages"
click node_authstate "https://github.com/ayman2162k7/saasc/blob/main/frontend/src/context/AuthContext.jsx"
click node_guard "https://github.com/ayman2162k7/saasc/blob/main/frontend/src/components/ProtectedRoute.jsx"
click node_navbar "https://github.com/ayman2162k7/saasc/blob/main/frontend/src/components/Navbar.jsx"
click node_feed "https://github.com/ayman2162k7/saasc/blob/main/frontend/src/components/StudentFeed.jsx"
click node_composer "https://github.com/ayman2162k7/saasc/blob/main/frontend/src/components/PostComposer.jsx"
click node_postcard "https://github.com/ayman2162k7/saasc/blob/main/frontend/src/components/PostCard.jsx"
click node_dashboard "https://github.com/ayman2162k7/saasc/blob/main/frontend/src/components/AdminDashboard.jsx"
click node_socketclient "https://github.com/ayman2162k7/saasc/blob/main/frontend/src/services/socket.js"
click node_server "https://github.com/ayman2162k7/saasc/blob/main/backend/server.js"
click node_authroutes "https://github.com/ayman2162k7/saasc/blob/main/backend/routes/auth.js"
click node_authmw "https://github.com/ayman2162k7/saasc/blob/main/backend/middleware/auth.js"
click node_postroutes "https://github.com/ayman2162k7/saasc/blob/main/backend/routes/posts.js"
click node_adminroutes "https://github.com/ayman2162k7/saasc/blob/main/backend/routes/admin.js"
click node_dbpool "https://github.com/ayman2162k7/saasc/blob/main/backend/db.js"
click node_postgres "https://github.com/ayman2162k7/saasc/blob/main/database/schema.sql"
click node_socketserver "https://github.com/ayman2162k7/saasc/blob/main/backend/server.js"

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_app,node_authui,node_authstate,node_guard,node_navbar,node_feed,node_composer,node_postcard,node_dashboard,node_socketclient,node_visitor toneBlue
class node_server,node_authroutes,node_authmw toneAmber
class node_postroutes,node_adminroutes toneMint
class node_dbpool,node_postgres,node_socketserver toneRose
```

## Components

### Web client

- [App routing](https://github.com/ayman2162k7/saasc/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Auth screens](https://github.com/ayman2162k7/saasc/tree/main/frontend/src/pages): `frontend/src/pages`
- [Session context](https://github.com/ayman2162k7/saasc/blob/main/frontend/src/context/AuthContext.jsx): `frontend/src/context/AuthContext.jsx`
- [Route guard](https://github.com/ayman2162k7/saasc/blob/main/frontend/src/components/ProtectedRoute.jsx): `frontend/src/components/ProtectedRoute.jsx`
- [Navigation](https://github.com/ayman2162k7/saasc/blob/main/frontend/src/components/Navbar.jsx): `frontend/src/components/Navbar.jsx`
- [Student feed](https://github.com/ayman2162k7/saasc/blob/main/frontend/src/components/StudentFeed.jsx): `frontend/src/components/StudentFeed.jsx`
- [Post composer](https://github.com/ayman2162k7/saasc/blob/main/frontend/src/components/PostComposer.jsx): `frontend/src/components/PostComposer.jsx`
- [Post interactions](https://github.com/ayman2162k7/saasc/blob/main/frontend/src/components/PostCard.jsx): `frontend/src/components/PostCard.jsx`
- [Admin dashboard](https://github.com/ayman2162k7/saasc/blob/main/frontend/src/components/AdminDashboard.jsx): `frontend/src/components/AdminDashboard.jsx`
- [Realtime client](https://github.com/ayman2162k7/saasc/blob/main/frontend/src/services/socket.js): `frontend/src/services/socket.js`

### API and access

- [HTTP and socket server](https://github.com/ayman2162k7/saasc/blob/main/backend/server.js): `backend/server.js`
- [Authentication API](https://github.com/ayman2162k7/saasc/blob/main/backend/routes/auth.js): `backend/routes/auth.js`
- [Token and role checks](https://github.com/ayman2162k7/saasc/blob/main/backend/middleware/auth.js): `backend/middleware/auth.js`

### Forum and moderation

- [Posts and reports](https://github.com/ayman2162k7/saasc/blob/main/backend/routes/posts.js): `backend/routes/posts.js`
- [Admin controls](https://github.com/ayman2162k7/saasc/blob/main/backend/routes/admin.js): `backend/routes/admin.js`

### Persistence and realtime

- [Database pool](https://github.com/ayman2162k7/saasc/blob/main/backend/db.js): `backend/db.js`
- [Forum database](https://github.com/ayman2162k7/saasc/blob/main/database/schema.sql): `database/schema.sql`
- [Realtime rooms](https://github.com/ayman2162k7/saasc/blob/main/backend/server.js): `backend/server.js`

### Other components

- **Campus user**

## Connections

- Campus user → App routing: uses
- App routing → Session context: reads session (evidence: `frontend/src/App.jsx`)
- App routing → Auth screens: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Route guard: protects routes (evidence: `frontend/src/App.jsx`)
- App routing → Navigation: renders (evidence: `frontend/src/App.jsx`)
- App routing → Student feed: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Admin dashboard: routes to (evidence: `frontend/src/App.jsx`)
- Auth screens → Session context: authenticates via (evidence: `frontend/src/pages/Login.jsx`)
- Route guard → Session context: checks access (evidence: `frontend/src/components/ProtectedRoute.jsx`)
- Session context → Authentication API: calls auth API (evidence: `frontend/src/context/AuthContext.jsx`)
- Student feed → Posts and reports: loads posts (evidence: `frontend/src/components/StudentFeed.jsx`)
- Student feed → Realtime client: connects and listens (evidence: `frontend/src/components/StudentFeed.jsx`)
- Student feed → Post composer: renders (evidence: `frontend/src/components/StudentFeed.jsx`)
- Student feed → Post interactions: renders (evidence: `frontend/src/components/StudentFeed.jsx`)
- Post composer → Posts and reports: submits posts
- Post interactions → Posts and reports: post actions
- Admin dashboard → Admin controls: manages content (evidence: `frontend/src/components/AdminDashboard.jsx`)
- Admin dashboard → Realtime client: receives live updates (evidence: `frontend/src/components/AdminDashboard.jsx`)
- HTTP and socket server → Authentication API: mounts route (evidence: `backend/server.js`)
- HTTP and socket server → Posts and reports: mounts route (evidence: `backend/server.js`)
- HTTP and socket server → Admin controls: mounts route (evidence: `backend/server.js`)
- HTTP and socket server → Realtime rooms: configures (evidence: `backend/server.js`)
- Authentication API → Token and role checks: verifies profile token (evidence: `backend/routes/auth.js`)
- Admin controls → Token and role checks: checks roles (evidence: `backend/routes/admin.js`)
- Posts and reports → Token and role checks: checks tokens and roles (evidence: `backend/routes/posts.js`)
- Authentication API → Database pool: queries (evidence: `backend/routes/auth.js`)
- Posts and reports → Database pool: queries and updates (evidence: `backend/routes/posts.js`)
- Admin controls → Database pool: queries and updates (evidence: `backend/routes/admin.js`)
- Database pool → Forum database: connects to
- Admin controls → Realtime rooms: emits moderation events (evidence: `backend/routes/admin.js`)
- Realtime client → Realtime rooms: opens authenticated connection (evidence: `frontend/src/services/socket.js`)
