This project is a simple HTTP server built with Go that provides user account management functionalities, such as registering users, depositing, withdrawing, and placing bets. It uses Redis for data storage and includes a Python CLI client for interacting with the server.
- Features
- Prerequisites
- Installation
- Usage
- API Endpoints
- Configuration
- Running Tests
- Docker Support
- Contributing
- License
- User registration
- Deposit funds to user accounts
- Withdraw funds from user accounts
- Place bets
- Retrieve all users
- Health check endpoint
- Go 1.18+
- Redis
- Python 3.12+
- Docker (optional)
git clone https://github.com/MrRezoo/code-challenge.git
cd code-challenge
-
Install Go dependencies
go mod tidy
-
Run the server
go run cmd/main.go
-
Navigate to the client directory
cd client
-
Install Python dependencies
pip install -r requirements.txt
or you can use poetry to install the dependencies
poetry install
go run cmd/main.go
python main.py
╭───────────────── Challenge CLI ──────────────────╮
│ Welcome to the Challenge! │
│ Commands available: │
│ 1. register - Register a new user │
│ 2. deposit - Deposit funds into a user account │
│ 3. withdraw - Withdraw funds from a user account │
│ 4. bet - Perform a betting operation (placeholder) │
│ 5. all - Retrieve all users │
╰────────────────────────────────────────────────────╯
register
: Register a new userdeposit
: Deposit funds to a user's accountwithdraw
: Withdraw funds from a user's accountbet
: Place a bet for a userlist
: Retrieve and display all users
- URL:
/health
- Method:
GET
- Responses:
200 OK
- URL:
/user/all
- Method:
GET
- Responses:
200 OK
- URL:
/user/register
- Method:
POST
- Request Body:
{ "id": 1, "balance": 100.0 }
- Responses:
200 OK
400 Bad Request
- URL:
/user/deposit
- Method:
PATCH
- Request Body:
{ "id": 1, "amount": 50.0 }
- Responses:
200 OK
400 Bad Request
- URL:
/user/withdraw
- Method:
PATCH
- Request Body:
{ "id": 1, "amount": 20.0 }
- Responses:
200 OK
400 Bad Request
- URL:
/user/bet
- Method:
POST
- Request Body:
{ "id": 1, "amount": 10.0 }
- Responses:
200 OK
400 Bad Request
Configuration files are located in the config
directory. Modify the .yaml
files according to your environment.
config-development.yaml
config-docker.yaml
To run the tests, use the following command:
go test ./...
To run the server using Docker, use the provided docker-compose
file.
docker-compose up --build
Contributions are welcome! Please fork the repository and submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
This `README.md` provides comprehensive documentation for your project, detailing its features, installation steps, usage, API endpoints, configuration, and more. Adjust any specific details as needed.