This document describes the current system architecture as implemented today. It is intended to give engineers a clear mental model of structure, flow, and responsibility boundaries.
LGC Articulate is a full-stack communication coaching system built around structured articulation.
It consists of:
- Frontend (
client/) → React-based UI for interaction - Backend (
server/) → API, business logic, AI orchestration, persistence
The entire system follows a consistent pipeline:
User Input → Structured Processing → AI Evaluation → Guided Feedback
Each mode applies this pattern differently:
- Learn → Predefined structured flow
- Evaluate → AI scoring + persistence
- Doubt → AI coaching + refinement
Every backend request follows a strict layered flow:
route → middleware → controller → service → model/utils → response
| Layer | Responsibility |
|---|---|
| Route | Endpoint definition + middleware wiring |
| Middleware | Validation, auth, sanitization, rate limiting |
| Controller | HTTP request/response handling |
| Service | Business logic + orchestration |
| Model / Utils | Data persistence + helper logic |
src/main.jsx→ React bootstrapsrc/app/App.jsx→ Global shell (navbar, overlays, layout)src/app/Routes.jsx→ Route mapping
Frontend is organized using feature-first slices:
features/learn/→ Guided articulation learningfeatures/evaluate/→ AI scoring + result renderingfeatures/doubt/→ Coaching flowfeatures/auth/→ Authentication lifecyclefeatures/home/→ Informational pages
shared/components/→ Reusable UI primitivesshared/utils/highlight.js→ Text highlighting logicservices/api.js→ API abstraction layerutils/auth.js→ Token managementutils/usageTracker.js→ Usage tracking
-
Local state (
useState) at component/page level -
Custom hooks for feature orchestration:
useEvaluateFlowuseDoubtFlow
-
LocalStorage used for:
- auth token
- draft persistence
- usage tracking
server.js is responsible for:
- Loading environment variables
- Validating configuration
- Applying middleware
- Mounting routes
- Connecting to database
- Starting server
routes/authRoutes.jsroutes/evaluationRoutes.jsroutes/doubtRoutes.js
Handles endpoint mapping only.
authMiddleware.js→ JWT verificationvalidationMiddleware.js→ Input validation & sanitizationerrorHandler.js→ Standardized error responsesrateLimiter.js→ Request limiting
authController.jsevaluateController.jsdoubtController.js
Handles:
- request parsing
- response formatting
- delegation to services
evaluationService.js→ evaluation workflow + persistenceaiRefinementService.js→ AI orchestration (core engine)emailService.js→ email flows
User.js→ user model + password hashingattemptModel.js→ evaluation attempts + AI output
-
config/index.js→ runtime configuration -
config/database.js→ MongoDB lifecycle -
config/attemptStack.js→ AI model fallback strategy -
config/modelPrompts.js,aiPrompt.js→ prompt definitions -
utils/aiGuard.js→ output validation -
utils/contextFormatter.js→ prompt formatting -
utils/defensiveValidator.js→ strict validation
- Frontend builds payload from scenario + user response
POST /api/evaluatewith JWT- Middleware validates and authenticates
- Controller delegates to service
- Service calls AI refinement (
mode: evaluation) - AI output validated via
aiGuard - Attempt stored in MongoDB
- Response returned to frontend
- UI parses and renders structured feedback
- User submits context + response + level
POST /api/doubt- Validation middleware runs
- Controller calls AI refinement (
mode: doubt) - Response returned and rendered
- Signup → user created + verification token
- Verify → account activated
- Login → JWT issued
- Forgot/Reset → email-based token flow
- Protected routes require Bearer token
The system enforces:
- Separation of concerns across layers
- Feature-based frontend organization
- Centralized AI orchestration
- Controlled AI output via guards
- Reusable shared components and utilities
- API response shape inconsistency (frontend compensating for drift)
- Mixed user/session storage patterns in evaluation persistence
- Hardcoded API base URL in frontend
- AI parsing relies on structured text patterns (fragility risk)
-
UI issue → check feature components
-
API issue → route → controller → service
-
AI issue →
aiRefinementService.jsmodelPrompts.jsaiGuard.js
-
Data issue → models + MongoDB
README.md→ high-level overviewQUICKSTART.md→ setup guideSYSTEM_MAP.md→ feature-to-file mappingEXAMPLES.md→ API usage examples