How chandan9335/campusboard works
1. This is a browser-only React SPA
The repository is a Vite + React front end with no custom backend service. src/main.jsx bootstraps the app, src/App.jsx wires the top-level layout/routes, and all persistent state lives in Supabase.
2. Supabase is the system boundary
src/supabaseClient.js is the single integration point to Supabase. The app uses Supabase for four distinct concerns: authentication, PostgreSQL data, Storage for avatars, and Realtime subscriptions.
3. Authentication is centralized in context
src/context/AuthContext.jsx owns the current session/user state and exposes auth actions to the rest of the app. The login/signup pages (src/pages/Login.jsx, src/pages/Signup.jsx) feed into this context, which is what the rest of the UI uses to know whether a user is signed in.
4. Route access is protected at the page boundary
src/routes/ProtectedRoute.jsx gates authenticated screens such as the dashboard/profile area. Public routes are the auth screens; protected routes depend on the session from AuthContext.
5. The app is organized by route-level pages and reusable components
src/pages/ contains the main screens: Dashboard, Profile, Login, and Signup. src/components/ contains the reusable UI pieces that those pages assemble: navigation, notice cards/forms, notification bell, and avatar upload.
6. Notices are the main CRUD entity
The notices table in Supabase is the app’s primary shared feed. src/hooks/useNotices.js encapsulates fetching and mutating notices, while NoticeForm.jsx creates new rows and NoticeCard.jsx renders individual entries. The database row-level policies allow public reads but restrict writes to the owner.
7. Realtime updates drive the live feed
src/hooks/useRealtimeNotices.js subscribes to notice changes so the dashboard updates without a manual refresh. This is the live “feed” path: database insert/update/delete events in Supabase Realtime flow back into the React UI.
8. Notifications are a separate user-scoped channel
The notifications table is private to each user, and src/hooks/useNotifications.js plus src/components/NotificationBell.jsx present the unread/read state in the UI. Unlike notices, notifications are not public; each user only sees their own rows.
9. Notice creation also triggers a notification pipeline
The README describes a Supabase trigger that inserts notification rows after a notice is created. That means a notice insert fan-outs into a second table write, and the bell component can reflect that change through the Realtime subscription path.
10. Profile data and avatar storage are separate from auth
src/pages/Profile.jsx handles profile metadata backed by the profiles table, while src/components/AvatarUpload.jsx uploads files into the public avatars Storage bucket. The storage path is user-scoped so the logged-in user owns the upload location.
11. Data access is split by visibility rules in Supabase
Profiles and notices are readable broadly, but notifications are private and avatar uploads are constrained by storage policies. This means the architecture relies heavily on Supabase RLS policies to enforce ownership and visibility, not on client-side checks alone.
12. Utility and presentation layers stay thin
src/utils/formatDate.js is a small shared formatting helper, and src/index.css provides lightweight global styling. The important architectural work happens in the auth context, data hooks, and Supabase-backed tables, not in custom UI state management.
Main entry points: App.jsx App · Dashboard.jsx Dashboard · supabaseClient.js Supabase Client · AuthContext.jsx Auth Context
Components 18
App Shell
Bootstrapping, routing, and auth-protected page composition.
- Entry · Vite entry point that mounts the React app.
src/main.jsx - App · Top-level layout and route wiring.
src/App.jsx - Protected Route · Gate for authenticated screens.
src/routes/ProtectedRoute.jsx - Auth Context · Central session and auth action state for the app.
src/context/AuthContext.jsx
UI Surface
Route-level pages and reusable visual components.
- Login · Public sign-in screen.
src/pages/Login.jsx - Signup · Public account creation screen.
src/pages/Signup.jsx - Dashboard · Main signed-in feed and overview screen.
src/pages/Dashboard.jsx - Profile · Signed-in user profile screen.
src/pages/Profile.jsx - Navbar · Shared top-level navigation.
src/components/Navbar.jsx - Notice Form · Creates new notice rows.
src/components/NoticeForm.jsx - Notice Card · Renders a single notice item.
src/components/NoticeCard.jsx - Bell · Unread/read notification indicator.
src/components/NotificationBell.jsx - Avatar Upload · Uploads user avatar files.
src/components/AvatarUpload.jsx
Data Layer
Supabase client, hooks, and shared formatting helpers.
- useNotices · Fetches and mutates notices.
src/hooks/useNotices.js - useRealtimeNotices · Subscribes to live notice changes.
src/hooks/useRealtimeNotices.js - useNotifications · Fetches and tracks user notifications.
src/hooks/useNotifications.js - Format Date · Shared date formatting helper.
src/utils/formatDate.js
Supabase
External system boundary for auth, database, storage, and realtime.
- Supabase Client · Single client entry to Supabase services.
src/supabaseClient.js
Connections 23
- Entry → App: boots · Application entry mounts the top-level app.
- App → Auth Context: provides auth · App composition depends on session state.
- App → Protected Route: guards pages · Protected routes wrap authenticated screens.
- App → Login: public route · Login page is reachable without auth.
- App → Signup: public route · Signup page is reachable without auth.
- App → Dashboard: protected route · Dashboard is shown only to signed-in users.
- App → Profile: protected route · Profile is shown only to signed-in users.
- Dashboard → Navbar: uses · Dashboard assembles shared navigation.
- Dashboard → Notice Form: creates notices · Dashboard includes the notice creation flow.
- Dashboard → Notice Card: lists notices · Dashboard renders notice entries.
- Dashboard → Bell: shows alerts · Dashboard surfaces notification state.
- Profile → Avatar Upload: uploads avatar · Profile manages avatar upload UI.
- Login → Auth Context: signs in · Login drives auth actions through context.
- Signup → Auth Context: registers · Signup drives auth actions through context.
- Auth Context → Supabase Client: auth session · Auth state is backed by Supabase auth.
- useNotices → Supabase Client: reads writes · Notice CRUD goes through the Supabase client.
- useRealtimeNotices → Supabase Client: subscribes · Realtime notice updates come from Supabase.
- useNotifications → Supabase Client: reads writes · Notification state is loaded from Supabase.
- Notice Form → useNotices: creates · Form delegates notice creation to the hook.
- Notice Card → Format Date: formats time · Notice timestamps use the shared formatter.
- Bell → useNotifications: reads state · Bell renders notification data from the hook.
- Avatar Upload → Supabase Client: uploads · Avatar files are stored through Supabase Storage.
- useRealtimeNotices → Dashboard: live feed · Realtime events drive dashboard updates.