# davidpal3c/campusconnect_next_express architecture

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

- Interactive diagram: https://gitdiagram.com/davidpal3c/campusconnect_next_express
- Repository: https://github.com/davidpal3c/campusconnect_next_express

## Overview

#### 1. Purpose and system boundary
CampusConnect is an archived full-stack campus engagement platform for students, alumni, and administrators. It supports role-specific access to articles, events, user administration, academics/audience data, and planned notifications/groups. The deployable system is a separate Next.js frontend and Express API backend, backed by PostgreSQL and Firebase authentication.

#### 2. Application entry points and routing
The frontend uses the Next.js App Router, rooted at `client/src/app/layout.tsx` and `client/src/app/page.tsx`. Role-separated route trees provide distinct admin and user experiences:
- `client/src/app/pages/admin/layout.tsx`
- `client/src/app/pages/user/layout.tsx`
- `client/src/app/pages/auth/admin/page.tsx`

The Express process starts at `server/src/server.ts`; domain routes are mounted from `server/src/routes/`, including `server/src/routes/article-route.ts`, `server/src/routes/events-route.ts`, and `server/src/routes/user-route.ts`.

#### 3. Frontend composition and client state
Shared shell components—navigation, headers, sidebars, dialogs, and reusable controls—form the common UI layer:
- `client/src/app/components/Sidebar/Sidebar.tsx`
- `client/src/app/components/TopBar/TopBar.tsx`
- `client/src/app/components/Header/AdminHeader.tsx`

React contexts hold cross-page client state for authentication, user data, articles, and article types:
- `client/src/app/_utils/auth-context.js`
- `client/src/app/_utils/articles-context.js`
- `client/src/app/_utils/articleTypes-context.js`

Frontend Next API handlers act as a browser-facing integration boundary for selected user/admin and image operations: `client/src/app/api/users/articles.ts`, `client/src/app/api/admin/users/index.ts`, and `client/src/app/api/upload-image.ts`.

#### 4. Role-based product domains
Admin workflows manage user records, article publishing/type/audience selection, events, and analytics surfaces:
- `client/src/app/components/PageComponents/Admin/User/UsersDashboard.tsx`
- `client/src/app/components/PageComponents/Admin/Articles/ArticlesDashboard.tsx`
- `client/src/app/components/PageComponents/Admin/Events/EventEditor.tsx`

Student/user workflows consume personalized dashboard content, articles, and events:
- `client/src/app/components/PageComponents/User/UserDashboard.tsx`
- `client/src/app/components/PageComponents/User/Articles/ArticlesContent.tsx`
- `client/src/app/components/PageComponents/User/Events/EventList.tsx`

Primary control flow is: login/session establishment → role-aware layout/routes → client context/data fetch → API → protected Express domain route → controller → Prisma persistence.

#### 5. API, authorization, and domain processing
The backend separates transport routing, authorization middleware, and controller-level domain operations. Firebase-backed authentication has separate admin and user flows:
- `server/src/routes/adminAuth-route.ts`
- `server/src/routes/userAuth-route.ts`
- `server/src/middleware/adminAuth-middleware.ts`

Controllers implement the main business boundaries for articles, audiences, events, users, academics, and media:
- `server/src/controllers/articles-controller.ts`
- `server/src/controllers/events-controller.ts`
- `server/src/controllers/audience-controller.ts`

Input validation/sanitization, rate limiting, security headers, and secure-cookie handling are centralized infrastructure concerns:
- `server/src/utils/inputValidator.ts`
- `server/src/utils/rateLimiter.ts`
- `server/src/utils/helmet.ts`

#### 6. Data, identity, and media services
PostgreSQL is accessed only through Prisma configuration and schema/migrations, which define evolving entities for users/students, events, articles/types, and related audience/academic data:
- `server/prisma/schema.prisma`
- `server/prisma/migrations/20250129044052_base/migration.sql`
- `server/src/config/prismaClient.ts`

