Skip to content

SlimDumbledodge/trade-lab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

798 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ“ˆ TradeLab

![Next.js](https://img.shields.io/badge/Next.js-15.4-black? style=for-the-badge&logo=next.js) ![NestJS](https://img.shields.io/badge/NestJS-11-E0234E? style=for-the-badge&logo=nestjs) TypeScript Prisma PostgreSQL React

A trading simulation platform to practice investing without financial risk.

Features โ€ข Tech Stack โ€ข Installation โ€ข API โ€ข Roadmap


๐ŸŽฏ About

TradeLab is a full-stack application that allows users to simulate buying and selling financial assets with real-time market data. Each user starts with a virtual portfolio of 10,000โ‚ฌ and can practice trading in realistic conditions.

โš ๏ธ MVP - This project is under active development. New features are coming regularly!


โœจ Features

๐Ÿ“Š Portfolio Management

  • Complete dashboard with performance visualization
  • Track total value and portfolio evolution
  • Asset allocation with automatic weighting
  • Portfolio snapshots history

๐Ÿ’น Trading

  • Buy/Sell stocks with real-time bid/ask prices
  • Market data powered by Alpaca & Finnhub
  • Automatic unrealized P&L calculation
  • Complete transaction history

๐Ÿ“ˆ Visualization

  • Price evolution charts (OHLC)
  • Portfolio performance charts
  • Modern interface with dark/light theme

๐Ÿ” Authentication

  • Secure sign up / sign in
  • JWT management with NextAuth.js
  • Password reset via email

โฐ Real-Time

  • Automatic price updates via cron jobs
  • Real-time market status (open/closed)
  • Trading days calendar

๐Ÿ›  Tech Stack

Backend

Technology Usage
NestJS 11 REST API Framework
Prisma 7 ORM & migrations
PostgreSQL Database
Passport JWT Authentication
Swagger API Documentation
Sentry Monitoring & errors

Frontend

Technology Usage
Next.js 15 React Framework (App Router)
React 19 UI Library
TypeScript Static typing
Tailwind CSS 4 Styling
Radix UI Accessible components
TanStack Query Server state management
Recharts Charts
React Hook Form + Zod Forms & validation

External APIs

  • Alpaca Markets - Real-time market data
  • Finnhub - Company information & prices

๐Ÿ“ Project Structure

trade-lab/
โ”œโ”€โ”€ backend/                 # NestJS API
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ alpaca/         # Alpaca API integration
โ”‚   โ”‚   โ”œโ”€โ”€ assets/         # Assets management
โ”‚   โ”‚   โ”œโ”€โ”€ assets-price/   # Price history
โ”‚   โ”‚   โ”œโ”€โ”€ auth/           # JWT authentication
โ”‚   โ”‚   โ”œโ”€โ”€ email/          # Email service
โ”‚   โ”‚   โ”œโ”€โ”€ finnhub/        # Finnhub integration
โ”‚   โ”‚   โ”œโ”€โ”€ market-status/  # Market status
โ”‚   โ”‚   โ”œโ”€โ”€ portfolios/     # Portfolio management
โ”‚   โ”‚   โ”œโ”€โ”€ transactions/   # Transaction history
โ”‚   โ”‚   โ””โ”€โ”€ users/          # User management
โ”‚   โ””โ”€โ”€ prisma/             # Schema & migrations
โ”‚
โ”œโ”€โ”€ frontend/               # Next.js Application
โ”‚   โ”œโ”€โ”€ app/               # Pages (App Router)
โ”‚   โ”‚   โ”œโ”€โ”€ market/        # Market pages
โ”‚   โ”‚   โ”œโ”€โ”€ portfolio/     # Portfolio pages
โ”‚   โ”‚   โ”œโ”€โ”€ transactions/  # History
โ”‚   โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”œโ”€โ”€ components/        # React components
โ”‚   โ”‚   โ”œโ”€โ”€ charts/        # Charts
โ”‚   โ”‚   โ”œโ”€โ”€ portfolio/     # Portfolio components
โ”‚   โ”‚   โ””โ”€โ”€ ui/            # UI components (shadcn)
โ”‚   โ”œโ”€โ”€ hooks/             # Custom hooks
โ”‚   โ”œโ”€โ”€ mutations/         # TanStack Query mutations
โ”‚   โ””โ”€โ”€ lib/               # Utilities
โ”‚
โ””โ”€โ”€ conception/            # Diagrams (ERD)

๐Ÿš€ Installation

Prerequisites

  • Node.js 20+
  • PostgreSQL 16+
  • pnpm (recommended) or npm

1. Clone the repository

git clone https://github.com/your-username/trade-lab.git
cd trade-lab

2. Backend

cd backend
npm install

# Configure environment variables
cp .env.example .env
# Edit .env with your API keys and DATABASE_URL

# Migrations & seed
npx prisma migrate dev
npx prisma db seed

# Start the server (port 3001)
npm run start:dev

3. Frontend

cd frontend
pnpm install

# Configure environment variables
# Create .env.local with:
# NEXT_PUBLIC_NEST_API_URL=http://localhost:3001
# NEXTAUTH_SECRET=your-secret
# NEXTAUTH_URL=http://localhost:3000

# Start the application (port 3000)
pnpm dev

๐Ÿ”Œ API Endpoints

Authentication

Method Endpoint Description
POST /auth/login Login
POST /users Sign up
POST /auth/forgot-password Request password reset
POST /auth/reset-password Reset password

Assets

Method Endpoint Description
GET /assets List all assets
GET /assets/:symbol Asset details
GET /assets/:symbol/prices Price history

Portfolio

Method Endpoint Description
GET /portfolios/:id Portfolio details
POST /portfolios/:id/buy Buy an asset
POST /portfolios/:id/sell Sell an asset
GET /portfolios/:id/assets Portfolio assets
GET /portfolios/:id/snapshots Value history

Transactions

Method Endpoint Description
GET /transactions Transaction history

Market

Method Endpoint Description
GET /market-status Market status

๐Ÿงช Tests

# Backend - Unit tests
cd backend
npm run test

# Backend - E2E tests
npm run test:e2e

# Backend - Coverage
npm run test:cov

๐Ÿ”ฎ Roadmap

In Progress

  • Advanced performance statistics
  • Optimized mobile responsive

Coming Soon

  • ๐Ÿ† User leaderboard
  • ๐Ÿ”” Custom price alerts
  • ๐Ÿ“ฐ Financial news integration
  • ๐ŸŽฏ Trading goals & gamification
  • ๐Ÿ“Š Technical indicators (RSI, MACD, etc.)
  • ๐Ÿ’ฑ Cryptocurrency support

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


๐Ÿ‘ค Author

Built with โค๏ธ as a personal project to learn and demonstrate my full-stack development skills.


โญ If you like this project, feel free to give it a star!

About

๐Ÿง  TradeLab is a full-stack trading simulator built with NestJS, Prisma & Next.js. Create portfolios, trade assets, and track real-time market data.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages