A beginner-friendly game account marketplace built with Spring Boot 3.5.0 and Java 17. Sellers can list game accounts, buyers can browse and purchase, and admins manage the platform.
Game Account Shop is a Vietnamese marketplace platform where:
- Sellers list game accounts (LiΓͺn Minh Huyα»n ThoαΊ‘i, Valorant, etc.)
- Buyers browse listings, search/filter, and purchase via PayOS payment gateway
- Admins approve listings, verify payments, and deliver credentials via email
Target Audience: Newbie developers learning Spring Boot
Technology Stack:
- Backend: Java 17, Spring Boot 3.5.0, Spring Data JPA, Spring Security, MySQL 8.0
- Frontend: Thymeleaf, Bootstrap 5.3, HTML5/CSS3/JavaScript
- Database: MySQL 8.0 with Flyway migrations
- Build: Maven 3.x
Before running this project, ensure you have:
| Tool | Version | Command to Check |
|---|---|---|
| Java JDK | 17+ | java -version |
| Maven | 3.8+ | mvn -version |
| MySQL | 8.0+ | mysql --version |
| Git | Latest | git --version |
git clone <repository-url>
cd fcode-challenge-3This section guides you through setting up MySQL 8.0 for the Game Account Shop project.
Check if MySQL is installed:
# Windows
mysql --version
# Linux/Mac
mysql --versionExpected output:
mysql Ver 8.0.xx for Win64 on x86_64
If MySQL is NOT installed:
Windows:
- Go to https://dev.mysql.com/downloads/mysql/
- Download "MySQL Community Server" 8.0
- Run the installer
- Use default settings (or set root password to something you'll remember)
- Finish installation
Linux (Ubuntu/Debian):
sudo apt update
sudo apt install mysql-server
sudo systemctl start mysql
sudo systemctl enable mysqlMac (using Homebrew):
brew install mysql
brew services start mysqlWindows:
- Open "Services" (press
Win + R, typeservices.msc) - Find "MySQL80" or "MySQL"
- Right-click β "Start"
Or using command line:
net start MySQL80Linux:
sudo systemctl start mysqlMac:
brew services start mysqlOption A: Let the application create it automatically (Easiest)
The application is configured to create the database automatically if it doesn't exist. You don't need to do anything!
Option B: Create manually using MySQL Command Line
- Open MySQL Command Line:
Windows:
- Open Command Prompt
- Type:
mysql -u root -p - Enter your MySQL root password (press Enter if no password set)
Linux/Mac:
mysql -u root -p- Create the database:
CREATE DATABASE gameaccountshop
CHARACTER SET utf8mb4
COLLATE utf8mb4_unicode_ci;- Verify database was created:
SHOW DATABASES;You should see gameaccountshop in the list.
- Exit MySQL:
EXIT;Test that you can connect to the database:
mysql -u root -p gameaccountshopIf successful, you'll see:
Server version: 8.0.xx MySQL Community Server
...
mysql>
Type EXIT; to leave.
The application uses these default credentials (already configured):
# In: game-account-shop/src/main/resources/application.yml
spring:
datasource:
username: root
password: passwordIf your MySQL root password is different:
- Open
game-account-shop/src/main/resources/application.ymlin a text editor - Find the
datasourcesection - Change
password: passwordtopassword: YOUR_MYSQL_PASSWORD
Example:
spring:
datasource:
url: jdbc:mysql://localhost:3306/gameaccountshop
username: root
password: MySecretPassword123 # Change this!Issue: "Access denied for user 'root'@'localhost'"
Solution: Reset MySQL root password
Windows:
- Stop MySQL service
- Create a text file with:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'NewPassword123'; - Save as
reset.sql - Run:
mysqld --init-file=C:\\path\\to\\reset.sql - Start MySQL service
Linux:
sudo mysql
ALTER USER 'root'@'localhost' IDENTIFIED BY 'NewPassword123';
FLUSH PRIVILEGES;
EXIT;**Issue: "Can't connect to MySQL server on 'localhost'"
Solution: MySQL server is not running
Windows:
net start MySQL80Linux:
sudo systemctl start mysql**Issue: "Unknown database 'gameaccountshop'"
Solution: Database doesn't exist yet. The app will create it automatically, or you can create manually (see Step 2.3).
This project uses Flyway to manage database schema automatically.
What happens on first run:
- Application starts
- Flyway checks if migrations table exists
- If not, it creates
flyway_schema_historytable - Runs migration script:
V1__Create_Database_Tables.sql - Creates 4 tables:
users,game_accounts,transactions,reviews
You don't need to manually create tables! Flyway handles everything.
View migration script:
# Location: game-account-shop/src/main/resources/db/migration/
cat V1__Create_Database_Tables.sqlAfter first application run, verify tables were created:
mysql -u root -p gameaccountshop
SHOW TABLES;Expected output:
+---------------------------+
| Tables_in_gameaccountshop |
+---------------------------+
| flyway_schema_history |
| game_accounts |
| reviews |
| transactions |
| users |
+---------------------------+
Check default admin user was created:
SELECT id, username, role FROM users;Expected output:
+----+----------+--------+
| id | username | role |
+----+----------+--------+
| 1 | admin | ADMIN |
+----+----------+--------+
Summary:
- β Install MySQL 8.0 (if not installed)
- β Start MySQL server
- β Database will be created automatically (optional manual creation)
- β
Configure password in
application.ymlif different frompassword - β Flyway will create tables automatically on first run
- β Default admin account created automatically
Step 3.1: Copy the example configuration file
# Navigate to the resources directory
cd game-account-shop/src/main/resources
# Copy the example configuration
cp application.yml.example application.ymlStep 3.2: Edit application.yml with your settings
Open game-account-shop/src/main/resources/application.yml in a text editor and configure:
spring:
datasource:
username: root
password: YOUR_MYSQL_PASSWORD # Change to your MySQL root password
# Email configuration (required for listing approval notifications)
mail:
username: your-email@gmail.com # CHANGE THIS: Your Gmail address
password: xxxx xxxx xxxx xxxx # CHANGE THIS: Your 16-character App Password
# ImgBB Image Upload API (optional - for image upload feature)
imgbb:
api-key: YOUR_IMGBB_API_KEY # Get free key from https://api.imgbb.com/
# PayOS Payment Configuration (required - for payment processing)
payos:
client-id: YOUR_PAYOS_CLIENT_ID # Your PayOS Client ID from my.payos.vn
api-key: YOUR_PAYOS_API_KEY # Your PayOS API Key
checksum-key: YOUR_PAYOS_CHECKSUM_KEY # Your PayOS Checksum KeyConfiguration Options:
| Setting | Description | Default |
|---|---|---|
spring.datasource.password |
MySQL root password | YOUR_MYSQL_PASSWORD |
spring.mail.username |
Gmail address for sending emails | your-email@gmail.com |
spring.mail.password |
Gmail App Password (see below) | xxxx xxxx xxxx xxxx |
imgbb.api-key |
ImgBB API key for image upload | YOUR_IMGBB_API_KEY |
Setting up Gmail for Email Notifications (Required):
The application sends email notifications to sellers when their listings are approved or rejected. To enable this:
-
Enable 2-Step Verification on your Google Account:
- Go to https://myaccount.google.com/security
- Find "2-Step Verification" and enable it
-
Create an App Password:
- Go to https://myaccount.google.com/apppasswords
- Select "Mail" and "Other (Custom name)"
- Enter a name like "GameShop"
- Click "Generate"
- Copy the 16-character password (e.g.,
abcd efgh ijkl mnop)
-
Configure in application.yml:
spring: mail: username: your-email@gmail.com # Your Gmail address password: uinkjxbccstgvtzv # Paste the 16-character App Password WITHOUT spaces
Important: Remove all spaces from the App Password when pasting into
application.yml. For example, if Google gives youabcd efgh ijkl mnop, enter it asabcdefghijklmnop.
Note: If you don't configure email, listing approval/rejection notifications will fail silently in the background.
Getting an ImgBB API Key (optional):
- Go to https://imgbb.com/
- Sign up for a free account
- Go to API Settings
- Copy your API key
- Paste it in
application.yml
Note: If you don't configure the ImgBB API key, the image upload feature will not work. You can add it later if needed.
Setting up PayOS for Payment Processing (Required):
The application uses PayOS as the payment gateway for processing purchases. To enable payments:
-
Create a PayOS Account:
- Go to https://my.payos.vn
- Sign up for a new account
- Verify your email address
-
Create a Payment Channel:
- Navigate to the "Payment Channels" section
- Click "Create New Channel"
- Select your bank and enter your bank account details
- Complete the verification process
-
Get Your API Credentials:
- From the Payment Channels section, copy:
- Client ID - Used for API authentication
- API Key - Used for API authentication
- Checksum Key - Used for HMAC SHA256 signature verification
- From the Payment Channels section, copy:
-
Configure in application.yml:
payos: client-id: your_actual_client_id_here api-key: your_actual_api_key_here checksum-key: your_actual_checksum_key_here base-url: https://api-merchant.payos.vn
-
Security Best Practices:
- NEVER commit actual API keys to git
- Use environment variables in production:
export PAYOS_CLIENT_ID=your_actual_client_id export PAYOS_API_KEY=your_actual_api_key export PAYOS_CHECKSUM_KEY=your_actual_checksum_key
- Add
.envto.gitignore - Use different credentials for development and production
-
Environment Variable Setup (Production):
Linux/Mac:
export PAYOS_CLIENT_ID=your_actual_client_id export PAYOS_API_KEY=your_actual_api_key export PAYOS_CHECKSUM_KEY=your_actual_checksum_key
Windows (Command Prompt):
set PAYOS_CLIENT_ID=your_actual_client_id set PAYOS_API_KEY=your_actual_api_key set PAYOS_CHECKSUM_KEY=your_actual_checksum_key
Windows (PowerShell):
$env:PAYOS_CLIENT_ID="your_actual_client_id" $env:PAYOS_API_KEY="your_actual_api_key" $env:PAYOS_CHECKSUM_KEY="your_actual_checksum_key"
-
Test Configuration:
- After configuring, start the application
- Try to purchase a listing
- Verify that QR code is generated with PayOS branding
- Check the payment page displays correctly
Note: If you don't configure PayOS credentials, the payment feature will fail with an error message. You can add it later, but payment processing will not work without it.
For more details: See docs/payos-integration.md for complete PayOS API documentation.
Navigate to project directory first:
cd game-account-shopThen run using Maven wrapper:
# Windows
mvnw.cmd spring-boot:run
# Linux/Mac
./mvnw spring-boot:runOr using installed Maven (if you have Maven installed globally):
mvn spring-boot:runLook for this log message:
=================================================================
DEFAULT ADMIN ACCOUNT CREATED
Username: admin
Password: admin123
=================================================================
Open your browser: http://localhost:8080
| Field | Value |
|---|---|
| Username | admin |
| Password | admin123 |
| Role | ADMIN |
game-account-shop/
βββ src/
β βββ main/
β β βββ java/com/gameaccountshop/
β β β βββ GameAccountShopApplication.java # Main entry point
β β β βββ config/ # Configuration classes
β β β β βββ SecurityConfig.java # Security + BCrypt
β β β β βββ DataInitializer.java # Creates default admin
β β β βββ controller/ # Web controllers
β β β βββ service/ # Business logic
β β β βββ repository/ # Data access (JPA)
β β β βββ entity/ # Database entities
β β β β βββ User.java
β β β βββ enums/ # Enumerations
β β β β βββ Role.java # USER, ADMIN
β β β βββ dto/ # Data Transfer Objects
β β βββ resources/
β β βββ application.yml # Application config
β β βββ db/migration/ # Flyway migrations
β β β βββ V1__Create_Database_Tables.sql
β β βββ templates/ # Thymeleaf templates
β β βββ static/ # CSS, JS, images
β βββ test/ # Unit tests
βββ pom.xml # Maven dependencies
βββ mvnw, mvnw.cmd # Maven wrapper scripts
βββ .mvn/ # Wrapper files
| Table | Description |
|---|---|
users |
User accounts (buyers, sellers, admins) |
game_accounts |
Game account listings (column account_rank for rank level) |
transactions |
Purchase transactions |
reviews |
Seller ratings and reviews |
Note: The game_accounts table uses account_rank instead of rank to avoid MySQL reserved keyword conflicts.
Game Account Status:
PENDING β APPROVED β SOLD
β
REJECTED
Transaction Status:
PENDING β VERIFIED
User Roles:
USER (can be seller or buyer)
ADMIN
| Document | Location | Description |
|---|---|---|
| Database Schema | docs/database-schema.md |
Complete database design |
| PayOS Integration | docs/payos-integration.md |
Payment gateway setup and API documentation |
| Project Context | _bmad-output/planning-artifacts/project-context.md |
Coding standards & rules |
| Architecture | _bmad-output/planning-artifacts/architecture.md |
System architecture decisions |
| Epics & Stories | _bmad-output/planning-artifacts/epics.md |
Feature breakdown (18 stories) |
| Sprint Status | _bmad-output/implementation-artifacts/sprint-status.yaml |
Development progress |
Follow the project-context.md rules:
-
Naming Conventions:
- Classes:
PascalCaseβUserService - Methods:
camelCaseβgetUserById - Database:
snake_caseβcreated_at,seller_id
- Classes:
-
Architecture Pattern (Strict Layered):
Browser β Controller β Service β Repository β Database -
Security:
- BCryptPasswordEncoder with 10 rounds minimum
- Never store plaintext passwords
- Session timeout: 30 minutes
-
Error Messages:
- All user-facing messages in Vietnamese
- Example:
"TΓͺn ΔΔng nhαΊp hoαΊ·c mαΊt khαΊ©u khΓ΄ng ΔΓΊng"
# Use the BMAD workflow
/bmad:bmm:workflows:create-story# Execute a story
/bmad:bmm:workflows:dev-story
# Code review
/bmad:bmm:workflows:code-reviewRun tests:
mvn testRun with coverage:
mvn clean test jacoco:reportEdit game-account-shop/src/main/resources/application.yml:
server:
port: 8081 # Change to available port- Verify MySQL is running:
mysql --version - Check credentials in
game-account-shop/src/main/resources/application.yml - Ensure database exists:
CREATE DATABASE gameaccountshop;
Drop and recreate database:
DROP DATABASE gameaccountshop;
CREATE DATABASE gameaccountshop CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;cd game-account-shop
./mvnw clean compileMake sure you're in the game-account-shop directory:
# Check current directory
pwd
# Should show: .../fcode-challenge-3
cd game-account-shop
# Now run
mvnw.cmd spring-boot:run| Epic | Status | Stories Done |
|---|---|---|
| Epic 1: Basic Authentication | Completed | 3/3 (β Initialize, β DB Setup, β Auth Logic) |
| Epic 2: Listings & Ratings | Backlog | 0/5 |
| Epic 3: Simple Buying | Backlog | 0/3 |
| Epic 4: Dashboard & Profiles | Backlog | 0/3 |
β Backend Status: Running successfully on http://localhost:8080
- Database connected and migrated (Flyway V1 applied)
- Default admin account created (admin/admin123)
- User Registration & Login implemented (Spring Security + Thymeleaf)
This is a learning project for newbie developers. To contribute:
- Check
sprint-status.yamlfor available stories - Pick a story from backlog
- Run
/bmad:bmm:workflows:dev-storyto implement - Run
/bmad:bmm:workflows:code-reviewfor review - Update sprint status when complete
For questions or issues:
- Review
docs/database-schema.mdfor data model questions - Check
project-context.mdfor coding standards - Refer to
epics.mdfor feature specifications
This project is for educational purposes.
Built with β€οΈ for newbie developers learning Spring Boot