# coderayushraj-png/campus-connect architecture

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

- Interactive diagram: https://gitdiagram.com/coderayushraj-png/campus-connect
- Repository: https://github.com/coderayushraj-png/campus-connect

## Overview

1. **Top-level shape**
   - This repo is a **client-heavy full-stack campus platform**: a React/Vite frontend, a Supabase backend for auth/data/storage/realtime, and a small server/edge-function layer for automation and AI-related workflows.
   - The app is organized into three major experiences: **auth**, **student portal**, and **admin portal**.

2. **Frontend shell**
   - `src/main.jsx`, `src/App.jsx`, `src/index.css`, and `vite.config.ts` form the browser app entry and build pipeline.
   - The UI appears to use a **route-grouped app structure** under `src/app/`, with separate layouts for `student` and `admin`, and dedicated login/signup screens under `(auth)`.
   - `vercel.json` indicates production deployment is intended to be served as a frontend app on Vercel.

3. **Route and role boundaries**
   - Authentication pages live in `src/app/(auth)/login` and `signup`.
   - Student-facing pages are grouped under `src/app/(student)` and include dashboard, notes, events, placement, forum, notices, clubs, lost-found, deadlines, profile, and settings.
   - Admin-only pages live under `src/app/admin` and cover dashboard, analytics, notices, placements, events, clubs, and users.
   - `src/app/(student)/layout.jsx` and `src/app/admin/layout.jsx` are the main boundary points for shared navigation and role-specific shell UI.

4. **Cross-cutting UI components**
   - `src/components/AIBuddy.jsx` is a persistent AI assistant component, likely embedded across the app shell rather than tied to a single page.
   - `src/components/NotificationBell.jsx` is the global notification entry point for unread counts and alerts.
   - These are the main shared interaction surfaces connecting multiple subsystems.

5. **Supabase is the core backend**
   - `src/lib/supabase.js` is the central client used by the frontend to talk to Supabase.
   - The backend responsibilities are spread across:
     - **Supabase Auth** for login/signup and role-based access,
     - **PostgreSQL** for campus entities like notices, events, notes, users, placements, and forum content,
     - **Supabase Storage** for uploaded files such as PDFs and images,
     - **Supabase Realtime** for live updates without refresh.
   - `supabase_seed.sql` suggests the repository includes seeded demo or initial data.

6. **Student-data flows**
   - Student pages are read-heavy dashboards over shared campus data: notices, deadlines, placements, events, club activity, forum posts, notes, and lost/found listings.
   - Typical flow is: frontend page → Supabase query → live updates via Realtime → UI refresh.
   - The student dashboard likely aggregates multiple collections into a single overview, while the specialized pages drill into one domain each.

7. **Admin-data flows**
   - The admin portal is the write/control plane for the system.
   - Admin pages manage the same core entities that students consume: notices, placements, events, clubs, and users.
   - This creates a clear architectural split: **students mostly consume data**, while **admins publish and govern it**.

8. **AI and RAG layer**
   - The repo includes a separate `server/` directory with `server/rag.ts` plus a top-level `server.ts`, which suggests a server-side AI or retrieval service distinct from the browser app.
   - The README describes AI-driven features such as the buddy assistant and notice Q&A, so the AI layer likely combines:
     - context retrieval from campus data,
     - a Groq-backed LLM call,
     - and response streaming back to the UI.
   - This is a separate intelligence boundary from the CRUD app logic.

9. **Automation and scheduled jobs**
   - `supabase/functions/check-deadlines/index.ts` and `send-deadline-email/index.ts` are Supabase Edge Functions.
   - Their role is operational automation: scanning upcoming deadlines and sending reminder emails.
   - This is the repo’s background-processing path, likely triggered by Supabase Cron rather than by user interaction.

10. **Email and external integrations**
   - The README indicates transactional email delivery through **Resend**.
   - That means deadline notifications are not just in-app alerts; they also leave the system through an email delivery service.
   - Groq is the other notable external dependency, used for low-latency AI responses.

