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.
![Screenshot 2023-08-14 at 18 14 16](https://private-user-images.githubusercontent.com/1651925/260521140-228e9824-417f-4903-baf9-bdac26ff0a92.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMTQ2MTQsIm5iZiI6MTcyNjExNDMxNCwicGF0aCI6Ii8xNjUxOTI1LzI2MDUyMTE0MC0yMjhlOTgyNC00MTdmLTQ5MDMtYmFmOS1iZGFjMjZmZjBhOTIucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDkxMiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA5MTJUMDQxMTU0WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZDI0NTgzZGJlYWQwZDgyNDVjNTQ0ZDVhZWQ5MjAzMjBhNzdhOWM5YjczMjAxYWE2MzI2YWEzMmIzMzIyY2MyMCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.3nWz2JQDlKszGymke1ewvP0U_RYj8IUGpIyXd8I3LW0)
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