How brij5/mocktestbuddy works
Project Type and Purpose
• Exam Buddy is a full-stack, containerized mock-test platform with two user-facing clients (a web app built in React/Vite and a mobile app in React Native/Expo), a Node.js/Express backend, and a MongoDB database.
• It supports role-based access (Admin/User), JWT authentication, exam/question management, and progress tracking.
File Structure
• Top-level directories:
• client/ → React/Vite web frontend
• server/ → Node.js/Express REST API
• docker/ → Nginx configs for production reverse-proxy
• docker-compose.dev.yml & docker-compose.prod.yml → multi-container orchestration
• docs/ → design, deployment, API docs
• assets/ & eas.json → React Native mobile app (Expo)
• client/src → components, pages, store (Redux), services (API layer), hooks, layouts
• server → layered backend: config, controllers, services (business logic), models (Mongoose schemas), routes, middleware, utils, validations, scripts, tests
Key Architectural Insights from README
• Clients consume REST endpoints over HTTP/S.
• Server issues and validates JWT tokens for auth, performs role checks in middleware.
• MongoDB accessed via Mongoose.
• Production deploy uses Docker images and Nginx as reverse proxy.
• Development uses Docker Compose with hot-reload.
Main Components
a. Clients
• Web App (React/Vite)
• Mobile App (Expo/React Native)
b. Edge/Proxy
• Nginx (production only)
c. Backend API
• Express App with layered structure (routes → controllers → services → models)
• Middleware (auth, validation, error handling)
d. Data Layer
• MongoDB database
e. External Services
• Email Service (SMTP or 3rd-party provider)
Relationships and Data Flows
• Users → (HTTPS) → Nginx → Web App static assets or → API endpoints
• Mobile App → (HTTPS) → API endpoints
• Web App & Mobile App → send credentials → API → AuthController → AuthService → JWT → Client
• Authenticated clients → call protected API routes → Controllers → Services → Models → MongoDB
• Backend uses emailService util to send transactional emails
• Docker Compose network: frontend, backend, mongo on same virtual network in dev
Architectural Patterns & Design Principles
• Layered architecture on server (separation of concerns: routing, business logic, data access)
• Client-side state management (Redux slices) and React Context/hooks
• Containerization (Docker) and infrastructure as code (Compose files)
• Environment-specific configuration (dev vs. prod .env files)
• Modular code organization (feature directories, reusable components, validation schemas)
• Clear, self-descriptive labels for each component and port numbers