A multi-project application with a Quarkus backend and React frontend.
This project consists of two main components:
- Backend: A Quarkus-based Java application that provides REST API endpoints and WebSocket support.
- Frontend: A React application with TypeScript that consumes the backend APIs.
- Language: Java 21
- Framework: Quarkus
- Build Tool: Gradle
- Features:
- REST API endpoints with virtual threads
- WebSocket support
- Native compilation
- Kubernetes deployment configuration
- Docker containerization
- Dev services for testing
- Language: TypeScript
- Framework: React
- Build Tool: npm
- Features:
- REST API client
- WebSocket client
- No prerequisites required! The JBang wrapper will automatically install:
- JBang itself (if not already installed)
- Java 21
- Node.js 18+
- JDK 21
- Node.js 18+
- Docker (optional, for containerized deployment)
The project includes a JBang script that starts both the backend and frontend in development mode and opens a browser automatically:
-
Run the development script from the project root:
# If jbang is already installed: ./start_dev.java # If jbang is not installed: ./jbang start_dev.java
The first time you run this, JBang will install itself and download all required dependencies (Java 21 and Node.js) if they're not already on your system.
This will:
- Start the backend in Quarkus dev mode
- Start the frontend development server
- Open a browser to http://localhost:3000
- Display logs from both servers in the console
Press Ctrl+C to stop both servers.
If you prefer to run the components separately:
-
Navigate to the backend directory:
cd backend -
Run the application in development mode:
../gradlew quarkusDev
The backend will be available at http://localhost:8080
-
Navigate to the frontend directory:
cd frontend -
Install dependencies:
npm install
-
Run the application in development mode:
npm start
The frontend will be available at http://localhost:3000
The project includes a robot demonstration application (robo-demo) that showcases the Robot Wars API functionality by creating battles and moving robots around an arena.
To run the robot demo, use the provided script:
cd robo-demo
./start-battle.sh [OPTIONS]-u, --url URL: Base URL for the Robot Wars API (default:http://localhost:8080)-t, --time TIME: Time limit for the battle (e.g.,5m,30s) (default:5m)-s, --stop-on-crash: Stop the demo when the first robot crashes (default:false)-h, --help: Show help message
# Run with default settings (5 minutes, continue after crashes)
./start-battle.sh
# Run for 2 minutes and stop on first crash
./start-battle.sh --time 2m --stop-on-crash
# Run against a different API server
./start-battle.sh --url http://remote-server:8080
# Combine multiple options
./start-battle.sh --url http://localhost:8080 --time 30s --stop-on-crashYou can also run the robot demo application directly using Gradle:
cd robo-demo
../gradlew run --args="--url http://localhost:8080 --time 5m --stop-on-crash"Run the backend tests:
cd backend
../gradlew testThe backend uses Quarkus Dev Services for testing, which automatically provides containerized services (databases, message brokers, etc.) during test execution without manual setup.
Run the frontend tests:
cd frontend
npm testBuild the backend:
cd backend
../gradlew buildFor native build:
cd backend
../gradlew build -Dquarkus.package.type=native -Dquarkus.native.container-build=trueBuild the frontend:
cd frontend
npm run buildBuild the JVM Docker image:
cd backend
docker build -f src/main/docker/Dockerfile.jvm -t quarkus/robot-wars-backend-jvm .Build the native Docker image:
cd backend
docker build -f src/main/docker/Dockerfile.native -t quarkus/robot-wars-backend-native .GET /api/greeting: Returns a plain text greetingGET /api/greeting/json: Returns a JSON greeting
/chat/{username}: WebSocket endpoint for chat functionality
The arena is a 2D grid addressed by integer coordinates (x, y) with zero-based indices:
- Valid ranges:
0 <= x < arenaWidthand0 <= y < arenaHeight - Direction semantics used by the engine (and tests):
- NORTH (or N): increases Y by 1 per block
- SOUTH (or S): decreases Y by 1 per block
- EAST (or E): increases X by 1 per block
- WEST (or W): decreases X by 1 per block
- Diagonals are supported: NE (x+1, y+1), NW (x-1, y+1), SE (x+1, y-1), SW (x-1, y-1) per block
- Robots crash if they move out of bounds or into a wall position
- Robots spawn at random valid positions that avoid walls
- Movement is asynchronous: robots traverse one block per configured movement time (robotMovementTimeSeconds)
These conventions apply uniformly across the REST API, WebSocket state, and test scenarios.
This project includes GitHub Actions workflows for continuous integration and deployment:
- Backend CI: Builds, tests, and creates a Docker image for the backend
- Frontend CI: Builds, tests, lints the frontend code, and deploys to S3 on main branch
To enable the frontend deployment to S3, configure the following GitHub repository variables:
AWS_ROLE_ARN: The ARN of the AWS IAM role to assume for deployment
S3_BUCKET_ARN: The ARN of the S3 bucket for deployment (e.g.,arn:aws:s3:::my-bucket-name)- Alternatively, you can use
S3_BUCKET_NAMEwith just the bucket name
- Alternatively, you can use
BACKEND_URL: Backend URL for the production build (default:http://localhost:8080)CLOUDFRONT_DISTRIBUTION_ID: CloudFront distribution ID for cache invalidation (optional)
Note: The deployment uses af-south-1 as the AWS region to match the backend deployment.
- Go to your GitHub repository
- Click on Settings > Secrets and variables > Actions
- For secrets (like
AWS_ROLE_ARN):- Click on the Secrets tab
- Click New repository secret
- Add the required secrets listed above
- For variables (like
S3_BUCKET_ARN):- Click on the Variables tab
- Click New repository variable
- Add the required variables listed above
The AWS_ROLE_ARN should have the following permissions:
s3:PutObjects3:PutObjectAcls3:GetObjects3:DeleteObjects3:ListBucketcloudfront:CreateInvalidation(if using CloudFront)
The role should also have a trust policy that allows GitHub Actions to assume it using OpenID Connect.
Sample IAM policy and trust policy files are provided in the .github/ directory:
.github/aws-iam-policy.json: Sample IAM policy for S3 deployment permissions.github/aws-trust-policy.json: Sample trust policy for GitHub Actions OIDC
Replace the placeholders (YOUR-BUCKET-NAME, YOUR-ACCOUNT-ID, YOUR-GITHUB-USERNAME, YOUR-DISTRIBUTION-ID) with your actual values.
This project is licensed under the MIT License - see the LICENSE file for details.