Skip to content

bhavanvir/nightrader

Repository files navigation

Nightrader test

Nightrader is a robust stock trading platform built on microservices architecture. We leverage Docker for orchestration, Go and Gin-Gonic for the backend API, PostgreSQL for our database, and React with Daisy UI and TailwindCSS for the frontend.

Services

  • Engine (Port 8585): Implements the matching engine, which processes buy and sell orders using a Pro Rata algorithm.
  • Setup (Port 8080): Initializes Nightrader by adding and creating stocks for market use.
  • Database (Port 5432): Handles table creation and data preprocessing, including password encryption.
  • Authentication (Port 8888): Verifies user credentials against the database and generates session tokens that expire after a fixed time.
  • Transaction (Port 5433): Manages client-exchange interactions, such as fetching current market prices and funding user balances.
  • Frontend (Port 3000): The user-facing application that facilitates interactions with the exchange.

Endpoints

Category Method Endpoint Parameters
Authentication POST /register {
    "username": string,
    "password": string,
    "name": string
}
POST /login {
    "user_name": string,
    "password": string
}
Transaction GET /getStockPrices -
GET /getWalletBalance -
GET /getStockPortfolio -
GET /getWalletTransactions -
GET /getStockTransactions -
POST /addMoneyToWallet {
    "amount": number
}
POST /placeStockOrder {
    "stock_id": number,
    "is_buy": boolean,
    "order_type": string,
    "quantity": number,
    "price": number
}
POST /cancelStockTransaction {
    "stock_tx_id": string
}
Setup POST /createStock {
    "stock_name": string
}
POST /addStockToUser {
    "stock_id": string,
    "quantity": number
}

Installation

  1. Prerequisites: Ensure Docker is installed and configured on your system.

  2. Clone the repository:

    git clone https://github.com/bhavanvir/day-trader.git
  3. Navigate to the project directory:

    cd day-trader
  4. Start up all microservices:

    docker compose up --build -d
  5. Access the frontend: Open a web browser and go to localhost:3000 to start trading.

Feel free to reach out if you have any questions or need further assistance. Happy trading!