The Currency Converter API is a Node.js-based backend project that allows users to register, authenticate, and convert currencies in real time using live exchange rate data. This project is built with Express, MongoDB, and integrates a third-party currency conversion API. It also supports token-based authentication using JWT.
This project simulates a real-world API for a currency converter app. It enables:
- User account creation and login
- Secure authentication using JWT
- Currency conversion from one currency to another using live exchange rates
- Modular, scalable folder structure following best practices
Ideal for anyone looking to understand:
- RESTful API development
- MongoDB with Mongoose
- Third-party API integration
- JWT authentication
- User signup and login
- Protected routes with JWT
- Real-time currency conversion via external API
- Clean folder structure using MVC pattern
- Fully testable with Thunder Client/Postman
- MongoDB persistence for user data
- Node.js – JavaScript runtime
- Express.js – API framework
- MongoDB – NoSQL database
- Mongoose – ODM for MongoDB
- JWT – Token-based authentication
- Axios – For calling external currency API
- dotenv – Environment variable management
- Nodemon – Development tool
- Thunder Client – API testing (VS Code extension)
git clone https://github.com/vermaharsha/currency-converter-api.git
cd currency-converter-apinpm installCreate a .env file in the root directory and add the following:
PORT=5000
MONGO_URI=mongodb+srv://<username>:<password>@<cluster>.mongodb.net/<dbname>
JWT_SECRET=your_jwt_secret
CURRENCY_API_URL=https://v6.exchangerate-api.com/v6
CURRENCY_API_KEY=your_currency_api_keyReplace
<username>,<password>,<cluster>,<dbname>, and API key with actual values.
npm run devServer will run at
http://localhost:5000
All routes starting with /api are available for public or authenticated access.
- Method:
POST - URL:
/api/auth/signup - Body (JSON):
{
"username": "harsha",
"email": "harsha@example.com",
"password": "securepass123"
}- ✅ Response:
{
"message": "User registered successfully"
}- Method:
POST - URL:
/api/auth/login - Body (JSON):
{
"email": "harsha@example.com",
"password": "securepass123"
}- ✅ Response:
{
"token": "JWT_TOKEN",
"user": {
"id": "user_id",
"username": "harsha",
"email": "harsha@example.com"
}
}- Method:
GET - URL:
/api/currency/convert?from=USD&to=INR&amount=100 - Headers:
Authorization: Bearer <JWT_TOKEN>- ✅ Response:
{
"from": "USD",
"to": "INR",
"amount": "100",
"rate": 83.01,
"convertedAmount": 8301
}Made with ❤️ by Harsha Verma



