How hoanghai0810/gvdqg works
Project Type & Purpose
• This is a full-stack, three-tier web application (“Client-Server-Database”) for managing a national football championship (GVDQG).
• Frontend: HTML/CSS/JavaScript (Bootstrap, EJS templates) served by Express.
• Backend: Node.js + Express.js + Sequelize ORM.
• Database: MySQL.
File Structure Analysis
• src/
• config/: DB connection (connectDB.js), view engine setup (ViewEngine.js), environment config (config.json, .env).
• controllers/: request handlers (homeController.js).
• route/web.js: defines HTTP endpoints and ties them to controllers.
• services/: business logic and generic CRUD (CRUDService.js).
• models/: Sequelize models representing tables (user, team, player, match, statistics, allcode). index.js initializes associations.
• migrations/ & seeders/: database schema migrations & initial data.
• views/: EJS templates for pages (login, dashboard for Admin/Manager, CRUD pages).
• public/: static assets (CSS, JS, images, widgets).
• insert/: custom scripts to bulk-insert domain entities (players, teams, coaches, matches, parameters).
• sever.js (entry point): wires up Express, middleware, routing, DB sync, view engine.
Key Architectural Patterns
• Three-Tier Separation:
• Presentation Layer (Client via EJS + static files)
• Application Layer (Express controllers, services)
• Data Layer (Sequelize ORM + MySQL)
• MVC flavor: Models (Sequelize), Views (EJS), Controllers (Express handlers).
• Modular routing and service-oriented design: controllers delegate to services which interact with models.
Main Components & Interactions
A. Client Tier
• Web Browser: issues HTTP/HTTPS requests to server.
• Static Assets: CSS, JS, images under /public served by Express static middleware.
• EJS Views: rendered server-side and sent as HTML.
B. Server Tier
• Express.js HTTP Server (sever.js)
• Middleware: bodyParser, static file serving, session/auth (if any).
• Router (src/route/web.js): maps URL paths to controller methods.
• Controllers: handle requests, validate input, call services, render views or return JSON.
• Services (CRUDService.js, domain-specific logic): encapsulate business rules (team registration, scheduling algorithm, result updating, report generation).
• ORM Layer: Sequelize models and associations (src/models) map to database tables.
• Migrations & Seeders: define and evolve DB schema and populate reference data.
C. Database Tier
• MySQL: persistent storage for users, teams, players, matches, statistics, configuration parameters.
• Access via Sequelize (connectDB.js).
D. External / Optional Services
• (None explicitly in codebase; could include email or notification in the future.)
Detailed Elements
• Tier boundaries and module groupings.
• Tech stack annotations (e.g., “Node.js vX”, “Express.js”, “Sequelize ORM”, “MySQL 8”).
• Notes on configuration files (.env, config.json) feeding into DB and view-engine setup.
• Distinction between dynamic page rendering (EJS) and client-side static assets.