How envoyx/hmm-lms works
1. High-level shape
- This is a Next.js 15 App Router monorepo-style application with a clear split between public-facing pages, authenticated member pages, and admin back office.
- Most of the UI lives in src/app, while shared UI, hooks, and server-side domain logic are separated into src/components, src/hooks, src/lib, and src/server.
2. Route / shell boundaries
- src/app/(external) is the public marketing and identity site for HMM ITB, with its own layout and visual sections.
- src/app/(with-sidebar) is the main authenticated student/member experience with a sidebar shell.
- src/app/admin is the operational/admin console for content management, analytics, database tools, and user management.
- Separate auth and utility routes live under src/app/auth, src/app/forms, and src/app/s/[slug] for sign-in, public form submission, and short links.
3. Core business domains
- The application centers on several domain modules: courses, events, announcements, tryouts, forms, scholarships, job vacancies (loker), shortlinks, profiles/settings, and analytics.
- Each domain typically has both a user-side surface and an admin-side management surface, which is important for diagramming the system as a content platform rather than a single-purpose LMS.
4. Backend API layer
- The main typed backend is tRPC under src/server/api, with routers per domain such as announcement, course, event, forms, tryout, loker, scholarship, short-link, analytics, dashboard, database, notifications, and push.
- src/server/api/root.ts composes these routers into one API surface, and src/trpc/* contains the client/server helpers used by the React app.
- There are also conventional REST routes under src/app/api for cases like auth callbacks, document upload/delete, video access, and notification webhook handling.
5. Data and persistence
- Prisma is the ORM, with schema and migrations in prisma/.
- The primary datastore is PostgreSQL; src/server/db.ts is the database access boundary.
- The schema is evolved through migrations, and the repo includes a later migration for job vacancy metadata, which signals that the data model is shared across many domains and evolves with feature expansion.
6. Authentication and authorization
- Authentication is handled with NextAuth in src/server/auth, exposed through the /api/auth/[...nextauth] route.
- Role-based access is a major architectural boundary: the app distinguishes students/members, admins, and likely superadmins.
- The presence of admin-only routes and database-management UI implies server-side authorization checks are enforced in API/router code, not just in the client shell.
7. Media, files, and external storage
- File/media handling is an explicit subsystem, not incidental: documents, images, course attachments, and question assets are uploaded and served through src/app/api/documents/* and related helpers in src/lib.
- The README and code structure point to AWS S3 as the object storage backend.
- src/lib/s3-client.ts, src/lib/file-utils.ts, and src/lib/external-asset.ts suggest a shared abstraction for stored media versus externally linked assets.
8. Notifications and push delivery
- Push notifications are a standalone flow: users subscribe via /api/notifications/subscribe, notifications are sent via /api/notifications/send, tested via /test, and integrated with a webhook endpoint.
- Client-side notification registration and updates are handled by components like register-sw.tsx, notif-prompt-modal.tsx, and sw-update.tsx.
- public/sw.js, public/worker/*, and the worker/ directory indicate a service-worker-based PWA notification channel.
9. Interactive learning and assessment flows
- Courses cover enrollment, resources, learning-session tracking, testimonials, and course detail pages.
- Tryouts are a more complex assessment subsystem with attempts, results, analytics, and multiple question types; admin and student attempt flows are separated.
- Forms are a general-purpose builder/submission system with create/edit/preview/response pages, and some of the same patterns are reused for registrations and surveys.
- These flows combine server-rendered pages with client-heavy components for rich editing, analytics, and multi-step interactions.
10. Event management and calendaring
- Events are a major subsystem with operational modes like basic listing, RSVP, attendance tracking, and combined registration/check-in.
- The calendar UI is supported by a dedicated component set in src/components/event-calendar, plus schedule utilities in src/app/(with-sidebar)/schedule.
- This area also ties into notifications, attendee data, and export/integration features such as Google Sheets mentioned in the README.
11. Admin operations and analytics
- The admin area is not a thin wrapper; it includes analytics dashboards, content CRUD, course membership management, tryout authoring, user management, database admin tooling, and shortlink creation.
- src/app/admin/database is especially notable because it exposes table browsing, create/edit/delete dialogs, pagination, refresh, and export functionality—effectively an internal data console.
- Analytics components are shared across admin domains, implying a common reporting layer over the main business tables.
12. Public content / brand site
- src/app/(external) is a separate public-facing experience for HMM identity, about/mission/vision content, and organogram presentation.
- It uses its own layout, navigation, and visual treatment, backed by static assets in public/ and custom typography in src/fonts/.
- This is a good boundary to draw separately from the authenticated LMS, since it represents institutional branding rather than operational workflow.
13. Shared UI and client-side infrastructure
- src/components/ui is a reusable design-system layer built around shadcn/ui-style primitives.
- Higher-level shared widgets include navbar/sidebar/header components, breadcrumbs, charts, dialogs, media viewers, uploaders, and theme controls.
- Hooks in src/hooks handle cross-cutting client behavior such as time indicators, file uploads, notifications, mobile detection, and local storage.
14. Operational/tooling concerns
- The repo uses Bun for package/runtime workflows, ESLint and Prettier for quality, and Vitest for tests.
- A GitHub Actions workflow (.github/workflows/quality-gates.yml) indicates automated quality checks in CI.
- public/manifest.json, service workers, and install prompts show that the app is intentionally shipped as a PWA, not just a traditional website.
15. How data flows through the system
- Typical flow: browser page or client component → tRPC or REST API route → server router/service → Prisma → PostgreSQL, with optional S3 interaction for media and push/notification side effects.
- For public forms, sign-in, and short links, the flow is simplified but still lands in the same shared backend/data model.
- For notifications and announcements, the flow often fans out from a content mutation into notification-trigger services plus service-worker delivery to end users.
Main entry points: ui UI system · routers Domain routers · [trpc] tRPC route · (with-sidebar) Member shell
Components 20
Public site
External brand and identity experience.
- External site · Public-facing HMM landing pages, about content, and organogram.
src/app/(external)
Member app
Authenticated student/member experience with sidebar shell.
- Member shell · Authenticated app with sidebar navigation and member workflows.
src/app/(with-sidebar) - Auth & forms · Sign-in/sign-up pages, public form submission, and form result views.
src/app/auth - Short links · Public slug-based redirect and landing route.
src/app/s/[slug]
Admin console
Operational back office for content, analytics, and data management.
- Admin shell · Administrative console for management, analytics, and operations.
src/app/admin
Backend
API, auth, persistence, and service-layer logic.
- tRPC route · Single typed RPC entrypoint for application data access.
src/app/api/trpc/[trpc] - Auth callback · NextAuth callback and session route.
src/app/api/auth/[...nextauth] - Media API · Document upload, delete, and video access endpoints.
src/app/api/documents - Notification API · Subscription, send, test, and webhook endpoints for notifications.
src/app/api/notifications - Video API · Video retrieval endpoint.
src/app/api/videos - API root · Composes domain routers into the main typed backend surface.
src/server/api/root.ts - Domain routers · Domain-specific routers for announcements, courses, events, forms, tryouts, loker, scholarships, analytics, dashboard, database, notifications, push, and more.
src/server/api/routers - Auth server · Server-side authentication and authorization setup.
src/server/auth - Database · Prisma schema and database access boundary over PostgreSQL.
src/server/db.ts - S3 storage · Shared file and media storage abstraction for uploads and assets.
src/lib/s3-client.ts - Notifications · Push subscription, service-worker delivery, and notification triggers.
src/server/services/notification-triggers.ts
Shared client
Reusable UI, hooks, and client-side infrastructure.
- UI system · Reusable design-system primitives and app-level shared widgets.
src/components/ui - Client hooks · Cross-cutting client behavior for uploads, notifications, mobile, time, and storage.
src/hooks - Shared lib · Schemas, file helpers, exports, theme color, and typed shared utilities.
src/lib - PWA worker · Service worker and worker assets for offline/PWA and push delivery.
public/sw.js
Connections 24
- External site → UI system: uses · Public pages render with shared UI primitives and widgets.
- Member shell → UI system: uses · Member pages build on reusable UI components and shells.
- Admin shell → UI system: uses · Admin console uses shared UI and admin widgets.
- Auth & forms → UI system: uses · Auth and form pages use common UI controls.
- Short links → API root: reads · Short-link resolution depends on backend data.
- Member shell → tRPC route: calls · Member UI fetches domain data through tRPC.
- Admin shell → tRPC route: calls · Admin UI drives CRUD and analytics through tRPC.
- Auth & forms → Auth callback: auth · Sign-in and sign-up flows use auth callbacks.
- Auth & forms → tRPC route: submits · Public forms and results interact with typed backend endpoints.
- tRPC route → API root: routes · The app RPC entrypoint forwards to the composed API surface.
- API root → Domain routers: composes · Root API aggregates all domain routers.
- Domain routers → Database: queries · Domain routers persist and read data through Prisma.
- Domain routers → S3 storage: stores · Routers handling documents and media use object storage.
- Domain routers → Notifications: triggers · Content and event mutations can fan out into notification delivery.
- Media API → S3 storage: uploads · Document endpoints proxy file upload and deletion to storage.
- Notification API → Notifications: delivers · Notification endpoints drive subscription and send flows.
- Auth callback → Auth server: authenticates · NextAuth route is backed by server auth configuration.
- Auth server → Database: persists · Authentication and user state depend on the database.
- Client hooks → Shared lib: relies on · Hooks use shared utilities and typed schemas.
- UI system → Shared lib: relies on · Shared widgets depend on common helpers and schemas.
- Notifications → PWA worker: pushes · Push delivery uses service-worker and worker assets.
- Member shell → PWA worker: registers · Member experience registers the service worker and install flow.
- Admin shell → Database: administers · Admin database tools operate directly over persisted data.
- External site → Shared lib: content · Public brand pages use shared content and asset helpers.