How omkargitcs/campus-share works
Purpose and deployment shape
Campus Share is a PERN academic-resource platform for authenticated students to publish and discover notes, textbooks, and PYQs. It is split into an independently deployed React/Vite client and Node/Express REST API backed by PostgreSQL. Client hosting is configured for Vercel at client/vercel.json; backend startup is centered on server/src/index.js.
Client application and entry points
The browser app mounts through client/src/main.jsx and application-level routing/state composition begins in client/src/App.jsx. client/src/api.js is the API boundary used by UI flows. Primary screens are:
• Authentication: client/src/pages/Login.jsx, client/src/pages/Register.jsx
• Authenticated resource dashboard: client/src/pages/Dashboard.jsx
The dashboard composes reusable navigation, profile, resource presentation, loading, and upload UI from client/src/components/Navbar.jsx, client/src/components/ProfileSidebar.jsx, client/src/components/ResourceCard.jsx, and client/src/components/UploadModal.jsx.
Authentication and access boundary
The API exposes auth operations through server/src/routes/authRoutes.js, implemented in server/src/controllers/authController.js. The system uses bcrypt password hashing and stateless JWTs. server/src/middleware/auth.js is the protected-route boundary: it validates incoming credentials before user- or resource-scoped controller logic executes. The client’s login/register screens acquire and use this authenticated API context.
Resource discovery and publishing flow
Resource endpoints are mounted from server/src/routes/resourceRoutes.js and handled by server/src/controllers/resourceController.js. The dashboard retrieves resources through client/src/api.js, renders them as cards in client/src/components/ResourceCard.jsx, and applies client-side category filtering. Publishing originates in client/src/components/UploadModal.jsx; uploaded payloads cross the API boundary and are processed by the resource controller.
File/media ingestion boundary
Multipart upload parsing is isolated in server/src/middleware/multer.js. Resource publication therefore separates HTTP multipart handling from business logic in server/src/controllers/resourceController.js. Cloudinary is the external media/document storage service described by the repository; persistent resource records store the resulting application data in PostgreSQL rather than making the frontend manage storage directly.
User domain and persistence
User-oriented endpoints are defined in server/src/routes/userRoutes.js and implemented by server/src/controllers/userController.js. Prisma owns database access: the schema is server/prisma/schema.prisma, migration history begins at server/prisma/migrations/20260204165000_init/migration.sql, and client/database initialization is centralized in server/src/db.js. This creates a clear controller → Prisma → PostgreSQL persistence path.
Runtime and control flow
server/src/index.js initializes the Express runtime, applies middleware, and mounts auth, user, and resource route groups. The frontend runs under Vite (client/vite.config.js) and calls the Express API over HTTP. Core request progression is: React screen/component → client/src/api.js → Express route → JWT/upload middleware as applicable → controller → Prisma/PostgreSQL and Cloudinary → JSON response → dashboard/auth UI update.
Components 19
React/Vite Client
- Vercel hosting
client/vercel.json - Vite runtime
client/vite.config.js - Client entry
client/src/main.jsx - App routing & state
client/src/App.jsx - Login & registration
client/src/pages/Login.jsx - Resource dashboard · Loads resources and filters them by category.
client/src/pages/Dashboard.jsx - API client
client/src/api.js - Resource cards & upload
client/src/components/ResourceCard.jsx
Express API
- Express runtime · Initializes middleware and mounts route groups.
server/src/index.js - Auth routes
server/src/routes/authRoutes.js - Resource routes
server/src/routes/resourceRoutes.js - User routes
server/src/routes/userRoutes.js - JWT auth guard · Validates credentials for protected routes.
server/src/middleware/auth.js - Multipart parser
server/src/middleware/multer.js - Domain controllers · Auth uses bcrypt and JWT; resource and user logic serve their route groups.
server/src/controllers/resourceController.js
Persistence & Media
- Prisma database client
server/src/db.js - Prisma schema & migration
server/prisma/schema.prisma - PostgreSQL · Stores users and resource records.
- Cloudinary · Stores uploaded documents and media.
Connections 23
- Vercel hosting → Vite runtime: hosts
- Vite runtime → Client entry: runs
- Client entry → App routing & state: mounts
- App routing & state → Login & registration: routes to
- App routing & state → Resource dashboard: routes to
- Resource dashboard → Resource cards & upload: renders
- Login & registration → API client: auth requests
- Resource dashboard → API client: fetches resources
- Resource cards & upload → API client: publishes upload
- API client → Express runtime: HTTP / JSON
- Express runtime → Auth routes: mounts
- Express runtime → Resource routes: mounts
- Express runtime → User routes: mounts
- Auth routes → Domain controllers: auth operations
- Resource routes → JWT auth guard: protects
- Resource routes → Multipart parser: parses multipart
- JWT auth guard → Domain controllers: authorizes
- Multipart parser → Domain controllers: provides files
- User routes → JWT auth guard: protects
- Domain controllers → Prisma database client: persists via
- Domain controllers → Cloudinary: uploads documents
- Prisma database client → Prisma schema & migration: uses
- Prisma database client → PostgreSQL: connects to