How ledinhtuyen/ailatrieuphu works
Project type and purpose
• This is a full-stack, real-time networked trivia game (“Ai là triệu phú”) with a Qt/QML C++ client and a C server backed by MySQL.
• The client handles UI, game flow, asset playback, while the server manages authentication, question distribution, PvP matchmaking, scoring, and persistence.
File structure
• Top-level:
• client/ – Qt application
– qml/ – all QML views (LoginPage.qml, GameScreen.qml, popups, etc.)
– src/ – C++ glue (BackEnd.cpp, Utils.c, main.cpp)
– headers/ – BackEnd.h, Utils.h
– assets/ – audio clips, sprites, fonts
• server/ – C network server
– server.c/.h – main logic (socket listening, client threads, game rules)
– config – config file for DB/port
– database.sql – schema & seed data
• Build scripts: Makefile (server, client), qmake project (.pro).
• Runtime dependencies: Qt 5.12 framework, libmysqlclient, OpenGL library (libgl1), MySQL server.
README
• Confirms tech stack: C/C++ for backend logic, QML/Qt for UI, MySQL for storage.
• Describes features: register/login, solo/PvP modes.
• Explains setup: compile server, import database, compile client, run with server IP/port.
a. Main components:
• Client Application
– QML UI Layer (Views & Popups)
– C++ Backend Layer (BackEnd.cpp & Utils.c)
– Asset Manager (audio, sprites, fonts)
– Network Module (QtNetwork or POSIX sockets)
• Server Application
– Network Listener (accepts client TCP connections)
– Game Engine (authentication, question dispatcher, matchmaking)
– DB Access Layer (MySQL client library)
• MySQL Database Server
– Users table, Questions table, Sessions/logs
• External Dependencies
– Qt Framework, OpenGL, libmysqlclient
b. Relationships & interactions:
1. Client UI triggers actions (login, answer, request question) → Backend Layer via Qt signals
2. Backend Layer serializes requests → Network Module → TCP → Server
3. Server Network Listener → hands off to Game Engine (per-client threads or event loop)
4. Game Engine issues queries via DB Access Layer → MySQL Server → returns data
5. Server composes response (authentication result, question payload, opponent’s answer) → back to Client
6. Client Backend updates QML UI; assets played accordingly
c. Architectural patterns & principles:
• Client: Model-View separation (QML views vs. C++ backend logic)
• Event-driven communication using Qt signals/slots or callbacks
• Server: request-response cycle + concurrent client handling (thread or non-blocking I/O)
• Thin server: business logic + DB persistence
• Layered design: UI → application logic → transport → persistence
d. Key technologies & libraries:
• Qt/QML for client UI
• C++ (BackEnd.cpp) & C (Utils.c) in client
• POSIX sockets or QtNetwork for client-server comms
• C network server with libmysqlclient-dev
• MySQL 5.x/8.x for data storage
Diagramming recommendations
• Rounded rectangles for UI components (QML pages)
• Rectangles for code modules (BackEnd, Utils, Game Engine)
• Clouds or hexagons for external frameworks (Qt, OpenGL)
• from QML → C++ backend → network → server → DB and back
• between server’s matchmaking module and multiple client modules for PvP
Detail
• Server’s sub-modules: Network Listener, Authentication Service, Question Service, Matchmaking Service, Persistence Service
• Config file as a parameter source for server startup