Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“ˆ Stock Market Learning Lab

A beginner-friendly Stock Market Learning Lab where users simulate market scenarios and receive AI-generated coaching feedback based on their behaviour, actions, and P&L. The goal is to teach investing concepts through interactive learning rather than reading long theory.


πŸš€ Overview

This project includes:

Backend (Node + Express)

  • API endpoint /api/coach/feedback
  • Takes user actions, behaviour tags, P&L, and summary
  • Generates a coaching message using an AI model (HuggingFace or mock response)
  • Simple, modular, and hackathon-ready

Frontend (React + TailwindCSS)

  • Clean and modern UI using project colors:
    • #00c853 (Green)
    • #ff3b30 (Red)
    • #050608 (Dark)
  • Form to send simulation results to backend
  • Displays AI feedback in a chat-style UI

πŸ“ Project Structure

project/
β”‚
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ controllers/
β”‚   β”‚   └── coachController.js
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   └── coachRoutes.js
β”‚   β”œβ”€β”€ index.js
β”‚   β”œβ”€β”€ package.json
β”‚   └── .env
β”‚
└── frontend/
    β”œβ”€β”€ src/
    β”‚   β”œβ”€β”€ components/
    β”‚   β”œβ”€β”€ App.jsx
    β”‚   └── main.jsx
    β”œβ”€β”€ tailwind.config.js
    β”œβ”€β”€ package.json
    └── index.html

βš™οΈ Backend Setup

1️⃣ Install dependencies

cd backend
npm install

2️⃣ Create .env
PORT=9000
HF_API_KEY=your_huggingface_api_key_here

3️⃣ Run Development Server
npm run dev

Backend runs at:
http://localhost:9000


🧠 API Documentation
POST /api/coach/feedback
Request Body
{
  "actions": [
    { "action": "BUY", "price": 120, "qty": 2 }
  ],
  "behaviourTags": ["FOMO", "Averaging Down"],
  "pnl": -230,
  "summary": "Bought aggressively after a spike"
}

Response Example
{
  "coachMessage": "Here's what I noticed about your trading behaviour..."
}

πŸ§ͺ Testing With Postman
Open Postman β†’ POST
URL: http://localhost:9000/api/coach/feedback
Body β†’ raw β†’ JSON:
{
  "actions": [{"action":"BUY","price":120,"qty":2}],
  "behaviourTags": ["FOMO","Overconfidence"],
  "pnl": -50,
  "summary": "User bought at peak"
}

πŸ’» Frontend Setup
1️⃣ Install Dependencies
cd frontend
npm install

2️⃣ Run React App
npm run dev

Frontend runs at:
http://localhost:5173


πŸ”Œ Connecting Frontend to Backend
Frontend uses:
const response = await fetch("http://localhost:9000/api/coach/feedback", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ actions, behaviourTags, pnl, summary })
});

Backend returns the AI message β†’ shown inside UI.

🎨 Color Palette
PurposeColorPrimary Green#00c853Loss Red#ff3b30Background Dark#050608

✨ Features
AI-generated beginner-friendly guidance
Clean UI with your custom colors
REST API backend
Trade simulation inputs
Behaviour-based insights
Perfect for hackathons

πŸ“¦ Deployment
Frontend Build
npm run build

Backend Deployment Options
Render
Railway
Vercel serverless
AWS EC2
Netlify (only frontend)

πŸ“Œ Future Enhancements
Authentication
Save trading history
Multi-scenario simulations
Gamification (XP, badges)
More advanced AI coaching


πŸ“œ License
MIT License Β© 2025

🀝 Contributing
PRs and issues are welcome.

About

this is a learning platform where you can learn about the stock market .

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages