How coding-club-iitg/coursehub works
1. This is a monorepo with three main runtime surfaces: client for the public user-facing app, admin for internal administration, and server for the backend API. A small utils/make-courses Go utility and several server scripts support data generation and maintenance.
2. The public client is a React + Vite single-page app. Its screens are organized by user journey: landing/search, browse file tree, dashboard, contributions, profile, share, and error states. It uses its own router guard, reusable UI components, and a Redux-style state layer (actions, reducers) for file browser, URLs, and user state.
3. The admin app is a separate React + Vite SPA for operational staff. Its main pages cover login, branch representatives, courses, students, and course-linking. It also has a private-route wrapper, indicating authenticated-only access and a distinct admin auth flow.
4. The backend is a modular Node/Express-style API under server/modules. Each domain has the same boundary pattern: route file, controller, and usually a model/service layer. Core domains include auth, admin, user, course, folder, file, year, contribution, search, student, BR, event, and OneDrive integration.
5. Authentication and authorization are enforced on the server with dedicated middleware: isAuthenticated, isAdmin, and isBR. There are separate auth flows for normal users and admins, plus an OTP/auth-admin subsystem, which suggests role-based access rather than a single flat login model.
6. The application’s primary data model is academic content organized by year, course, folder, and file. The client browse/dashboard/profile screens consume these APIs to render course catalogs, file trees, favorites, exam cards, and contribution records. The server’s search, course, folder, file, and year modules form the backbone of that content graph.
7. Contributions are a first-class workflow. The public app has contribution screens and per-item contribution cards, while the server has a dedicated contribution module. This implies user-submitted content enters a moderation/approval path rather than being directly published.
8. External storage and file delivery are important boundaries. The server includes an onedrive module, OneDrive configuration, and a device-code token file, so academic files are at least partially sourced from or synchronized with OneDrive. There is also an imagekit service and an email service, suggesting media handling and notification workflows.
9. Course metadata is generated and maintained through offline tooling. The repo includes server/modules/course/create_courses.py, course/list.json, server scripts for seeding, migration, and cleanup, and a separate Go utility that reads an Excel file to generate course data. That means course catalog data is partly curated outside the live API and then imported.
10. Caching and lookup behavior are explicit architecture concerns in the public client. There are utility modules for frontend cache, course cache, folder search, formatting, and course-link logic docs. These reduce repeated API calls and help keep browse/search interactions responsive.
11. Build and deployment are split by surface. Both frontends have their own Vite configs and env examples, while the server has its own package, static assets, and deployment script. The apps are therefore independently buildable, but they share a common backend API contract.
12. For an architecture diagram, the main boundaries are: public client ↔ API server, admin client ↔ API server, and API server ↔ database/storage/external services. Inside the server, the key internal flow is route → controller → model/service → persistence or external integration.
Main entry points: src/App.jsx Client UI · index.js Server API · src/App.jsx Admin UI · course.routes.js Domain modules
Components 21
Client app
Public React + Vite SPA for learners and contributors.
- Client UI · Public user-facing application with browse, dashboard, profile, share, and contribution flows.
client/src/App.jsx - Private route · Client-side access control wrapper for protected screens.
client/src/router_utils/PrivateRoutes.jsx - State layer · Actions and reducers for file browser, URLs, and user state.
client/src/reducers/index.js - Browse flow · File tree browsing, folder/file display, year and folder actions.
client/src/screens/browse/index.jsx - Landing search · Entry screen and search modal for finding courses and content.
client/src/screens/landing/index.jsx - Dashboard · Course cards, favourites, exams, and contribution banner for signed-in users.
client/src/screens/dashboard/index.jsx - Contributions · Public contribution views and per-item contribution cards.
client/src/screens/contributions/index.jsx - Profile · User profile and contribution history views.
client/src/screens/profile.js/index.jsx - Share · Sharing surface for course/content links.
client/src/screens/share/index.jsx - Client utils · Formatting, search, and caching helpers that reduce repeated API work.
client/src/utils/frontendCache.js
Admin app
Private React + Vite SPA for operational staff.
- Admin UI · Internal administration application for staff workflows.
admin/src/App.jsx - Private route · Admin-only access wrapper and authenticated navigation.
admin/src/router_utils/PrivateRoutes.jsx - Admin login · Admin authentication screens and API wiring.
admin/src/pages/Login.jsx - Ops pages · Branch representatives, courses, students, and course-linking administration.
admin/src/pages/Courses.jsx
API server
Node/Express backend, domain modules, integrations, and scripts.
- Server API · Main backend entrypoint wiring middleware, modules, and static assets.
server/index.js - Auth & roles · Authentication and role checks for users, admins, and BRs.
server/middleware/isAuthenticated.js - Domain modules · Route-controller-model boundaries for auth, admin, user, course, folder, file, year, contribution, search, student, BR, and event.
server/modules/course/course.routes.js - Content graph · Academic hierarchy and discovery backbone across year, course, folder, file, and search.
server/modules/year/year.routes.js - Integrations · OneDrive, email, image processing, and upload boundaries.
server/modules/onedrive/onedrive.routes.js - Maintenance scripts · Seeding, migration, cleanup, and import scripts for the live dataset.
server/scripts/seed_app.js
Offline tooling
Data-generation utilities and import helpers.
- Go generator · Standalone utility that generates course data from spreadsheet input.
utils/make-courses/cmd/app/main.go
Connections 21
- Client UI → Private route: protect routes · Wrap protected screens with client-side access control.
- Client UI → State layer: manage state · Coordinate browse, URL, and user state through actions and reducers.
- Client UI → Browse flow: browse · Navigate the file tree and content hierarchy.
- Client UI → Landing search: search · Start course discovery from the landing page.
- Client UI → Dashboard: dashboard · Render user dashboard summaries and cards.
- Client UI → Contributions: contribute · Open contribution workflows and records.
- Client UI → Profile: profile · Show user profile and contribution history.
- Client UI → Share: share · Present sharing flows and link surfaces.
- Client UI → Client utils: cache/format · Use caching and formatting helpers to keep interactions responsive.
- Admin UI → Private route: restrict access · Gate internal pages behind authenticated-only routing.
- Admin UI → Admin login: sign in · Use the separate admin authentication flow.
- Admin UI → Ops pages: manage ops · Handle staff workflows for BRs, courses, students, and linking.
- Client UI → Server API: API calls · Public SPA consumes backend endpoints.
- Admin UI → Server API: API calls · Admin SPA consumes backend endpoints.
- Server API → Auth & roles: enforce roles · Apply authentication and role middleware to protected routes.
- Server API → Domain modules: mount modules · Expose domain-specific routers under the main API.
- Domain modules → Content graph: content APIs · Course, year, folder, file, and search form the core content graph.
- Domain modules → Integrations: external sync · Integrate with OneDrive, email, imagekit, and upload services.
- Server API → Maintenance scripts: maintenance · Run seeding, migration, cleanup, and import scripts alongside the API.
- Domain modules → Auth & roles: auth endpoints · Separate user, admin, and OTP/auth-admin flows from content APIs.
- Maintenance scripts → Go generator: generate courses · Offline tooling feeds curated course data into the server dataset.