How duonghuuthanh/cs2301quizapp works
Project type and purpose
• This is a Java desktop application (JavaFX-based) for administering and practicing quizzes.
• It follows a layered MVC-style architecture with controllers for the UI, service classes for business logic, POJOs as data models, utilities for database connectivity, and FXML/CSS for the presentation.
File structure
• Top-level modules: QuizAppV1 and QuizAppV2 (two iterations of the same app).
• src/main/java/com/dht/quizappvX: entry point App.java and four controllers (PrimaryController, SecondaryController, QuestionsController, PracticeController).
• src/main/java/com/dht/services: service interfaces and implementations (CategoryServices, LevelServices, QuestionServices, plus decorators in V1).
• src/main/java/com/dht/pojo: data models (Category, Level, Question, Choice).
• src/main/java/com/dht/utils: helpers for alerts, stages, database connector (MyConnector/JdbcConnector), and theme management (Factory pattern).
• src/main/resources/com/dht/quizappvX: FXML views and CSS theme files.
• quizdb.sql at top level defines the relational schema.
(sparse) README
• Name: CS2301QuizApp – implies an academic project or sample.
• No further architectural notes—structure must be inferred from file tree.
a. Main components
1. Presentation Layer
– JavaFX FXML files (primary.fxml, secondary.fxml, questions.fxml, practice.fxml)
– Controllers (PrimaryController, SecondaryController, QuestionsController, PracticeController)
2. Business Logic Layer
– Service interfaces and implementations (CategoryServices, LevelServices, QuestionServices, decorators)
3. Data Access Layer
– JdbcConnector/MyConnector
– SQL schema (quizdb.sql)
4. Domain Model
– POJOs: Question, Choice, Category, Level
5. Themes Engine
– ThemeFactory + concrete factories (Dark, Light, Default)
– ThemeManager
6. External Resource
– SQLite/MySQL database (as defined by quizdb.sql)
b. Relationships and interactions
1. App.java initializes JavaFX and injects dependencies (ThemeManager, Services, Connectors).
2. Controllers receive user events from FXML views and call corresponding Services.
3. Services issue SQL queries via the JdbcConnector to the database.
4. Results are mapped into POJOs and returned to Controllers.
5. Controllers update the UI, possibly switching scenes via MyStage.
6. ThemeManager applies CSS themes at startup or on user request using Factory pattern.
c. Architectural patterns/design principles
• MVC separation: FXML + Controllers, Service layer, Domain models
• Factory pattern for theme selection
• Decorator pattern (V1) to extend QuestionServices with filtering (Keyword, Limit)
• Single responsibility: each package handles one concern (pojo, services, utils, themes)
d. Key technologies/frameworks
• Java 11+ (module-info.java present)
• JavaFX (FXML, CSS)
• JDBC (via custom connector)
• Maven build (pom.xml)