# rajeshmore369/placio architecture

> Architecture diagram of the GitHub repository rajeshmore369/placio, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rajeshmore369/placio
- Repository: https://github.com/rajeshmore369/placio

## Overview

#### 1. Purpose and Runtime Topology
Placio is a multi-tenant smart-campus placement platform covering practice, assessments, placement workflows, LMS-style features, proctoring, analytics, billing, and notifications. It runs as a Next.js web client, NestJS API, and Flutter mobile client.
- Web entry: `frontend/src/app/layout.tsx`, `frontend/src/app/page.tsx`
- API bootstrap/composition: `backend/src/main.ts`, `backend/src/app.module.ts`
- Mobile entry: `mobile/lib/main.dart`

#### 2. Web and Mobile Clients
The Next.js App Router frontend provides public, authentication, practice, and role-specific dashboard routes. Dashboard layout is the primary client-side navigation boundary for Student, Institute, TPO, and Super Admin experiences. `frontend/src/lib/api.ts` is the browser-to-API boundary; tenant context and desktop restrictions are client concerns.
- `frontend/src/app/dashboard/layout.tsx`
- `frontend/src/app/dashboard/student/page.tsx`
- `frontend/src/lib/tenantContext.tsx`

Flutter is a separate API-consuming client with centralized routing and services for authentication, connectivity, FCM, cached state, exams, and proctoring.
- `mobile/lib/core/router/app_router.dart`
- `mobile/lib/core/services/api_service.dart`
- `mobile/lib/core/services/proctor_service.dart`

#### 3. API, Identity, and Tenant Enforcement
NestJS is organized by domain modules with controllers as HTTP boundaries and services as business/data orchestration. OTP authentication issues JWTs; guards enforce JWT, role, plan, B2B, CSRF, and desktop policies. Tenant middleware/context establishes institutional isolation before domain services execute.
- `backend/src/auth/auth.module.ts`
- `backend/src/common/middleware/tenant.middleware.ts`
- `backend/src/common/guards/plan.guard.ts`

User, tenant, and billing domains govern administrative access and subscription entitlement across feature modules.
- `backend/src/users/users.service.ts`
- `backend/src/tenants/tenants.service.ts`
- `backend/src/billing/billing.service.ts`

#### 4. AI Practice and Asynchronous Feedback Pipeline
Nine practice domains expose dedicated APIs and session workflows: interview, aptitude, coding, English, GD simulation, resume review, daily challenge, skill roadmap, and company preparation. They share the AI layer rather than calling models directly.
- `backend/src/practice/practice.module.ts`
- `backend/src/practice/interview/interview.service.ts`
- `backend/src/practice/coding/coding.service.ts`

`ModelRouterService` selects Claude models by task/cost. Question generation is precomputed into PostgreSQL; real-time sessions use appropriate models; longer feedback is queued, submitted to Anthropic Batch API, polled, and persisted. Redis/BullMQ is the production asynchronous boundary, with fallback behavior when unavailable.
- `backend/src/ai/model-router.service.ts`
- `backend/src/ai/question-bank.service.ts`
- `backend/src/ai/feedback.processor.ts`

#### 5. Core Campus Workflows and Integrations
Placement tracks jobs and student applications through a staged pipeline. Assessments own exam/test handling and delegate code execution to Judge0. Frontend proctoring is browser-local—camera/face, audio, and browser monitoring—while assessment/proctoring results are submitted to backend workflows.
- `backend/src/placement/placement.service.ts`
- `backend/src/assessments/judge0.service.ts`
- `frontend/src/lib/proctoring/engine.ts`

Supporting domains provide persisted resumes/files, analytics, multi-channel notifications, and mail delivery. External boundaries include Cloudflare R2/S3-compatible storage, Razorpay, Resend/SMTP, Firebase Cloud Messaging, and Judge0.
- `backend/src/files/files.service.ts`
- `backend/src/notifications/notifications.service.ts`
- `backend/src/analytics/analytics.service.ts`

#### 6. Data and Deployment Boundaries
Prisma defines the shared PostgreSQL persistence model, targeting Neon PostgreSQL. Redis supports cache and queue workloads. Docker Compose deploys frontend, backend, reverse proxy, and supporting services; Nginx is the public ingress. The frontend proxies API traffic during development rather than directly embedding backend connectivity.
- `backend/prisma/schema.prisma`
- `backend/src/prisma/prisma.service.ts`
- `backend/src/redis/redis.service.ts`
- `docker-compose.yml`
- `nginx/nginx.conf`

