How r-argentina-programa/kahoot-clone works
Project type and purpose
• This is a full-stack, real-time “Kahoot” clone built with React (front-end), Node.js/Express + Socket.IO (back-end), and a relational database managed via CLI migrations/seeders.
• Core features: Hosts select and run quizzes; Users join games; real-time question delivery and score updates via WebSockets; persistent storage for trivias, questions, answers, players, games, and player answers.
File structure
• Monorepo with two top-level apps:
• back-end/ – Node.js service
• front-end/ – React app with Cypress e2e tests
• back-end layers under src/:
• config/ (DI setup)
• controller/ (HTTP + Socket.IO handlers)
• service/ (business logic)
• repository/ (data access abstraction)
• model/entity/mapper (ORM models, domain entities, DTO mapping)
• cli/ (DB migrations & seeders)
• front-end under src/:
• pages/ (route components for Host and User flows)
• components/ (UI widgets)
• assets, styles, index.js (app bootstrap)
• cypress/ (E2E tests)
• Key config/build files: package.json at root, back-end/.env.dist, front-end/public, etc.
README for additional insights
• Specifies real-time interaction via Socket.IO
• “npm run dev” concurrently runs Express (port 3001) and React dev server (port 3000)
• Host and User UIs communicate with the same back-end
Main components and interactions
a. Components:
1. Browser (Hosts and Users)
2. React Front-end (SPA served from Node or static build)
3. Node.js Back-end (Express + Socket.IO server)
4. Relational Database (PostgreSQL or similar via Sequelize)
5. CLI Tool (for migrations & seeding)
6. External Services (optional: Codeship CI)
b. Relationships & Data Flows:
• Browser ↔ React Front-end (served as JS/CSS/HTML)
• React ↔ Back-end via:
• REST HTTP API (for listing trivias, initial game setup)
• WebSocket channel (Socket.IO) for real-time question push, answer submissions, score broadcasts
• Back-end layers: Controller → Service → Repository → Database
• CLI Tool → Database (migrations/seeders)
• CI Server → GitHub → Auto-run tests (back-end unit tests, front-end Cypress e2e)
c. Architectural patterns & design principles:
• Layered MVC-style server architecture with clear separation: HTTP handlers (controllers), business logic (services), persistence (repositories), and domain mapping (mappers/entities/models)
• Dependency Injection configured in config/di.js
• Real-time event bus with Socket.IO integrated into Express controllers
• Monorepo organizing client & server side by domain
d. Key technologies:
• Front-end: React, React Router, CSS modules, Cypress for e2e
• Back-end: Node.js, Express, Socket.IO, Sequelize (migrations, models), Jest for unit tests
• CI: Codeship