How davidpal3c/campusconnect_next_express works
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: layout.tsx Role-aware routes · deployment.yaml AKS deployment · server.ts Express server · article-route.ts Domain routes
Components 23
Next.js frontend
- App Router shell · Root layout and landing entry point.
client/src/app/layout.tsx - Role-aware routes · Separate admin, user, and admin-auth experiences.
client/src/app/pages/admin/layout.tsx - Shared UI shell · Navigation, headers, sidebars, dialogs, and controls.
client/src/app/components/Sidebar/Sidebar.tsx - Client state · Auth, user, articles, and article-type state.
client/src/app/_utils/auth-context.js - Admin workflows · Users, publishing, audiences, events, and analytics.
client/src/app/components/PageComponents/Admin/Articles/ArticlesDashboard.tsx - User workflows · Personalized dashboard, articles, and events.
client/src/app/components/PageComponents/User/UserDashboard.tsx - Browser integration API · Selected user/admin and image operations.
client/src/app/api/users/articles.ts - Frontend Firebase · SSO and session identity client.
client/src/app/_utils/firebase.ts
Express API
- Express server · Backend process entry point.
server/src/server.ts - Domain routes · Article, event, user, and auth route mounting.
server/src/routes/article-route.ts - Authorization middleware · Protects role-specific backend access.
server/src/middleware/adminAuth-middleware.ts - Domain controllers · Articles, audiences, events, users, academics, and media.
server/src/controllers/articles-controller.ts - API security · Validation, sanitization, rate limits, headers, and cookies.
server/src/utils/inputValidator.ts - Image service · Image controller backed by storage abstraction.
server/src/controllers/image-controller.ts
Data and identity
- Prisma data access · Exclusive PostgreSQL access layer.
server/src/config/prismaClient.ts - PostgreSQL schema · Users, academics, audiences, articles, types, and events.
server/prisma/schema.prisma - Firebase identity · Google/Microsoft SSO and session verification.
server/src/config/firebase.ts - Media storage
server/src/lib/storage.ts
Deployment
- Frontend and API containers · Independently built Node.js services.
client/Dockerfile - AKS deployment · Frontend and backend deployments behind ingress.
k8s/frontend/deployment.yaml - NGINX TLS ingress · cert-manager TLS with Azure DNS.
k8s/ingress/ingress.yaml - CI/CD pipeline · Build, security, registry, and AKS deployment flow.
.github/workflows/deploy.yaml - Helm packaging · Parallel or transitioning deployment packaging.
helm-chart/values.yaml
Connections 24
- 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