Production variants and CI/CD are represented by DigitalOcean deployment assets and GitHub Actions.
- `.do/docker-compose.prod.yml`
- `.do/nginx.prod.conf`
- `.github/workflows/ci-cd.yml`

Main entry points: [`frontend/src/app/layout.tsx`](https://github.com/rajeshmore369/placio/blob/main/frontend/src/app/layout.tsx) (Next.js web client), [`backend/src/app.module.ts`](https://github.com/rajeshmore369/placio/blob/main/backend/src/app.module.ts) (NestJS API), [`backend/src/ai/feedback.processor.ts`](https://github.com/rajeshmore369/placio/blob/main/backend/src/ai/feedback.processor.ts) (Feedback worker), [`docker-compose.yml`](https://github.com/rajeshmore369/placio/blob/main/docker-compose.yml) (Docker Compose stack)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["Client apps"]
  node_web["Next.js web client<br/>web app<br/>[layout.tsx]"]
  node_dashboard["Dashboard boundary<br/>client navigation<br/>[layout.tsx]"]
  node_tenant_context["Tenant context<br/>client state<br/>[tenantContext.tsx]"]
  node_browser_proctoring["Browser proctoring<br/>client monitoring<br/>[engine.ts]"]
  node_mobile["Flutter mobile client<br/>mobile app<br/>[main.dart]"]
  node_mobile_api["Mobile API service<br/>client service<br/>[api_service.dart]"]
end

subgraph group_api["NestJS API"]
  node_api_bootstrap["NestJS API<br/>application runtime<br/>[app.module.ts]"]
  node_identity_tenant["Identity and tenant enforcement<br/>middleware and guards"]
  node_campus_domains["Campus workflow domains<br/>domain services"]
  node_practice_domains["Practice domains<br/>domain modules<br/>[practice.module.ts]"]
end

subgraph group_ai["AI feedback pipeline"]
  node_model_router["Model router<br/>AI orchestration"]
  node_question_bank["Question bank generation<br/>precompute service"]
  node_feedback_worker["Feedback worker<br/>BullMQ processor"]
end

subgraph group_data["Data and integrations"]
  node_postgres[("Neon PostgreSQL<br/>primary database<br/>[schema.prisma]")]
  node_redis["Redis<br/>cache and queue<br/>[redis.service.ts]"]
  node_external_services{{"External services<br/>integration boundaries<br/>[judge0.service.ts]"}}
end

subgraph group_deploy["Deployment"]
  node_ingress["Nginx ingress<br/>reverse proxy<br/>[nginx.conf]"]
  node_compose["Docker Compose stack<br/>deployment topology<br/>[docker-compose.yml]"]
  node_cicd["CI/CD<br/>delivery pipeline<br/>[ci-cd.yml]"]
end

node_web -->|"renders"| node_dashboard
node_web -->|"sets client tenant"| node_tenant_context
node_dashboard -->|"runs assessment monitoring"| node_browser_proctoring
node_web -->|"API requests"| node_api_bootstrap
node_mobile -->|"uses"| node_mobile_api
node_mobile_api -->|"API requests"| node_api_bootstrap
node_api_bootstrap -->|"applies before services"| node_identity_tenant
node_identity_tenant -->|"authorizes and scopes"| node_campus_domains
node_identity_tenant -->|"authorizes and scopes"| node_practice_domains
node_campus_domains -->|"persists workflows"| node_postgres
node_campus_domains -->|"uses payments, files, mail, FCM, Judge0"| node_external_services
node_browser_proctoring -->|"submits results"| node_campus_domains
node_practice_domains -->|"requests AI work"| node_model_router
node_model_router -->|"supports generation"| node_question_bank
node_question_bank -->|"stores questions"| node_postgres
node_model_router -->|"queues long feedback"| node_feedback_worker
node_feedback_worker -->|"consumes jobs"| node_redis
node_feedback_worker -->|"Anthropic Batch API"| node_external_services
node_feedback_worker -->|"persists feedback"| node_postgres
node_ingress -->|"routes public traffic"| node_web
node_ingress -->|"routes API traffic"| node_api_bootstrap
node_compose -->|"deploys"| node_ingress
node_compose -->|"runs"| node_api_bootstrap
node_compose -->|"runs"| node_web
node_cicd -->|"deploys"| node_compose

click node_web "https://github.com/rajeshmore369/placio/blob/main/frontend/src/app/layout.tsx"
click node_dashboard "https://github.com/rajeshmore369/placio/blob/main/frontend/src/app/dashboard/layout.tsx"
click node_tenant_context "https://github.com/rajeshmore369/placio/blob/main/frontend/src/lib/tenantContext.tsx"
click node_browser_proctoring "https://github.com/rajeshmore369/placio/blob/main/frontend/src/lib/proctoring/engine.ts"
click node_mobile "https://github.com/rajeshmore369/placio/blob/main/mobile/lib/main.dart"
click node_mobile_api "https://github.com/rajeshmore369/placio/blob/main/mobile/lib/core/services/api_service.dart"
click node_api_bootstrap "https://github.com/rajeshmore369/placio/blob/main/backend/src/app.module.ts"
click node_identity_tenant "https://github.com/rajeshmore369/placio/blob/main/backend/src/common/middleware/tenant.middleware.ts"
click node_campus_domains "https://github.com/rajeshmore369/placio/blob/main/backend/src/placement/placement.service.ts"
click node_practice_domains "https://github.com/rajeshmore369/placio/blob/main/backend/src/practice/practice.module.ts"
click node_model_router "https://github.com/rajeshmore369/placio/blob/main/backend/src/ai/model-router.service.ts"
click node_question_bank "https://github.com/rajeshmore369/placio/blob/main/backend/src/ai/question-bank.service.ts"
click node_feedback_worker "https://github.com/rajeshmore369/placio/blob/main/backend/src/ai/feedback.processor.ts"
click node_postgres "https://github.com/rajeshmore369/placio/blob/main/backend/prisma/schema.prisma"
click node_redis "https://github.com/rajeshmore369/placio/blob/main/backend/src/redis/redis.service.ts"
click node_external_services "https://github.com/rajeshmore369/placio/blob/main/backend/src/assessments/judge0.service.ts"
click node_ingress "https://github.com/rajeshmore369/placio/blob/main/nginx/nginx.conf"
click node_compose "https://github.com/rajeshmore369/placio/blob/main/docker-compose.yml"
click node_cicd "https://github.com/rajeshmore369/placio/blob/main/.github/workflows/ci-cd.yml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_web,node_dashboard,node_tenant_context,node_browser_proctoring,node_mobile,node_mobile_api toneBlue
class node_api_bootstrap,node_identity_tenant,node_campus_domains,node_practice_domains toneAmber
class node_model_router,node_question_bank,node_feedback_worker toneMint
class node_postgres,node_redis,node_external_services toneRose
class node_ingress,node_compose,node_cicd toneIndigo
```

## Components

### Client apps

- [Next.js web client](https://github.com/rajeshmore369/placio/blob/main/frontend/src/app/layout.tsx): web app · Public, auth, practice, and role-specific experiences. · `frontend/src/app/layout.tsx`
- [Dashboard boundary](https://github.com/rajeshmore369/placio/blob/main/frontend/src/app/dashboard/layout.tsx): client navigation · Role-specific student, institute, TPO, and admin navigation. · `frontend/src/app/dashboard/layout.tsx`
- [Tenant context](https://github.com/rajeshmore369/placio/blob/main/frontend/src/lib/tenantContext.tsx): client state · `frontend/src/lib/tenantContext.tsx`
- [Browser proctoring](https://github.com/rajeshmore369/placio/blob/main/frontend/src/lib/proctoring/engine.ts): client monitoring · Captures local camera, audio, face, and browser signals. · `frontend/src/lib/proctoring/engine.ts`
- [Flutter mobile client](https://github.com/rajeshmore369/placio/blob/main/mobile/lib/main.dart): mobile app · API client with centralized routing, cached state, and FCM. · `mobile/lib/main.dart`
- [Mobile API service](https://github.com/rajeshmore369/placio/blob/main/mobile/lib/core/services/api_service.dart): client service · `mobile/lib/core/services/api_service.dart`

### NestJS API

- [NestJS API](https://github.com/rajeshmore369/placio/blob/main/backend/src/app.module.ts): application runtime · HTTP composition root for domain modules. · `backend/src/app.module.ts`
- [Identity and tenant enforcement](https://github.com/rajeshmore369/placio/blob/main/backend/src/common/middleware/tenant.middleware.ts): middleware and guards · JWT, policy, entitlement, and institutional isolation boundary. · `backend/src/common/middleware/tenant.middleware.ts`
- [Campus workflow domains](https://github.com/rajeshmore369/placio/blob/main/backend/src/placement/placement.service.ts): domain services · Placement, assessments, files, analytics, notifications, users, tenants, and billing. · `backend/src/placement/placement.service.ts`
- [Practice domains](https://github.com/rajeshmore369/placio/blob/main/backend/src/practice/practice.module.ts): domain modules · Nine practice workflows share the AI layer. · `backend/src/practice/practice.module.ts`

### AI feedback pipeline

- [Model router](https://github.com/rajeshmore369/placio/blob/main/backend/src/ai/model-router.service.ts): AI orchestration · Selects Claude models by task and cost. · `backend/src/ai/model-router.service.ts`
- [Question bank generation](https://github.com/rajeshmore369/placio/blob/main/backend/src/ai/question-bank.service.ts): precompute service · Generates and stores practice questions ahead of sessions. · `backend/src/ai/question-bank.service.ts`
- [Feedback worker](https://github.com/rajeshmore369/placio/blob/main/backend/src/ai/feedback.processor.ts): BullMQ processor · Submits, polls, and persists long-running AI feedback. · `backend/src/ai/feedback.processor.ts`

### Data and integrations

- [Neon PostgreSQL](https://github.com/rajeshmore369/placio/blob/main/backend/prisma/schema.prisma): primary database · Shared Prisma persistence model. · `backend/prisma/schema.prisma`
- [Redis](https://github.com/rajeshmore369/placio/blob/main/backend/src/redis/redis.service.ts): cache and queue · Production cache and BullMQ boundary. · `backend/src/redis/redis.service.ts`
- [External services](https://github.com/rajeshmore369/placio/blob/main/backend/src/assessments/judge0.service.ts): integration boundaries · Anthropic, Judge0, R2/S3, Razorpay, Resend/SMTP, and FCM. · `backend/src/assessments/judge0.service.ts`

### Deployment

- [Nginx ingress](https://github.com/rajeshmore369/placio/blob/main/nginx/nginx.conf): reverse proxy · Public entrypoint for deployed services. · `nginx/nginx.conf`
- [Docker Compose stack](https://github.com/rajeshmore369/placio/blob/main/docker-compose.yml): deployment topology · Runs frontend, backend, proxy, and supporting services. · `docker-compose.yml`
- [CI/CD](https://github.com/rajeshmore369/placio/blob/main/.github/workflows/ci-cd.yml): delivery pipeline · Builds and deploys production variants. · `.github/workflows/ci-cd.yml`

## Connections

- Next.js web client → Dashboard boundary: renders
- Next.js web client → Tenant context: sets client tenant
- Dashboard boundary → Browser proctoring: runs assessment monitoring
- Next.js web client → NestJS API: API requests
- Flutter mobile client → Mobile API service: uses
- Mobile API service → NestJS API: API requests
- NestJS API → Identity and tenant enforcement: applies before services
- Identity and tenant enforcement → Campus workflow domains: authorizes and scopes
- Identity and tenant enforcement → Practice domains: authorizes and scopes
- Campus workflow domains → Neon PostgreSQL: persists workflows
- Campus workflow domains → External services: uses payments, files, mail, FCM, Judge0
- Browser proctoring → Campus workflow domains: submits results
- Practice domains → Model router: requests AI work
- Model router → Question bank generation: supports generation
- Question bank generation → Neon PostgreSQL: stores questions
- Model router → Feedback worker: queues long feedback
- Feedback worker → Redis: consumes jobs
- Feedback worker → External services: Anthropic Batch API
- Feedback worker → Neon PostgreSQL: persists feedback
- Nginx ingress → Next.js web client: routes public traffic
- Nginx ingress → NestJS API: routes API traffic
- Docker Compose stack → Nginx ingress: deploys
- Docker Compose stack → NestJS API: runs
- Docker Compose stack → Next.js web client: runs
- CI/CD → Docker Compose stack: deploys
