Casino Roulette is a Cuphead-style web app that simulates an roulette game where users bet their souls. Register, deposit souls, place bets, and climb the leaderboard 😈.
- Features
- Technologies
- Project Structure
- Getting Started
- API Endpoints
- Running Tests
- Contributing
- License
- User Authentication: Registration and login using JWT.
- Soul Deposits: Users can deposit souls to their account.
- Dynamic Betting: Place bets on colors, even/odd, high/low, or specific numbers.
- Leaderboard: View top players based on soul balance.
- Interactive UI: Frontend with HTMX and Alpine.js.
- Cuphead Aesthetic: Unique style inspired by Cuphead.
- Containerized Deployment: Easy setup and deployment using Docker Compose.
- Backend: Golang
- Frontend: HTMX, Alpine.js
- Database: PostgreSQL
- Containerization: Docker, Docker Compose
- Authentication: JWT (JSON Web Tokens)
- Web Framework: Chi
casino-roulette
├── backend
│ ├── cmd
│ │ └── main.go
│ ├── Dockerfile
│ ├── go.mod
│ ├── go.sum
│ └── pkg
│ ├── api
│ ├── auth
│ ├── db
│ ├── middleware
│ ├── models
│ └── roulette
├── docker-compose.yml
├── frontend
│ ├── Dockerfile
│ ├── fonts
│ │ ├── CupheadFelix-Regular-merged.ttf
│ │ ├── CupheadHenriette-A-merged.ttf
│ │ ├── CupheadMemphis-Medium-merged.ttf
│ │ ├── CupheadPoster-Regular.ttf
│ │ ├── CupheadVogue-Bold-merged.ttf
│ │ └── CupheadVogue-ExtraBold-merged.ttf
│ ├── images
│ │ ├── avatars
│ │ ├── devil.png
│ │ ├── leaderboard_icon.png
│ │ ├── logout_icon.png
│ │ ├── money_icon.png
│ │ ├── roulette_arrow.png
│ │ ├── roulette_circle.png
│ │ ├── roullete_icon.png
│ │ ├── skull_icon.png
│ │ ├── soul_icon.png
│ │ └── user_icon.png
│ ├── index.html
│ ├── leaderboard.html
│ ├── nginx.conf
│ ├── profile.html
│ ├── register.html
│ ├── roulette.html
│ ├── scripts
│ │ ├── avatar.js
│ │ └── script.js
│ ├── style.css
│ └── styles
│ ├── common.css
│ ├── leaderboard.css
│ ├── profile.css
│ ├── register.css
│ └── roulette.css
└── README.md
- Docker installed on your machine.
- Docker Compose installed.
-
Clone the repository:
git clone https://github.com/alik-r/casino-roulette.git cd casino-roulette
The project can be fully launched using Docker Compose, which sets up both the backend and frontend along with the PostgreSQL database.
-
Start the services:
docker-compose up --build
-
Access the application:
- Frontend: http://localhost:81
- Backend API: http://localhost:8080
If you prefer to run the backend and frontend separately without Docker Compose, follow these steps:
-
Navigate to the backend directory:
cd backend
-
Install dependencies:
go mod download
-
Set Environment Variables:
Create a
.env
file or set the following environment variables:DATABASE_URL=postgres://gambler:ilovegambling@localhost:5433/casino?sslmode=disable
JWT_SECRET=super-secret-jwt-key
-
Run the server:
go run cmd/main.go
The backend server will be running on http://localhost:8080.
-
Navigate to the frontend directory:
cd frontend
-
Serve Static Pages:
You can use any static file server. For example, using
nginx
:docker build -t casino-roulette-frontend . docker run -d -p 81:80 casino-roulette-frontend
Access the frontend at http://localhost:81.
-
Healthcheck
- URL:
/api/healthcheck
- Method:
GET
- Response:
- Status:
200 OK
- Body:
"OK"
- Status:
- URL:
-
Register
-
URL:
/api/register
-
Method:
POST
-
Request Body:
{ "username": "string", "email": "string", "password": "string", "avatar": "string" // Optional }
-
Response:
{ "token": "string", "message": "Registered successfully" }
-
-
Login
-
URL:
/api/login
-
Method:
POST
-
Request Body:
{ "email": "string", "password": "string" }
-
Response:
{ "token": "string" }
-
All protected endpoints require the Authorization
header with a valid JWT token:
Authorization: Bearer <token>
-
Get User Information
-
URL:
/api/user
-
Method:
GET
-
Response:
{ "username": "string", "email": "string", "avatar": "string", "balance": 1000 }
-
-
Deposit Souls
-
URL:
/api/user/deposit
-
Method:
POST
-
Request Body:
{ "amount": 100 }
-
Response:
{ "id": 1, "username": "string", "email": "string", "avatar": "string", "balance": 1100 }
-
-
Place a Bet
-
URL:
/api/roulette
-
Method:
POST
-
Request Body:
{ "bet_amount": 50, "bet_type": "color", // Options: "color", "evenodd", "highlow", "number" "bet_value": "red" // Depending on bet_type, could be string or number }
-
Response:
{ "balance": 1050, "bet_amount": 50, "bet_type": "color", "bet_value": "red", "payout": 50, "result": "win", "result_color": "red", "result_number": 32 }
-
-
Get Leaderboard
-
URL:
/api/leaderboard
-
Method:
GET
-
Response:
[ { "username": "player1", "balance": 5000, "avatar": "images/avatars/avatar1.png" }, { "username": "player2", "balance": 4500, "avatar": "images/avatars/avatar2.png" } // Top 10 players ]
-
To ensure the integrity of the backend functionalities, run the tests using the following command:
cd backend
go test ./...