How naveengehu/quiz_port works
Project Type and Purpose
• QuizPort is a full-stack, web-based quiz application that demonstrates internal data structures (hash tables, arrays/linked lists) for efficient question lookup, storage, and randomization.
• The existing file tree shows a static “frontend” (HTML/CSS/JS) and a collection of monolithic PHP scripts under “server.”
High-Level Architecture Overview
a. Client Layer (Presentation Tier)
b. Application Layer (Backend Services)
c. Data Layer (Persistence and Cache)
Main Components
a. Client Layer
• Browser-based SPA pages (login, registration, dashboard, test creation/taking)
• app.js orchestrates UI logic, stores session info in LocalStorage, and calls REST endpoints.
• Responsive UI (HTML5, CSS3, possibly a UI framework like Bootstrap or Vue/React)
b. Application Layer
We replace the unstructured PHP scripts with separate, well-scoped service modules. Each module is a PHP class or microservice, exposing RESTful endpoints via an API Gateway (e.g., Slim Framework or Laravel API routes).
1. API Gateway / Router
– Central entry point for all REST calls
– Authenticates token/session, routes to service controllers
2. User Management Service
– Endpoints: /register, /login, /logout, /validateSession
– Responsibilities: credential hashing, JWT/session issuance, session validation
3. Quiz Management Service
– Endpoints: /questions, /createTest, /getTestKeys
– Internally loads question metadata into:
• Hash Tables (O(1) lookup by ID)
• Arrays or Linked Lists for sequencing & randomization
– Supports CRUD on question bank
4. Attempt Evaluation Service
– Endpoint: /submitTest
– Validates answers against keyed data structures, calculates score
5. Leaderboard/Analytics Service
– Endpoints: /leaderboard, /stats
– Aggregates results, computes rankings, trend analytics
c. Data Layer
• Primary Database (MySQL/PostgreSQL)
– Tables: users, questions, tests, submissions, scores
• Cache Layer (Redis or Memcached)
– Caches hot question data and leaderboard results
• File Storage (if media questions): S3 or local FS
Relationships and Data Flows
1. Browser → API Gateway: Authenticate & fetch question list
2. API Gateway → Appropriate Service Module
3. Service Module ↔ Database / Cache for read/write
4. Service Module returns JSON responses to Client
5. Client updates UI, persists tokens in LocalStorage
Architectural Patterns and Principles
• Layered Architecture: separation of concerns between Presentation, Application, and Data
• Modular Services: each business function in its own bounded context
• Dependency Injection / Inversion of Control in PHP services (using a framework)
• Caching for performance, database normalization for integrity
• Statelessness: backend services treat each request independently (facilitates scaling)
Technologies and Frameworks
• Client: Vanilla JS or modern framework (React/Vue/Angular), Bootstrap/CSS3
• Backend: PHP 7+ with a micro-framework (Slim, Lumen, Laravel API)
• DB: MySQL/PostgreSQL
• Cache: Redis
• Authentication: JWT or PHP sessions stored in Redis
• REST over HTTPS