How mrmls-dev/nhs-mono-app works
1. This repository is a monorepo with two runtime apps and shared packages: a Next.js frontend in apps/web, a NestJS backend API in apps/api, and reusable UI/tooling in packages/*. The overall product appears to be a multi-tenant real-estate/agent marketing platform, based on the domain models and routes for agents, communities, counties, regions, floor plans, contacts, and branding.
2. The frontend (apps/web) is the user-facing application. It uses the Next.js App Router and is split into three major route groups: public marketing pages, authentication pages, and a protected dashboard. This separation is important for diagramming because each group has a different rendering and authorization boundary.
3. Public marketing pages render community and plan detail pages, schedule pages, and Open Graph image endpoints. These pages also rely on a mix of static assets in apps/web/public and local data files in apps/web/data, which suggests some public content is prebuilt or semi-static rather than always fetched from the API.
4. The dashboard area is the main authenticated workspace. It contains management screens for agents, communities, counties, regions, contacts, listings, members, integrations, SEO, domains, branding, and scheduling embeds. Many of these screens are composed from client-side components under app/dashboard/**/_components, indicating that the dashboard is interactive and form-heavy while still leveraging server-side route structure.
5. The web app’s data access is centralized in apps/web/lib/api/*, with one client module per backend domain area. This is the main frontend-to-backend boundary: UI components talk to these API wrappers, which in turn call the NestJS service. apps/web/lib/auth-client.ts and apps/web/proxy.ts indicate auth/session handling is wired into the frontend request path, likely to protect dashboard routes and attach session context.
6. The backend (apps/api) is a modular NestJS service. Each business area is isolated into its own module, controller, and service: agents, communities, counties, floor plans, regions, staff, marketing contacts, integrations, stats, storage, Mapbox token management, GHL, Vercel, and auth. For an architecture diagram, these modules are the core domain boxes behind a single API boundary.
7. Persistence is handled through Prisma in apps/api/prisma, with generated client code, migrations, and a seed script. The schema includes both business entities and auth/tenant entities such as Organization, Member, User, Session, Account, Invitation, and Verification, plus domain entities like Community, County, Region, FloorPlanModel, MarketingContact, and integration records. This implies the database is the system of record for both tenant identity and marketing content.
8. Authentication and authorization are first-class backend concerns. The API has dedicated auth modules, guards, decorators, and role/session support, which means request processing likely flows through session validation and role checks before domain services run. The presence of organization/member tables suggests access control is tenant-scoped rather than purely user-scoped.
9. Several backend modules represent external integrations or platform concerns rather than core CRUD. ghl and integrations point to GoHighLevel-style marketing automation integration, vercel likely manages deployment or environment linkage, mapbox handles token provisioning, and storage suggests file/media handling. These should be drawn as outbound integration points from the API, not from the frontend.
10. Shared packages separate cross-cutting concerns from app logic. packages/ui contains the design system and shadcn-style components consumed by the web app, while packages/typescript-config and packages/eslint-config standardize build and code-quality settings across the repo. This keeps UI primitives and tooling boundaries distinct from the business applications.
11. The monorepo is managed with Turbo and package-lock-based workspace tooling, so build/test boundaries are likely optimized around app/package dependency graphs. In practical terms, the architecture is not just “frontend talks to backend”; it is “Next.js app + Nest API + shared UI packages + centralized DB,” with each domain isolated into modules on the backend and route groups on the frontend.
Main entry points: app.module.ts API app · layout.tsx Next app · turbo.json Workspace · page.tsx Dashboard
Components 21
Monorepo
Workspace for frontend, backend, and shared packages.
- Workspace · Top-level repo orchestration and shared workspace tooling.
turbo.json
Web app
Next.js frontend with marketing, auth, and dashboard route boundaries.
- Next app · User-facing application built with the App Router.
apps/web/app/layout.tsx - Marketing · Public community, plan, schedule, and Open Graph pages.
apps/web/app/(marketing)/page.tsx - Auth area · Authentication boundary for sign-in pages and layout.
apps/web/app/(auth)/login/page.tsx - Dashboard · Authenticated admin area for managing tenants and marketing content.
apps/web/app/dashboard/page.tsx - Shared UI · Reusable client components and dashboard page pieces.
apps/web/components/BrandThemeProvider.tsx - API client · Typed wrappers used by the web app to call backend domains.
apps/web/lib/api/agent.ts - Session client · Frontend session and request protection helpers.
apps/web/lib/auth-client.ts - Route proxy · Protects dashboard traffic and forwards auth context.
apps/web/proxy.ts
API app
NestJS backend organized by domain modules.
- API app · Modular service boundary exposing business and integration APIs.
apps/api/src/app.module.ts - Auth module · Session validation, role checks, decorators, and auth flows.
apps/api/src/auth/auth.module.ts - Agents · Agent management and branding/coverage domain logic.
apps/api/src/agent/agent.module.ts - Communities · Community records and related content management.
apps/api/src/community/community.module.ts - Geography · County and region management for market structure.
apps/api/src/county/county.module.ts - Floor plans · Floor plan and media management for listings content.
apps/api/src/floor-plan/floor-plan.module.ts - Contacts · Marketing contact management and list operations.
apps/api/src/marketing-contacts/marketing-contacts.module.ts - Integrations · External platform concerns such as GHL, Vercel, storage, Mapbox, and stats.
apps/api/src/integrations/integrations.module.ts - Prisma DB · Database schema, generated client, migrations, and seed data.
apps/api/prisma/schema.prisma
Shared packages
Reusable UI and tooling packages consumed across apps.
- UI package · Reusable component library consumed by the web app.
packages/ui/src/components/button.tsx - TS config · Workspace TypeScript presets for apps and libraries.
packages/typescript-config/base.json - Lint config · Common ESLint presets for repository-wide consistency.
packages/eslint-config/base.js
Connections 26
- Workspace → Next app: manages · Workspace orchestrates the frontend application.
- Workspace → API app: manages · Workspace orchestrates the backend application.
- Workspace → UI package: shares · Common UI package is consumed by the frontend.
- Workspace → TS config: shares · TypeScript presets are shared across packages and apps.
- Workspace → Lint config: shares · ESLint presets are shared across packages and apps.
- Next app → Marketing: routes · Public App Router group for marketing pages.
- Next app → Auth area: routes · Authentication route group for sign-in flows.
- Next app → Dashboard: routes · Protected dashboard route group for admin workflows.
- Dashboard → Shared UI: composes · Dashboard screens are assembled from reusable client components.
- Marketing → API client: reads · Public pages can fetch domain data through frontend API wrappers.
- Dashboard → API client: reads · Dashboard forms and tables call backend through typed clients.
- Dashboard → Session client: guards · Dashboard behavior depends on session and auth helpers.
- Route proxy → Dashboard: protects · Proxy enforces authenticated access to protected routes.
- Next app → UI package: uses · Frontend renders shared UI primitives from the design system.
- Next app → API app: calls · Frontend communicates with the backend service boundary.
- API app → Auth module: uses · Backend requests flow through auth/session enforcement.
- API app → Agents: hosts · API exposes agent domain endpoints.
- API app → Communities: hosts · API exposes community domain endpoints.
- API app → Geography: hosts · API exposes county and region endpoints.
- API app → Floor plans: hosts · API exposes floor plan endpoints.
- API app → Contacts: hosts · API exposes contact endpoints.
- API app → Integrations: hosts · API exposes platform and external integration modules.
- API app → Prisma DB: persists · Backend reads and writes system-of-record data through Prisma.
- Integrations → Prisma DB: stores · Integration state is persisted in the shared database.
- API client → API app: fetches · Frontend data access wrappers call the NestJS API.
- Session client → Auth module: sessions · Frontend auth helpers align with backend session handling.