Carbon Backend, built with Nest.js, serves as a specialized backend solution for aggregating insights from Carbon smart contracts and delivering them through APIs. It provides a suite of APIs offering valuable insights, such as trading activity and history.
Before setting up Carbon Backend, ensure you have the following prerequisites:
- TimescaleDB: Ensure TimescaleDB is properly installed and running.
- Redis: Ensure Redis is properly installed and running.
- CoinGecko: Obtain an API key from CoinGecko.
- CoinMarketCap: Obtain an API key from CoinMarketCap.
- Python 3 (Optional): Required for the simulator.
To set up Carbon Backend, follow these steps:
-
Clone the repository:
git clone https://github.com/bancorprotocol/carbon-backend
-
Navigate to the project directory:
cd carbon-backend
-
Install dependencies:
npm install
-
Configure environment variables:
Duplicate the
.env.example
file as.env
:cp .env.example .env
Provide the required values in the
.env
file. -
(Optional) If you wish to utilize the simulator feature, install the required Python packages:
pip install -r src/simulator/requirements.txt
To run Carbon Backend:
npm start
Access the API documentation by navigating to http://localhost:3000 in your browser.
Manually run the seed
function in src/historic-quote/historic-quote.service.ts
to populate the database with historic quotes for history-dependent functionalities such as the simulator.
To switch Carbon Backend's network for different deployments, follow these steps:
-
Replace Smart Contract Files:
- Replace files in
src/contracts/mainnet
with those from the new deployment.
- Replace files in
-
Modify CoinMarketCap Service:
- Adjust
src/coinmarketcap/coinmarketcap.service.ts
to align with the new network. - For guidance, check the CoinMarketCap API documentation.
- Adjust
-
Modify CoinGecko Service:
- Adjust
src/quote/coingecko.service.ts
to match the requirements of the new network. - Refer to the CoinGecko API documentation for assistance.
- Adjust
By following these steps, you can seamlessly switch Carbon Backend's network to suit your deployment or environment.
Carbon Backend is licensed under the MIT License.