- Introduction
- Features
- Technology Stack
- Monorepo Structure
- Services
- Getting Started
- Environment Variables
- API Documentation
- Testing
The Forex Marketplace is a monorepo-based microservices project that allows users to buy and sell foreign exchange (forex). It fetches real-time conversion rates from an external API and facilitates transactions via a secure and scalable platform.
- User registration and authentication
- Wallet management with credit/debit functionality
- Forex transaction and order management
- Real-time forex rates integration
- gRPC for internal communication between microservices
- REST API for user-facing endpoints
- Backend Framework: NestJS with TypeScript
- Database: PostgreSQL with TypeORM
- Internal Communication: gRPC
- External API Integration: ExchangeRate-API
- Monorepo Management: Nx
- Protobuf Compiler: grpc-tools and ts-proto
root/
├── apps/
│ ├── users/
│ ├── wallet/
│ ├── transactions/
│ ├── rates/
├── authentication/
├── libs/
├── protos/
│ ├── generated/
│ ├── user.proto
├── scripts/
│ ├── generate-proto.sh
├── servers/
├── node_modules/
├── nx.json
├── package.json
├── tsconfig.base.json
- Responsibilities: User registration, authentication, and profile management
- Endpoints:
POST /users
GET /users
GET /users/:username
PUT /users/:userId/profile
POST /auth/login
GET /auth/user
- Responsibilities: Managing user wallets, including checking balances and performing transactions
- Endpoints:
POST /wallets
GET /wallets/
PUT /wallets/deposit/:walletId
- Responsibilities: Handling the creation and management of forex transactions and orders
- Endpoints:
POST /transaction/buy
POST /transaction/sell
GET /transaction/history
- Responsibilities: Fetching current forex rates from ExchangeRate-API and providing them to other services via gRPC
- Endpoints:
GRPC GetRate
- Nest.js
- PostgreSQL
- Nx CLI
-
Clone the repository:
git clone https://github.com/NuelUzoma/forex-marketplace.git cd forex-marketplace
-
Install dependencies:
npm install
-
Set up environment variables:
cp .env.example .env
-
Start PostgreSQL and create the necessary databases.
-
Run the services:
nx serve users nx serve wallet nx serve transactions nx serve rates
- Run the script to generate protobuf files:
sh scripts/generate-proto.sh
Define all necessary environment variables in the .env
file. Example:
# Database
DB_HOST=localhost
DB_PORT=5432
DB_USERNAME=your_db_user
DB_PASSWORD=your_db_password
DB_DATABASE=your_db_name
# JWT
JWT_SECRET=your_jwt_secret
# Exchange Rate API
EXCHANGE_RATE_API_KEY=your_api_key
API documentation is created using Swagger but incomplete at the moment.
To run tests, use the following command:
nx test