Contains the database configuration file (database.js
) for establishing a connection with MongoDB.
Holds the controller logic for handling transaction and user balance requests.
Defines the Mongoose schemas and models for transactions, addresses, and Ethereum prices.
Defines the API routes for transactions and user balance endpoints.
Includes service files for interacting with external APIs like Etherscan and CoinGecko.
Contains utility files, such as priceUpdater.js
, which handles the periodic update of Ethereum prices.
The main entry point of the application, responsible for setting up the Express server, connecting to the database, and registering the routes.
Environment variables file for storing sensitive information like the Etherscan API key and MongoDB connection URL.
Manages project dependencies and scripts.
- Fetches and stores Ethereum transactions for a given address using the Etherscan API.
- Calculates the user's balance based on the fetched transactions.
- Retrieves the current price of Ether from the CoinGecko API and updates it in the database every 10 minutes.
- Provides a
GET
API endpoint to retrieve the user's balance and the current Ether price.
- Node.js
- Express.js
- MongoDB (with Mongoose)
- Axios (for making HTTP requests)
- Etherscan API
- CoinGecko API
- Clone the repository:
git clone https://github.com/ShubhzDev/KoinX.git
- Install dependencies:
npm install
- Set up the environment variables in the
.env
file. - Start the server:
node app.js
- The server will start running on
http://localhost:3000
.
GET /api/transactions/:address
: Fetches and stores transactions for the given Ethereum address.GET /api/balance/:address
: Retrieves the user's balance and the current Ether price.