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.
This project includes:
- 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
- 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/
β
βββ 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
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.