How harutouizumi/group12 works
1. System shape
- AuctionHub is a single Java 17/Maven codebase with two runtime roles: a JavaFX client and an optional TCP server.
- Persistence is via SQLite (auction.db in production, test_auction.db in tests).
- The same project supports both standalone local execution and client–server multi-machine execution.
2. Entry points and launch paths
- auction.MainApp is the client entry point.
- auction.server.ServerMain / AuctionServer start the backend server.
- Shell/batch scripts (start.sh, run_server.sh, etc.) wrap build and launch concerns, but do not change the core architecture.
3. Presentation layer
- The UI is built with JavaFX 21 using a mix of FXML and Java-based pages/controllers.
- Main UI structure lives under auction.ui: pages, components, controller, and MainLayout.
- login.fxml and auction_list.fxml are the main FXML-bound views; style.css provides shared styling.
4. Session, login, and role-based UI
- auction.session.Session holds the current authentication state and user context.
- The application distinguishes ADMIN, SELLER, and BIDDER roles through the model layer.
- Page classes such as AdminPage, SellerProfilePage, BidderProfilePage, and ProfilePage indicate role-specific navigation and functionality.
5. Domain model
- Core entities are under auction.model, centered on User, Auction, Item, and BidTransaction.
- Item has category-specific subclasses: ElectronicsItem, ArtItem, and VehicleItem.
- AuctionStatus models lifecycle state, while Admin, Seller, and Bidder specialize user behavior.
6. Factories and object creation
- UserFactory and ItemFactory create role- and category-specific model instances.
- These factories are the main boundary for translating user input or database data into typed domain objects.
7. Persistence boundary
- Data access is split by DAO interfaces (AuctionDAO, UserDAO) and concrete implementations in dao.impl.
- auction.db.Database and DatabaseInit manage SQLite connection/configuration and initial seeding.
- The README indicates default accounts are created automatically on first run, and passwords are stored hashed via PasswordUtil (SHA-256).
8. Bid transaction flow
- The critical business operation is placeBid, implemented in AuctionDAOImpl.
- That flow validates auction status, balance, and bid rules; updates the current leader; refunds the previous leader; deducts the new bid amount; and records the transaction in one database transaction.
- This makes the DAO layer the central transactional boundary for auction state changes.
9. Server-side networking
- In client–server mode, clients communicate through auction.network and auction.server.
- Protocol defines the message contract between client and server.
- ClientHandler handles each connected client thread, AuctionServer accepts connections, and ServerBroadcaster fan-outs updates to all clients.
10. Real-time update path
- A bid submitted from the UI reaches the server, is persisted, then triggers a broadcast back to all connected clients.
- This is the key runtime data flow for the “realtime bidding” behavior described in the README.
- ServerConnection and ConnectionManager represent the client-side transport boundary.
11. Background services and time-based behavior
- AuctionScheduler handles periodic auction maintenance, including automatic closing/checking of auctions.
- The README also mentions anti-sniping behavior and cross-process refresh support; those concerns are reflected in service classes such as CrossProcessRefreshService.
- LogService is the shared logging boundary for operational events.
12. Observer-driven notifications
- BidEventManager and BidObserver implement an observer pattern around bid events.
- LogObserver and UIRefreshObserver show that bid changes can trigger both logging and UI refresh actions.
- This sits between business logic and side effects, especially for real-time feedback.
13. Error handling
- Domain-specific exceptions are explicit: InvalidBidException, AuctionClosedException, InsufficientBalanceException, and AuthenticationException.
- These exceptions define the main failure boundaries for bidding and login flows, and they help the UI and server return user-facing errors cleanly.
14. Quality and verification
- Unit tests cover DAO behavior, protocol handling, factories, observer logic, scheduler behavior, exceptions, and password hashing.
- CI is configured via GitHub Actions, so the repository has automated build/test validation around these core layers.
15. How to draw the architecture
- A useful diagram should show: JavaFX UI → session/controller → client network layer → server handler → DAO/SQLite, with a side path for broadcast/observer notifications back to all clients.
- Keep the DAO + SQLite boundary as the persistence core, and the server/broadcast layer as the concurrency/realtime core.
Main entry points: ClientHandler.java Client handler · AuctionDAOImpl.java Auction DAO · MainLayout.java Main layout · controller Controllers
Components 21
Presentation
JavaFX UI, pages, and session state.
- Main app · Client entry point.
src/main/java/auction/MainApp.java - Main layout · Top-level JavaFX navigation and composition.
src/main/java/auction/ui/MainLayout.java - Pages · Role-specific and workflow screens.
src/main/java/auction/ui/pages - Components · Reusable JavaFX widgets and small view parts.
src/main/java/auction/ui/components - Controllers · FXML-bound UI controllers for login and listings.
src/main/java/auction/ui/controller - Session · Current user context and login state.
src/main/java/auction/session/Session.java
Runtime
Client networking and server-side request handling.
- Client conn · Client-side connection manager for server communication.
src/main/java/auction/client/ConnectionManager.java - Server main · Backend launcher for the TCP server.
src/main/java/auction/server/ServerMain.java - Auction server · Accepts client connections and coordinates server runtime.
src/main/java/auction/server/AuctionServer.java - Client handler · Handles one connected client connection.
src/main/java/auction/server/ClientHandler.java - Broadcaster · Pushes server updates to connected clients.
src/main/java/auction/server/ServerBroadcaster.java - Protocol · Shared client-server message format.
src/main/java/auction/network/Protocol.java
Core
Domain model, factories, persistence, and services.
- Auction DAO · Auction queries and transactional bid updates.
src/main/java/auction/dao/impl/AuctionDAOImpl.java - User DAO · User lookup and account persistence.
src/main/java/auction/dao/impl/UserDAOImpl.java - SQLite DB · Database connection and initialization boundary.
src/main/java/auction/db/Database.java - Domain model · Users, auctions, items, and bid transactions.
src/main/java/auction/model - Factories · Creates typed users and item variants.
src/main/java/auction/factory - Scheduler · Background auction maintenance and closing.
src/main/java/auction/service/AuctionScheduler.java - Refresh service · Supports cross-process refresh behavior.
src/main/java/auction/service/CrossProcessRefreshService.java
Support
Utility and operational boundaries.
- Log service · Shared logging boundary for operational events.
src/main/java/auction/service/LogService.java - Password util · Password hashing utility used for stored credentials.
src/main/java/auction/util/PasswordUtil.java
Connections 21
- Main app → Main layout: starts · Launches the JavaFX shell.
- Main layout → Pages: navigates · Hosts role-specific screens.
- Main layout → Components: composes · Uses reusable UI widgets.
- Pages → Controllers: binds · FXML pages connect to controllers.
- Controllers → Session: reads state · Controllers consult login and role context.
- Controllers → Client conn: sends bid · UI actions reach the transport layer.
- Client conn → Protocol: encodes · Client messages follow the shared protocol.
- Server main → Auction server: boots · Server entry starts the backend.
- Auction server → Client handler: spawns · Creates a worker per connected client.
- Client handler → Protocol: decodes · Handles protocol messages from clients.
- Client handler → Auction DAO: persists bid · Bid operations reach the transactional DAO.
- Client handler → Broadcaster: broadcasts · Server updates fan out after state changes.
- Auction DAO → SQLite DB: uses · DAO reads and writes SQLite.
- User DAO → SQLite DB: uses · User persistence goes through SQLite.
- Auction DAO → Domain model: maps · Persists domain entities and auction state.
- User DAO → Factories: creates · Converts stored data into typed users.
- Factories → Domain model: instantiates · Builds concrete domain objects.
- Scheduler → Auction DAO: closes auctions · Background maintenance updates auction state.
- Refresh service → Broadcaster: triggers sync · Supports cross-process refresh behavior.
- Log service → Broadcaster: records events · Operational events are logged around updates.
- Password util → User DAO: hashes · Passwords are hashed before persistence.