The GAFI Marketplace Backend is a backend project written in Rust that provides APIs for the GAFI Chain marketplace. It uses actix_web framework to handle HTTP requests and interacts with a MongoDB database. The project is organized as a cargo workspace with three main packages: backend
, worker
, and shared
.
- RESTful APIs for the GAFI Chain marketplace
- Real-time event processing using the
worker
package
To install and set up the project locally, follow these steps:
-
Ensure you have Rust and Cargo installed on your machine. If not, you can install them from here.
-
Clone the repository:
git clone https://github.com/grindytech/gafi-market-be.git
-
Navigate to the project directory:
cd gafi-market-be
-
Install the necessary dependencies:
cargo build
-
Set up the environment variables by creating a
.env
file in the project root directory. Use the provided.env.example
file as a template and fill in the required values. -
Start the backend server:
cargo run -p backend
The server should now be running on
http://localhost:8080
. Swagger UI run athttp://localhost:8080/swagger-ui/
. -
Start the worker
cargo run -p worker
-
(Optional) We use
mongodb-memory-server
for unit test, so if you want to run unit tests, you need to install Node.js and the required dependencies. Run the following commands:npm install
After that, you can run the unit tests using the following command:
cargo test
For detailed information about the available API endpoints and how to interact with them, please refer to the API documentation.
The project is organized as follows:
backend
: Contains the code for the RESTful APIs using the actix_web framework.worker
: Listens for new blocks and processes events.shared
: Contains common code such as models, utils, types, constants, and database connection.
The project uses environment variables for configuration. Create a .env
file in the project root directory and fill in the required values. The following variables are used:
MONGODB_URI
: The URI for connecting to the MongoDB database.MONGODB_DB_NAME
: The name of the MongoDB database.JWT_TOKEN_SECRET
: The secret key used for JWT token generation and validation.JWT_EXPIRE_TIME
: The expiration time for JWT tokens.START_BLOCK
: The block height that worker begin handle.RPC
: The websocket rpc uri.
If you would like to contribute to the project, please follow these guidelines:
- Fork the repository and clone it to your local machine.
- Create a new branch for your feature or bug fix.
- Make your changes and commit them to your branch.
- Push your branch to your forked repository.
- Open a pull request to the main repository.
This project is licensed under the MIT License.