11. **Security and access control**
   - The architecture relies on **role-based access** at both the UI and data layers.
   - Admin/student separation is enforced by route layout structure in the frontend and, per the README, by Supabase Row Level Security in the database.
   - This means the access boundary is not only visual; it is enforced where the data is stored.

12. **Deployment/runtime split**
   - The frontend is built with **Vite + React** and deployed on **Vercel**.
   - Backend logic is split between **Supabase-managed services** and **serverless edge functions**.
   - The presence of `server.ts`/`server/rag.ts` adds a second server-side runtime path, likely for AI orchestration or API mediation.

13. **How to draw the architecture**
   - A good diagram would show:
     - **Browser UI** at the top,
     - branching into **Auth**, **Student Portal**, and **Admin Portal**,
     - all talking to a shared **Supabase backend**,
     - with a side lane for **AI/RAG service**,
     - and a background lane for **scheduled deadline/email automation**.
   - The main system boundary is the Supabase-backed campus data platform; everything else is either presentation, AI enhancement, or automation.

Main entry points: [`src/App.jsx`](https://github.com/coderayushraj-png/campus-connect/blob/main/src/App.jsx) (App shell), [`src/app/(student)/layout.jsx`](https://github.com/coderayushraj-png/campus-connect/blob/main/src/app/(student)/layout.jsx) (Student shell), [`src/app/admin/layout.jsx`](https://github.com/coderayushraj-png/campus-connect/blob/main/src/app/admin/layout.jsx) (Admin shell), [`src/lib/supabase.js`](https://github.com/coderayushraj-png/campus-connect/blob/main/src/lib/supabase.js) (Supabase client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_main["Main entry<br/>vite bootstrap<br/>[main.jsx]"]
  node_app["App shell<br/>router shell<br/>[App.jsx]"]
  node_auth["Auth pages<br/>route group<br/>[page.jsx]"]
  node_student_layout["Student shell<br/>layout<br/>[layout.jsx]"]
  node_student_portal["Student portal<br/>student routes<br/>[page.jsx]"]
  node_admin_layout["Admin shell<br/>layout<br/>[layout.jsx]"]
  node_admin_portal["Admin portal<br/>admin routes<br/>[page.jsx]"]
  node_ai_buddy(("AI buddy<br/>shared widget<br/>[AIBuddy.jsx]"))
  node_notifications(("Notifications<br/>shared widget"))
end

subgraph group_backend["Backend"]
  node_supabase_client["Supabase client<br/>data client<br/>[supabase.js]"]
  node_supabase_platform[("Supabase platform<br/>managed backend")]
  node_rag_server["RAG server<br/>ai service<br/>[rag.ts]"]
  node_server_entry["Server entry<br/>runtime entry<br/>[server.ts]"]
  node_deadline_check["Deadline check<br/>edge function<br/>[index.ts]"]
  node_deadline_email["Deadline email<br/>edge function<br/>[index.ts]"]
end

subgraph group_integrations["Integrations"]
  node_groq(("Groq<br/>llm provider"))
  node_resend(("Resend<br/>email service"))
  node_vercel["Vercel<br/>deployment target<br/>[vercel.json]"]
end

node_main -->|"boots"| node_app
node_app -->|"routes"| node_auth
node_app -->|"routes"| node_student_layout
node_app -->|"routes"| node_admin_layout
node_student_layout -->|"wraps"| node_student_portal
node_admin_layout -->|"wraps"| node_admin_portal
node_student_layout -->|"hosts"| node_notifications
node_student_layout -->|"hosts"| node_ai_buddy
node_admin_layout -->|"hosts"| node_notifications
node_admin_layout -->|"hosts"| node_ai_buddy
node_auth -->|"auth"| node_supabase_client
node_student_portal -->|"queries"| node_supabase_client
node_admin_portal -->|"mutates"| node_supabase_client
node_supabase_client -->|"connects"| node_supabase_platform
node_supabase_platform -.->|"triggers"| node_deadline_check
node_deadline_check -->|"invokes"| node_deadline_email
node_deadline_email -->|"sends"| node_resend
node_rag_server -->|"calls"| node_groq
node_server_entry -->|"serves"| node_rag_server
node_ai_buddy -->|"chat"| node_rag_server
node_notifications -->|"subscribes"| node_supabase_platform
node_student_portal -->|"realtime"| node_supabase_platform
node_admin_portal -->|"realtime"| node_supabase_platform
node_vercel -->|"deploys"| node_main

click node_main "https://github.com/coderayushraj-png/campus-connect/blob/main/src/main.jsx"
click node_app "https://github.com/coderayushraj-png/campus-connect/blob/main/src/App.jsx"
click node_auth "https://github.com/coderayushraj-png/campus-connect/blob/main/src/app/(auth)/login/page.jsx"
click node_student_layout "https://github.com/coderayushraj-png/campus-connect/blob/main/src/app/(student)/layout.jsx"
click node_student_portal "https://github.com/coderayushraj-png/campus-connect/blob/main/src/app/(student)/dashboard/page.jsx"
click node_admin_layout "https://github.com/coderayushraj-png/campus-connect/blob/main/src/app/admin/layout.jsx"
click node_admin_portal "https://github.com/coderayushraj-png/campus-connect/blob/main/src/app/admin/dashboard/page.jsx"
click node_ai_buddy "https://github.com/coderayushraj-png/campus-connect/blob/main/src/components/AIBuddy.jsx"
click node_notifications "https://github.com/coderayushraj-png/campus-connect/blob/main/src/components/NotificationBell.jsx"
click node_supabase_client "https://github.com/coderayushraj-png/campus-connect/blob/main/src/lib/supabase.js"
click node_rag_server "https://github.com/coderayushraj-png/campus-connect/blob/main/server/rag.ts"
click node_server_entry "https://github.com/coderayushraj-png/campus-connect/blob/main/server.ts"
click node_deadline_check "https://github.com/coderayushraj-png/campus-connect/blob/main/supabase/functions/check-deadlines/index.ts"
click node_deadline_email "https://github.com/coderayushraj-png/campus-connect/blob/main/supabase/functions/send-deadline-email/index.ts"
click node_vercel "https://github.com/coderayushraj-png/campus-connect/blob/main/vercel.json"

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_main,node_app,node_auth,node_student_layout,node_student_portal,node_admin_layout,node_admin_portal,node_ai_buddy,node_notifications toneBlue
class node_supabase_client,node_supabase_platform,node_rag_server,node_server_entry,node_deadline_check,node_deadline_email toneAmber
class node_groq,node_resend,node_vercel toneMint
```

## Components

### Frontend

Browser app, route shells, and shared UI

- [Main entry](https://github.com/coderayushraj-png/campus-connect/blob/main/src/main.jsx): vite bootstrap · App bootstrap and render entry · `src/main.jsx`
- [App shell](https://github.com/coderayushraj-png/campus-connect/blob/main/src/App.jsx): router shell · Top-level client routing and composition · `src/App.jsx`
- [Auth pages](https://github.com/coderayushraj-png/campus-connect/blob/main/src/app/(auth)/login/page.jsx): route group · Login and signup flows · `src/app/(auth)/login/page.jsx`
- [Student shell](https://github.com/coderayushraj-png/campus-connect/blob/main/src/app/(student)/layout.jsx): layout · Shared navigation and page frame for students · `src/app/(student)/layout.jsx`
- [Student portal](https://github.com/coderayushraj-png/campus-connect/blob/main/src/app/(student)/dashboard/page.jsx): student routes · Student-facing dashboards and campus workflows · `src/app/(student)/dashboard/page.jsx`
- [Admin shell](https://github.com/coderayushraj-png/campus-connect/blob/main/src/app/admin/layout.jsx): layout · Shared navigation and page frame for admins · `src/app/admin/layout.jsx`
- [Admin portal](https://github.com/coderayushraj-png/campus-connect/blob/main/src/app/admin/dashboard/page.jsx): admin routes · Admin control plane for campus content and users · `src/app/admin/dashboard/page.jsx`
- [AI buddy](https://github.com/coderayushraj-png/campus-connect/blob/main/src/components/AIBuddy.jsx): shared widget · Persistent assistant entry point across the app · `src/components/AIBuddy.jsx`
- [Notifications](https://github.com/coderayushraj-png/campus-connect/blob/main/src/components/NotificationBell.jsx): shared widget · Global alerts and unread counts · `src/components/NotificationBell.jsx`

### Backend

Supabase data layer, AI service, and automation

- [Supabase client](https://github.com/coderayushraj-png/campus-connect/blob/main/src/lib/supabase.js): data client · Frontend gateway for auth, database, storage, and realtime · `src/lib/supabase.js`
- **Supabase platform**: managed backend · Auth, Postgres, storage, realtime, and access rules
- [RAG server](https://github.com/coderayushraj-png/campus-connect/blob/main/server/rag.ts): ai service · Server-side retrieval and LLM orchestration · `server/rag.ts`
- [Server entry](https://github.com/coderayushraj-png/campus-connect/blob/main/server.ts): runtime entry · Node/server entrypoint for AI or API mediation · `server.ts`
- [Deadline check](https://github.com/coderayushraj-png/campus-connect/blob/main/supabase/functions/check-deadlines/index.ts): edge function · Scans upcoming deadlines for reminders · `supabase/functions/check-deadlines/index.ts`
- [Deadline email](https://github.com/coderayushraj-png/campus-connect/blob/main/supabase/functions/send-deadline-email/index.ts): edge function · Sends deadline reminder emails · `supabase/functions/send-deadline-email/index.ts`

### Integrations

External services used by the platform

- **Groq**: llm provider · Low-latency model backend for assistant responses
- **Resend**: email service · Transactional email delivery for reminders
- [Vercel](https://github.com/coderayushraj-png/campus-connect/blob/main/vercel.json): deployment target · Frontend hosting and production deployment · `vercel.json`

## Connections

- Main entry → App shell: boots · Client entry renders the app shell
- App shell → Auth pages: routes · Route group for login and signup
- App shell → Student shell: routes · Student section uses its own shell
- App shell → Admin shell: routes · Admin section uses its own shell
- Student shell → Student portal: wraps · Provides navigation and shared student chrome
- Admin shell → Admin portal: wraps · Provides navigation and shared admin chrome
- Student shell → Notifications: hosts · Global alert entry in student shell
- Student shell → AI buddy: hosts · Persistent assistant available to students
- Admin shell → Notifications: hosts · Global alert entry in admin shell
- Admin shell → AI buddy: hosts · Assistant can be surfaced in admin context
- Auth pages → Supabase client: auth · Login and signup use Supabase auth
- Student portal → Supabase client: queries · Student pages read campus data from Supabase
- Admin portal → Supabase client: mutates · Admin pages write and manage campus data
- Supabase client → Supabase platform: connects · Single client for backend services
- Supabase platform → Deadline check: triggers · Scheduled processing for deadlines
- Deadline check → Deadline email: invokes · Reminder jobs hand off to email sending
- Deadline email → Resend: sends · Transactional email delivery
- RAG server → Groq: calls · LLM inference and assistant responses
- Server entry → RAG server: serves · Server runtime exposes AI/RAG logic
- AI buddy → RAG server: chat · Assistant UI sends prompts to RAG service
- Notifications → Supabase platform: subscribes · Unread counts and alerts via realtime data
- Student portal → Supabase platform: realtime · Student views refresh from live updates
- Admin portal → Supabase platform: realtime · Admin views refresh from live updates
- Vercel → Main entry: deploys · Frontend is hosted as a web app
