How samjoshua2002/educrm works
Purpose and topology
educrm is a multi-tenant admissions CRM split into a Next.js administrative/public portal and a NestJS tenant API. It supports superadmin organization management, organization operations, staff/admin workflows, applicant self-service, public forms, lead capture, applications, and academic master data.
• admissions-mm-admin-main/src/app
• admissions-tenant-api-main/src/app.module.ts
• docker-compose.yml
Frontend entry points and role boundaries
The Next.js App Router frontend separates experiences by route group and role: authentication, internal main/admin views, applicant views, organization tenant views, and superadmin views. Layouts and role-specific sidebars provide the principal UI shell boundary.
• admissions-mm-admin-main/src/app/layout.tsx
• admissions-mm-admin-main/src/app/organization/layout.tsx
• admissions-mm-admin-main/src/app/superadmin/layout.tsx
Public form and lead ingestion
Public form URLs resolve by slug, while the backend exposes public-form submission and form-response endpoints. Submission data is persisted as form responses/submissions and feeds lead ingestion; lead assignment, verification, notes, status changes, and closure are separate workflow concerns.
• admissions-mm-admin-main/src/app/f/[slug]/page.tsx
• admissions-tenant-api-main/src/modules/forms/public-forms.controller.ts
• admissions-tenant-api-main/src/modules/leads/lead-ingestion.service.ts
Admissions and application lifecycle
Applications are a core domain aggregate with section-specific records for addresses, education, parents, work experience, qualifications, tests, and activities. Organization and main/admin application pages consume this lifecycle; the user portal exposes “my application.” Status updates and application activities form the audit/progression path.
• admissions-tenant-api-main/src/modules/applications/applications.service.ts
• admissions-tenant-api-main/src/modules/applications/entities/application.entity.ts
• admissions-mm-admin-main/src/app/(user)/my-application/page.tsx
Tenant administration and master data
Organizations are the tenancy root. Their staff administer branches, courses, academic sessions, course sessions, users/team members, forms, leads, applications, communications, payments, events, and students through organization-scoped routes and API modules.
• admissions-tenant-api-main/src/modules/organizations/organizations.service.ts
• admissions-tenant-api-main/src/modules/branches/branches.service.ts
• admissions-mm-admin-main/src/app/organization/settings/page.tsx
Authentication, authorization, and tenancy boundary
The API uses JWT authentication plus role and tenant guards, with common response transformation and exception handling. Frontend middleware is the corresponding route-access boundary; client auth state is maintained separately. Superadmin routes manage organizations and subscriptions, distinct from tenant routes.
• admissions-tenant-api-main/src/common/guards/jwt-auth.guard.ts
• admissions-tenant-api-main/src/common/guards/tenant.guard.ts
• admissions-mm-admin-main/src/middleware.ts
Data access, API integration, and runtime infrastructure
The frontend uses an API client, domain hooks, and a React Query provider/query client to fetch and cache backend resources. The Nest API follows controller → service → entity/DTO module boundaries and is backed by the schema represented in Database.sql. A local Next upload route is present; no specific third-party storage, payment, or messaging provider is identifiable from the tree.
• admissions-mm-admin-main/src/lib/api.ts
• admissions-mm-admin-main/src/components/providers/query-provider.tsx
• admissions-tenant-api-main/Database.sql
Main entry points: layout.tsx App Router shells · app.module.ts Nest application · api.ts API client and cache · organizations.service.ts Organizations and branches
Components 18
Next.js portal
Role-separated administrative, tenant, applicant, and public experiences.
- App Router shells · Layouts establish internal, organization, and superadmin UI boundaries.
admissions-mm-admin-main/src/app/layout.tsx - Organization operations · Organization-scoped administration for settings and operational domains.
admissions-mm-admin-main/src/app/organization/layout.tsx - Superadmin console · Manages organizations and subscriptions separately from tenant routes.
admissions-mm-admin-main/src/app/superadmin/layout.tsx - My application
admissions-mm-admin-main/src/app/(user)/my-application/page.tsx - Public form by slug
admissions-mm-admin-main/src/app/f/[slug]/page.tsx - Route access middleware · Frontend route-access boundary.
admissions-mm-admin-main/src/middleware.ts - API client and cache · Domain hooks use the API client and React Query cache.
admissions-mm-admin-main/src/lib/api.ts - React Query provider
admissions-mm-admin-main/src/components/providers/query-provider.tsx
NestJS tenant API
Tenant-scoped domain API and workflow layer.
- Nest application · Composes tenant API modules.
admissions-tenant-api-main/src/app.module.ts - JWT and tenant guards · Authenticates requests and enforces role and tenant scope.
admissions-tenant-api-main/src/common/guards/jwt-auth.guard.ts - Organizations and branches · Organizations are the tenancy root; branches are organization-scoped.
admissions-tenant-api-main/src/modules/organizations/organizations.service.ts - Academic master data · Courses, sessions, users, and related tenant administration.
admissions-tenant-api-main/src/modules/branches/branches.service.ts - Public forms API · Resolves forms and accepts form responses.
admissions-tenant-api-main/src/modules/forms/public-forms.controller.ts - Lead ingestion workflow · Turns submissions into leads for assignment and follow-up.
admissions-tenant-api-main/src/modules/leads/lead-ingestion.service.ts - Applications lifecycle · Manages applications, section records, status changes, and activities.
admissions-tenant-api-main/src/modules/applications/applications.service.ts - Application aggregate · Core application record with section-specific admissions data.
admissions-tenant-api-main/src/modules/applications/entities/application.entity.ts
Data and runtime
- CRM database schema · Persistence schema for tenant and admissions domains.
admissions-tenant-api-main/Database.sql - Local runtime stack
docker-compose.yml
Connections 23
- Route access middleware → App Router shells: protects routes
- App Router shells → Organization operations: hosts
- App Router shells → Superadmin console: hosts
- App Router shells → My application: hosts
- App Router shells → Public form by slug: hosts
- React Query provider → API client and cache: caches queries
- Organization operations → API client and cache: uses
- Superadmin console → API client and cache: uses
- My application → API client and cache: uses
- Public form by slug → Public forms API: submits responses
- API client and cache → Nest application: calls
- Nest application → JWT and tenant guards: applies
- JWT and tenant guards → Organizations and branches: enforces tenant scope
- Nest application → Public forms API: exposes
- Public forms API → Lead ingestion workflow: feeds submissions
- Nest application → Applications lifecycle: serves
- Applications lifecycle → Application aggregate: manages
- Organizations and branches → Academic master data: scopes
- Organizations and branches → Applications lifecycle: scopes
- Organizations and branches → CRM database schema: persists
- Applications lifecycle → CRM database schema: persists
- Lead ingestion workflow → CRM database schema: persists
- Local runtime stack → Nest application: runs