Firebase is configured on both frontend and backend, providing Google/Microsoft SSO and session identity verification:
- `client/src/app/_utils/firebase.ts`
- `server/src/config/firebase.ts`

Image operations are a separate backend capability, with storage abstraction behind the image controller:
- `server/src/controllers/image-controller.ts`
- `server/src/lib/storage.ts`

#### 7. Deployment and runtime infrastructure
Frontend and backend are independently containerized Node.js workloads:
- `client/Dockerfile`
- `server/Dockerfile`

Kubernetes manifests deploy each service behind an NGINX ingress; TLS uses cert-manager/Let's Encrypt and Azure DNS configuration:
- `k8s/frontend/deployment.yaml`
- `k8s/backend/deployment.yaml`
- `k8s/ingress/ingress.yaml`

GitHub Actions drives CI/CD and security/deployment flow toward Azure Container Registry and AKS. Helm chart templates provide a parallel/transitioning packaging path:
- `.github/workflows/deploy.yaml`
- `helm-chart/values.yaml`
- `helm-chart/templates/ingress/ingress.yaml`

Main entry points: [`client/src/app/pages/admin/layout.tsx`](https://github.com/davidpal3c/campusconnect_next_express/blob/dev/client/src/app/pages/admin/layout.tsx) (Role-aware routes), [`k8s/frontend/deployment.yaml`](https://github.com/davidpal3c/campusconnect_next_express/blob/dev/k8s/frontend/deployment.yaml) (AKS deployment), [`server/src/server.ts`](https://github.com/davidpal3c/campusconnect_next_express/blob/dev/server/src/server.ts) (Express server), [`server/src/routes/article-route.ts`](https://github.com/davidpal3c/campusconnect_next_express/blob/dev/server/src/routes/article-route.ts) (Domain routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Next.js frontend"]
  node_next_app["App Router shell<br/>Next.js app<br/>[layout.tsx]"]
  node_role_routes["Role-aware routes<br/>route layouts<br/>[layout.tsx]"]
  node_shared_ui["Shared UI shell<br/>React components<br/>[Sidebar.tsx]"]
  node_client_context["Client state<br/>React contexts<br/>[auth-context.js]"]
  node_admin_workflows["Admin workflows<br/>admin UI"]
  node_user_workflows["User workflows<br/>user UI<br/>[UserDashboard.tsx]"]
  node_next_api["Browser integration API<br/>Next API handlers<br/>[articles.ts]"]
  node_frontend_firebase["Frontend Firebase<br/>auth client<br/>[firebase.ts]"]
end

subgraph group_backend["Express API"]
  node_express_server["Express server<br/>API process<br/>[server.ts]"]
  node_domain_routes["Domain routes<br/>Express routes<br/>[article-route.ts]"]
  node_auth_middleware["Authorization middleware<br/>Firebase auth guard"]
  node_controllers["Domain controllers<br/>business logic"]
  node_api_security["API security<br/>middleware utilities<br/>[inputValidator.ts]"]
  node_image_service["Image service<br/>media capability"]
end

subgraph group_services["Data and identity"]
  node_prisma["Prisma data access<br/>ORM client<br/>[prismaClient.ts]"]
  node_postgres[("PostgreSQL schema<br/>database<br/>[schema.prisma]")]
  node_firebase["Firebase identity<br/>identity provider<br/>[firebase.ts]"]
  node_storage["Media storage<br/>storage abstraction<br/>[storage.ts]"]
end

subgraph group_delivery["Deployment"]
  node_containers["Frontend and API containers<br/>Docker workloads"]
  node_kubernetes{{"AKS deployment<br/>Kubernetes manifests<br/>[deployment.yaml]"}}
  node_ingress["NGINX TLS ingress<br/>Kubernetes ingress<br/>[ingress.yaml]"]
  node_cicd["CI/CD pipeline<br/>GitHub Actions<br/>[deploy.yaml]"]
  node_helm["Helm packaging<br/>Helm chart<br/>[values.yaml]"]
end

node_next_app -->|"selects role routes"| node_role_routes
node_role_routes -->|"uses"| node_shared_ui
node_role_routes -->|"admin experience"| node_admin_workflows
node_role_routes -->|"user experience"| node_user_workflows
node_client_context -->|"supplies state"| node_admin_workflows
node_client_context -->|"supplies state"| node_user_workflows
node_frontend_firebase -->|"establishes session"| node_client_context
node_admin_workflows -->|"requests operations"| node_next_api
node_user_workflows -->|"fetches content"| node_next_api
node_next_api -->|"calls backend API"| node_express_server
node_express_server -->|"applies"| node_api_security
node_express_server -->|"mounts"| node_domain_routes
node_domain_routes -->|"protects routes"| node_auth_middleware
node_auth_middleware -->|"verifies identity"| node_firebase
node_domain_routes -->|"dispatches"| node_controllers
node_controllers -->|"persists through"| node_prisma
node_prisma -->|"reads and writes"| node_postgres
node_controllers -->|"handles media"| node_image_service
node_image_service -->|"stores images"| node_storage
node_containers -->|"deployed as"| node_kubernetes
node_kubernetes -->|"exposed through"| node_ingress
node_cicd -->|"builds images"| node_containers
node_cicd -->|"deploys"| node_kubernetes
node_helm -.->|"packages alternative manifests"| node_kubernetes

click node_next_app "https://github.com/davidpal3c/campusconnect_next_express/blob/dev/client/src/app/layout.tsx"
click node_role_routes "https://github.com/davidpal3c/campusconnect_next_express/blob/dev/client/src/app/pages/admin/layout.tsx"
click node_shared_ui "https://github.com/davidpal3c/campusconnect_next_express/blob/dev/client/src/app/components/Sidebar/Sidebar.tsx"
click node_client_context "https://github.com/davidpal3c/campusconnect_next_express/blob/dev/client/src/app/_utils/auth-context.js"
click node_admin_workflows "https://github.com/davidpal3c/campusconnect_next_express/blob/dev/client/src/app/components/PageComponents/Admin/Articles/ArticlesDashboard.tsx"
click node_user_workflows "https://github.com/davidpal3c/campusconnect_next_express/blob/dev/client/src/app/components/PageComponents/User/UserDashboard.tsx"
click node_next_api "https://github.com/davidpal3c/campusconnect_next_express/blob/dev/client/src/app/api/users/articles.ts"
click node_frontend_firebase "https://github.com/davidpal3c/campusconnect_next_express/blob/dev/client/src/app/_utils/firebase.ts"
click node_express_server "https://github.com/davidpal3c/campusconnect_next_express/blob/dev/server/src/server.ts"
click node_domain_routes "https://github.com/davidpal3c/campusconnect_next_express/blob/dev/server/src/routes/article-route.ts"
click node_auth_middleware "https://github.com/davidpal3c/campusconnect_next_express/blob/dev/server/src/middleware/adminAuth-middleware.ts"
click node_controllers "https://github.com/davidpal3c/campusconnect_next_express/blob/dev/server/src/controllers/articles-controller.ts"
click node_api_security "https://github.com/davidpal3c/campusconnect_next_express/blob/dev/server/src/utils/inputValidator.ts"
click node_image_service "https://github.com/davidpal3c/campusconnect_next_express/blob/dev/server/src/controllers/image-controller.ts"
click node_prisma "https://github.com/davidpal3c/campusconnect_next_express/blob/dev/server/src/config/prismaClient.ts"
click node_postgres "https://github.com/davidpal3c/campusconnect_next_express/blob/dev/server/prisma/schema.prisma"
click node_firebase "https://github.com/davidpal3c/campusconnect_next_express/blob/dev/server/src/config/firebase.ts"
click node_storage "https://github.com/davidpal3c/campusconnect_next_express/blob/dev/server/src/lib/storage.ts"
click node_containers "https://github.com/davidpal3c/campusconnect_next_express/blob/dev/client/Dockerfile"
click node_kubernetes "https://github.com/davidpal3c/campusconnect_next_express/blob/dev/k8s/frontend/deployment.yaml"
click node_ingress "https://github.com/davidpal3c/campusconnect_next_express/blob/dev/k8s/ingress/ingress.yaml"
click node_cicd "https://github.com/davidpal3c/campusconnect_next_express/blob/dev/.github/workflows/deploy.yaml"
click node_helm "https://github.com/davidpal3c/campusconnect_next_express/blob/dev/helm-chart/values.yaml"

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_next_app,node_role_routes,node_shared_ui,node_client_context,node_admin_workflows,node_user_workflows,node_next_api,node_frontend_firebase toneBlue
class node_express_server,node_domain_routes,node_auth_middleware,node_controllers,node_api_security,node_image_service toneAmber
class node_prisma,node_postgres,node_firebase,node_storage toneMint
class node_containers,node_kubernetes,node_ingress,node_cicd,node_helm toneRose
```

## Components

### Next.js frontend

- [App Router shell](https://github.com/davidpal3c/campusconnect_next_express/blob/dev/client/src/app/layout.tsx): Next.js app · Root layout and landing entry point. · `client/src/app/layout.tsx`
- [Role-aware routes](https://github.com/davidpal3c/campusconnect_next_express/blob/dev/client/src/app/pages/admin/layout.tsx): route layouts · Separate admin, user, and admin-auth experiences. · `client/src/app/pages/admin/layout.tsx`
- [Shared UI shell](https://github.com/davidpal3c/campusconnect_next_express/blob/dev/client/src/app/components/Sidebar/Sidebar.tsx): React components · Navigation, headers, sidebars, dialogs, and controls. · `client/src/app/components/Sidebar/Sidebar.tsx`
- [Client state](https://github.com/davidpal3c/campusconnect_next_express/blob/dev/client/src/app/_utils/auth-context.js): React contexts · Auth, user, articles, and article-type state. · `client/src/app/_utils/auth-context.js`
- [Admin workflows](https://github.com/davidpal3c/campusconnect_next_express/blob/dev/client/src/app/components/PageComponents/Admin/Articles/ArticlesDashboard.tsx): admin UI · Users, publishing, audiences, events, and analytics. · `client/src/app/components/PageComponents/Admin/Articles/ArticlesDashboard.tsx`
- [User workflows](https://github.com/davidpal3c/campusconnect_next_express/blob/dev/client/src/app/components/PageComponents/User/UserDashboard.tsx): user UI · Personalized dashboard, articles, and events. · `client/src/app/components/PageComponents/User/UserDashboard.tsx`
- [Browser integration API](https://github.com/davidpal3c/campusconnect_next_express/blob/dev/client/src/app/api/users/articles.ts): Next API handlers · Selected user/admin and image operations. · `client/src/app/api/users/articles.ts`
- [Frontend Firebase](https://github.com/davidpal3c/campusconnect_next_express/blob/dev/client/src/app/_utils/firebase.ts): auth client · SSO and session identity client. · `client/src/app/_utils/firebase.ts`

### Express API

- [Express server](https://github.com/davidpal3c/campusconnect_next_express/blob/dev/server/src/server.ts): API process · Backend process entry point. · `server/src/server.ts`
- [Domain routes](https://github.com/davidpal3c/campusconnect_next_express/blob/dev/server/src/routes/article-route.ts): Express routes · Article, event, user, and auth route mounting. · `server/src/routes/article-route.ts`
- [Authorization middleware](https://github.com/davidpal3c/campusconnect_next_express/blob/dev/server/src/middleware/adminAuth-middleware.ts): Firebase auth guard · Protects role-specific backend access. · `server/src/middleware/adminAuth-middleware.ts`
- [Domain controllers](https://github.com/davidpal3c/campusconnect_next_express/blob/dev/server/src/controllers/articles-controller.ts): business logic · Articles, audiences, events, users, academics, and media. · `server/src/controllers/articles-controller.ts`
- [API security](https://github.com/davidpal3c/campusconnect_next_express/blob/dev/server/src/utils/inputValidator.ts): middleware utilities · Validation, sanitization, rate limits, headers, and cookies. · `server/src/utils/inputValidator.ts`
- [Image service](https://github.com/davidpal3c/campusconnect_next_express/blob/dev/server/src/controllers/image-controller.ts): media capability · Image controller backed by storage abstraction. · `server/src/controllers/image-controller.ts`

### Data and identity

- [Prisma data access](https://github.com/davidpal3c/campusconnect_next_express/blob/dev/server/src/config/prismaClient.ts): ORM client · Exclusive PostgreSQL access layer. · `server/src/config/prismaClient.ts`
- [PostgreSQL schema](https://github.com/davidpal3c/campusconnect_next_express/blob/dev/server/prisma/schema.prisma): database · Users, academics, audiences, articles, types, and events. · `server/prisma/schema.prisma`
- [Firebase identity](https://github.com/davidpal3c/campusconnect_next_express/blob/dev/server/src/config/firebase.ts): identity provider · Google/Microsoft SSO and session verification. · `server/src/config/firebase.ts`
- [Media storage](https://github.com/davidpal3c/campusconnect_next_express/blob/dev/server/src/lib/storage.ts): storage abstraction · `server/src/lib/storage.ts`

### Deployment

- [Frontend and API containers](https://github.com/davidpal3c/campusconnect_next_express/blob/dev/client/Dockerfile): Docker workloads · Independently built Node.js services. · `client/Dockerfile`
- [AKS deployment](https://github.com/davidpal3c/campusconnect_next_express/blob/dev/k8s/frontend/deployment.yaml): Kubernetes manifests · Frontend and backend deployments behind ingress. · `k8s/frontend/deployment.yaml`
- [NGINX TLS ingress](https://github.com/davidpal3c/campusconnect_next_express/blob/dev/k8s/ingress/ingress.yaml): Kubernetes ingress · cert-manager TLS with Azure DNS. · `k8s/ingress/ingress.yaml`
- [CI/CD pipeline](https://github.com/davidpal3c/campusconnect_next_express/blob/dev/.github/workflows/deploy.yaml): GitHub Actions · Build, security, registry, and AKS deployment flow. · `.github/workflows/deploy.yaml`
- [Helm packaging](https://github.com/davidpal3c/campusconnect_next_express/blob/dev/helm-chart/values.yaml): Helm chart · Parallel or transitioning deployment packaging. · `helm-chart/values.yaml`

## Connections

- App Router shell → Role-aware routes: selects role routes
- Role-aware routes → Shared UI shell: uses
- Role-aware routes → Admin workflows: admin experience
- Role-aware routes → User workflows: user experience
- Client state → Admin workflows: supplies state
- Client state → User workflows: supplies state
- Frontend Firebase → Client state: establishes session
- Admin workflows → Browser integration API: requests operations
- User workflows → Browser integration API: fetches content
- Browser integration API → Express server: calls backend API
- Express server → API security: applies
- Express server → Domain routes: mounts
- Domain routes → Authorization middleware: protects routes
- Authorization middleware → Firebase identity: verifies identity
- Domain routes → Domain controllers: dispatches
- Domain controllers → Prisma data access: persists through
- Prisma data access → PostgreSQL schema: reads and writes
- Domain controllers → Image service: handles media
- Image service → Media storage: stores images
- Frontend and API containers → AKS deployment: deployed as
- AKS deployment → NGINX TLS ingress: exposed through
- CI/CD pipeline → Frontend and API containers: builds images
- CI/CD pipeline → AKS deployment: deploys
- Helm packaging → AKS deployment: packages alternative manifests
