A simple trading application developed with a full stack Rust, utilizing Axum for the backend and MongoDB as the database. The frontend is written using NextJS and React.
- Docker
- Docker-compose 2.12.2
- Node v16.x (for frontend)
- Yarn 1.22.19 (for frontend)
- Rust 1.71.1 (for backend if not using Docker)
-
Navigate to the backend directory:
cd backend
-
Build the Docker image for the backend:
docker build -t carbon-sim .
-
List docker image to check that image
carbon-sim:latest
was created successfullydocker image ls
-
Navigate to the frontend directory:
cd ftontend
-
Build the Docker image for the frontend:
docker build -t carbon-ui .
-
List docker image to check that image
carbon-ui:latest
was created successfullydocker image ls
Upon successful completion of the Docker builds, you should now have local images established for both the frontend and backend components.
Within the root directory of this project, designated as carbon-sim, there is a docker-compose file. This file has been configured to facilitate e2e initiation of MongoDB, the backend, and the frontend servers.
To execute these services, navigate to the root directory of the project and issue the following command:
docker-compose up
This procedure will initiate and run the services in the foreground. Ensure you monitor the console output for any potential issues or confirmations of successful service launches.
Open your web browser and navigate to:
http://localhost:3000
Create new user
Parameter | Type | Description |
---|---|---|
user_id |
string |
Required. The unique user_id |
name |
string |
Required. The provided name of the user |
balance |
decimal (64) |
Required. The initial balance of the user |
curl -X POST \
-H "Content-Type: application/json" \
-d '{"name": "Alice", "user_id": "alice", "balance": 1000}' \
http://localhost:8787/users/create
GET /users/${user_id}
Parameter | Type | Description |
---|---|---|
user_id |
string |
Required. User Id of user to fetch |
Example
curl -X GET http://localhost:8787/users/alice
GET /users
Example
curl -X GET http://localhost:8787/users
Transfer balance between two users
Parameter | Type | Description |
---|---|---|
sender |
string |
Required. User Id of the sender |
receiver |
string |
Required. User Id of the receiver |
amount |
string |
Required. The amount to be transferred |
curl -X POST \
-H "Content-Type: application/json" \
-d '{"sender": "alice", "receiver": "bob", "balance": 1000, "amount": 10}' \
http://localhost:8787/transactions/transfer
GET /transactions
Example
curl -X GET http://localhost:8787/transactions