How marcr11/ba-schedule works
1. Top-level shape
- The repo is split into a client and a server.
- The client is a React + TypeScript + Vite single-page app; the server is a Node.js + Express API.
- The system is centered on one domain: pulling university schedule data from Campus Dual and presenting it in a friendlier calendar UI.
2. Frontend presentation layer
- client/src/components/App.tsx is the main composition root for the UI.
- The visible UI is built from focused components: Calendar, Login, GeneralLogin, UserLogin, SettingsPopUp, SettingsButton, ThemeToggle, and LoadingAnim.
- The frontend also includes a couple of static entry pages in client/pages/ (info.html, timer.html), suggesting some non-SPA or auxiliary pages alongside the main app.
3. Frontend data handling and formatting
- The UI uses local helper modules to transform backend data into calendar-ready structures: scheduleDataFormat, setAppointmentColors, hexToRgb, and loadingMessages.
- Static JSON assets such as subjects.json and randomLoadingMessages.json are part of the presentation/data layer, not server state.
- This implies the client does some view-model shaping locally after receiving schedule data.
4. Frontend state and UX concerns
- Theme and interaction behavior are handled explicitly through helpers like configureTheme and configureKeyDownEvents.
- The app has a settings subsystem with dedicated popup and option components, indicating user preferences are likely managed in the UI layer rather than deeply in the backend.
- Styling is split into component-scoped CSS files plus a global index.css.
5. Backend entrypoint and API surface
- server/server.js is the backend bootstrap.
- The main API route is organized around routes/schedule.route.js, with controllers/schedule.controller.js and services/schedule.service.js separating HTTP handling from business logic.
- The backend appears to expose schedule-related functionality as the primary API contract.
6. External schedule source integration
- A dedicated campusDualFetcher folder contains campusDualFetcher.js and a certificate chain file, which strongly indicates the server integrates with the Campus Dual university system over a trusted TLS connection.
- This is the key external dependency in the architecture: the backend fetches authoritative schedule data from the university service, then normalizes and serves it to the client.
- The README’s login instructions also point to the campus self-service portal as the source of a user-specific hash/credential.
7. Persistence and user management
- MongoDB is the durable storage layer, configured via configs/db.config.js and accessed through services/db.service.js.
- The data model is split into models/user.model.js and models/general.model.js, which suggests separate storage concerns for user-specific records and shared/system data.
- Helper modules such as createNewUser, checkUserExistence, checkUserRegistered, updateUserLastLogin, and updateUserToken indicate the backend manages user registration state, token storage, and activity metadata.
8. Authentication and access control
- Authentication is helper-driven: checkPwd, verifyToken, and the token update helpers imply the backend validates access using stored secrets/tokens rather than anonymous public access.
- The frontend’s separate GeneralLogin and UserLogin components mirror that backend split: one flow likely handles general access, while the other handles user-linked Campus Dual login.
- This is a boundary worth capturing in an architecture diagram: client login → backend verification/token persistence → schedule access.
9. Scheduling and background work
- createNewCronJob.helper.js suggests the server can run scheduled jobs, likely to refresh schedule data or maintain user/session-related state.
- Additional helpers like getScheduleData, endTime, and updateUserLastLogin indicate the server is doing more than simple proxying; it also computes or enriches schedule records before returning them.
- The architecture therefore includes a small backend processing layer between the external Campus Dual source and the client calendar.
10. Cross-cutting protections and tooling
- middlewares/rateLimit.middleware.js adds request throttling, which matters because the backend is likely protecting an external dependency and/or user-specific endpoints.
- GitHub Actions workflows cover build/deploy, CodeQL security scanning, and Prettier formatting enforcement.
- This repo is production-oriented: it has deployment automation, static typing in the client, and security/quality automation in CI.
11. Runtime boundaries to show in a diagram
- Browser/client: renders UI, manages theme/settings, formats schedule data, and calls the API.
- Express backend: handles login/schedule endpoints, validates users/tokens, applies rate limiting, and orchestrates data access.
- MongoDB: persists users, tokens, and shared application data.
- Campus Dual external system: authoritative source for schedule information and login-related data.
12. Primary data flow
- User opens the React app → logs in with Campus Dual-derived credentials/hash → frontend sends login/schedule requests to the Express API → backend checks user/token state in MongoDB → backend fetches schedule data from Campus Dual when needed → backend returns normalized schedule payloads → frontend formats and renders them in the calendar UI.
Main entry points: App.tsx App · schedule.route.js Schedule API · db.config.js Mongo layer · checkPwd.helper.js User auth
Components 18
Client
React + TypeScript SPA that renders the schedule experience and prepares data for the calendar UI.
- App · Main UI composition root and application shell.
client/src/components/App.tsx - Calendar · Primary calendar presentation for timetable data.
client/src/components/Calendar.tsx - Login · Login entry and credential flow components.
client/src/components/Login.tsx - Settings · Popup and option controls for app settings.
client/src/components/SettingsPopUp.tsx - Theme/UX · Client-side theme and keyboard behavior helpers.
client/src/helpers/configureTheme.ts - Formatters · Transforms backend schedule data into calendar-ready structures and presentation colors.
client/src/helpers/scheduleDataFormat.ts - Loading UI · Loading animation and randomized loading messages.
client/src/components/LoadingAnim.tsx - Static data · Local JSON assets used by the UI for subjects and loading messages.
client/src/data/subjects.json - Aux pages · Standalone HTML pages outside the main SPA entry.
client/pages/info.html
Server
Express API that authenticates users, fetches schedule data, and serves normalized responses.
- Server · Backend startup and Express application bootstrap.
server/server.js - Schedule API · HTTP route, controller, and service layer for schedule-related requests.
server/src/routes/schedule.route.js - User auth · Checks password, token, and registration state while managing user records.
server/src/helpers/checkPwd.helper.js - Schedule processing · Schedule enrichment, end-time calculation, and cron-driven background work.
server/src/helpers/getScheduleData.helper.js - Mongo layer · Database configuration, service access, and user/general models.
server/src/configs/db.config.js - Rate limit · Request throttling for protected or dependency-sensitive endpoints.
server/src/middlewares/rateLimit.middleware.js - CampusDual fetcher · Trusted integration that retrieves schedule data from Campus Dual.
server/src/campusDualFetcher/campusDualFetcher.js
External
Outside systems the backend depends on for authoritative schedule and identity-related data.
- Campus Dual · Authoritative university schedule and login source.
- MongoDB · Persistent store for users, tokens, and shared application data.
Connections 21
- App → Calendar: renders · The app composes the primary calendar experience.
- App → Login: includes · The app mounts login flows and access entry points.
- App → Settings: includes · The app exposes settings and preference controls.
- App → Theme/UX: uses · The app configures theme and key handling behavior.
- App → Formatters: formats · Incoming schedule payloads are reshaped before rendering.
- App → Loading UI: shows · The app uses loading feedback during async work.
- App → Static data: reads · The UI consumes local JSON data for subjects and messages.
- App → Aux pages: adjacent pages · Auxiliary static pages sit alongside the SPA.
- Server → Schedule API: mounts · Server bootstrap wires the schedule API surface.
- Schedule API → Rate limit: protected by · API requests are throttled by rate limiting middleware.
- Schedule API → User auth: verifies · Login and access flows rely on user/token checks.
- Schedule API → Schedule processing: orchestrates · The route layer delegates schedule computation and enrichment.
- User auth → Mongo layer: persists · Auth helpers read and update user records in MongoDB.
- Schedule processing → CampusDual fetcher: fetches · Schedule processing pulls authoritative data through the Campus Dual adapter.
- CampusDual fetcher → Campus Dual: connects to · Backend integration reaches the external university system.
- Mongo layer → MongoDB: stores in · Mongo-backed persistence holds application records.
- User auth → Campus Dual: uses credentials · Login-related data originates from the Campus Dual side.
- Login → Schedule API: calls · Frontend login requests are sent to the backend API.
- Calendar → Schedule API: loads schedule · Calendar data is retrieved from the backend.
- Schedule API → Mongo layer: reads/writes · API operations depend on persisted user and general data.
- Schedule processing → Mongo layer: checks state · Processing consults stored user data and related metadata.