Skip to content

jayalloyd/Quantify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

114 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“ˆ Quantify

🚧 Status: Active Development

Quantify is a full-stack simulated trading platform built using the MERN stack, designed to replicate core functionalities of real-world trading systems. It focuses on high-performance backend system design, secure transaction handling, and seamless data interaction.


πŸš€ Features

πŸ” Authentication & Security

  • JWT (JOSE): Secure user authentication and session management.
  • Middleware Protection: Custom authentication middleware to guard private routes.
  • HTTP Security: Integrated Helmet.js for setting secure headers.
  • Rate Limiting: (In Progress) Redis-backed rate limiting to prevent API abuse.

πŸ“Š Market Data & Watchlists

  • Dynamic Watchlists: User-specific stock tracking with real-time price data simulation.
  • Stock Analytics: Interactive charts for detailed price analysis and trend monitoring.

πŸ’Ό Portfolio Management

  • Live Tracking: Dynamic portfolio valuation based on current market prices.
  • Holdings Management: Automated calculation of Profit/Loss (P&L) and total asset value.

🧾 Trade Execution Engine

  • Simulated Orders: Seamless Buy/Sell execution logic.
  • Atomic Updates: Ensures database consistency across portfolio and transaction logs.
  • Validation: Server-side checks for sufficient balance and stock quantity.

πŸ› οΈ Tech Stack

  • Frontend: React.js, React-Bootstrap, Axios, React Router
  • Backend: Node.js, Express.js
  • Database: MongoDB (Mongoose)
  • Caching/Security: Redis (In Progress), JWT, Helmet.js, CORS
  • Package Manager: pnpm

πŸ—οΈ System Architecture

graph TD
    subgraph Client_Side [Frontend - React.js]
        A[User Interface] --> B[State Management]
        B --> C[Axios / API Calls]
    end

    subgraph Security_Layer [Middleware]
        C --> D{JWT Authenticator}
    end

    subgraph Server_Side [Backend - Node.js/Express]
        D -- Authorized --> E[Controllers]
        E --> F[User Controller]
        E --> G[Portfolio Controller]
        E --> H[Watchlist Controller]
        E --> I[Transaction Controller]
    end

    subgraph Database_Layer [Data - MongoDB]
        F <--> J[(Users Collection)]
        G <--> K[(Portfolios Collection)]
        H <--> L[(WatchLists Collection)]
        I <--> M[(Transactions Collection)]
    end

    %% Styling
    style Client_Side fill:#e1f5fe,stroke:#01579b
    style Server_Side fill:#fff3e0,stroke:#e65100
    style Database_Layer fill:#e8f5e9,stroke:#1b5e20
    style Security_Layer fill:#fce4ec,stroke:#880e4f


Loading

πŸ”„ Request Flow

sequenceDiagram
    participant User as User (React)
    participant API as API Gateway (Express)
    participant Auth as JWT Middleware
    participant DB as MongoDB

    User->>API: GET /watchlist
    API->>Auth: Verify Token
    Auth-->>API: Token Valid
    API->>DB: WatchList.find()
    DB-->>API: Data
    API-->>User: JSON Response
    
Loading

πŸ“ Project Structure

Quantify/
β”‚
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ models/
β”‚   β”œβ”€β”€ routes/
β”‚   β”œβ”€β”€ controllers/
β”‚   β”œβ”€β”€ middleware/
β”‚   β”œβ”€β”€ config/
β”‚   └── server.js
β”‚
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”œβ”€β”€ App.jsx
β”‚   β”‚   └── main.jsx
β”‚   └── index.html
β”‚
β”œβ”€β”€ .env
β”œβ”€β”€ pnpm-workspace.yaml
β”œβ”€β”€ package.json
└── README.md
Backend-Folder Structure
backend/
β”‚
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ config/
β”‚   β”‚   └── db.js            # MongoDB connection
β”‚   β”‚
β”‚   β”œβ”€β”€ models/
β”‚   β”‚   └── User.model.js
β”‚   β”‚
β”‚   β”œβ”€β”€ controllers/
β”‚   β”‚   └── auth.controller.js
β”‚   β”‚
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   └── auth.routes.js
β”‚   β”‚
β”‚   β”œβ”€β”€ middlewares/
β”‚   β”‚   └── auth.middleware.js
β”‚   β”‚
β”‚   β”œβ”€β”€ app.js
β”‚   └── server.js
β”‚
β”œβ”€β”€ .env
β”œβ”€β”€ package.json
└── README.md
---

🧠 Engineering Insights & Journey

This project serves as a deep dive into backend system design and security. I document my architectural decisions, failures, and technical breakthroughs in a multi-part blog series:

πŸ› οΈ Key Technical Challenges Overcome

1. Directory Structure Maintenance

  • Challenge: Early development led to a cluttered root directory where frontend and backend configurations leaked into one another, making deployments error-prone.
  • Solution: Migrated to a strict monorepo layout using pnpm-workspace. Separated domain logic into dedicated backend/src/ subfolders matching standard MVC patterns.

2. Stateless Auth Route Protection

  • Challenge: Securing simulated portfolio and transaction data without introducing heavy database queries on every authenticated request.
  • Solution: Built a reusable, custom Express middleware leveraging the JOSE ecosystem for lightweight JWT validation, verifying incoming tokens deterministically before exposing controllers.

Notes

Initial frontend boilerplate was generated using AI tools (Google Antigravity) (SignUp,login and Services Pages Only) and then customized and extended manually.

βš™οΈ Installation & Setup

Prerequisites

  • Node.js (v18+ recommended)
  • PNPM
  • MongoDB (local or Atlas)

Install PNPM (if not installed)

npm install -g pnpm

Clone the Repository

git clone https://github.com/jayalloyd/quantify.git
cd Quantify

Install Dependencies

pnpm install

▢️ Running the Project

Start Backend

cd backend
pnpm run dev

Start Frontend

cd frontend
pnpm run dev

Frontend will run on:

http://localhost:5173

Backend will run on:

http://localhost:5000

πŸ” Environment Variables

Create a .env file inside backend/:

PORT=5000
MONGO_URI=your_mongodb_connection_string
JWT_SECRET=your_secret_key

πŸ§ͺ Future Enhancements

  • WebSocket-based live price updates
  • Payment gateway integration
  • Role-based admin dashboard
  • Advanced charting (TradingView)
  • Watchlists & alerts

πŸ“œ License

This project is for educational purposes only and is a demo project and is not affiliated with any trading platform.


πŸ‘¨β€πŸ’» Author

Quantify

Jaya Rani.Y.S

Linkedin:jayarani y s Github: jayalloyd

About

🚧 Work in Progress-> Quantify is a full-stack finance platform built with the MERN stack.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors