A full-stack stock analytics platform with real-time watchlists, portfolio tracking, price alerts, and 20-DMA buy/sell signals — built for traders who mean business.
| 🖥️ Page | 💡 What it does |
|---|---|
| 📊 Dashboard | Watchlist manager, live stock cards, price vs 20-DMA bar chart with buy/sell signals |
| 🌍 Markets | Symbol search with autocomplete, 30-day line chart, full market overview table |
| 💼 Portfolio | BUY/SELL trade logger, real-time P&L calculation, full trade history |
| 🔔 Alerts | Set price alerts (above/below threshold), toggle on/off, up to 10 active at once |
| ⚙️ Settings | Update profile info and change password securely |
| 🔐 Auth | JWT access + refresh token rotation with token-theft detection |
┌─────────────────────────────────────────────────────┐
│ TrendEdge │
├───────────────────────┬─────────────────────────────┤
│ FRONTEND │ BACKEND │
│ │ │
│ ⚛️ React 18 │ 🟢 Node.js + Express 5 │
│ ⚡ Vite │ 🍃 MongoDB + Mongoose │
│ 🗺️ React Router v6 │ 🔑 JWT (access + refresh) │
│ 📈 Chart.js │ 🛡️ Helmet + Rate Limiting │
│ 🎨 Lucide Icons │ 📡 Alpha Vantage API │
└───────────────────────┴─────────────────────────────┘
trendedge/
├── 📂 client/ ← React frontend (Vite)
│ ├── 📂 src/
│ │ ├── 📂 api/ ← Axios instance + all API calls
│ │ ├── 📂 components/ ← Layout, StockCard, Toast, Sidebar…
│ │ ├── 📂 context/ ← AuthContext (global user state)
│ │ └── 📂 pages/ ← Dashboard, Markets, Portfolio, Alerts, Settings
│ ├── 📄 vite.config.js ← Proxies /api → localhost:5000 in dev
│ └── 📄 vercel.json ← SPA rewrite rules for Vercel
│
├── 📂 server/ ← Express backend
│ ├── 📂 config/ ← MongoDB connection
│ ├── 📂 controllers/ ← auth, stock, portfolio, alert logic
│ ├── 📂 middleware/ ← JWT guard, rate limiter, error handler
│ ├── 📂 models/ ← User, Portfolio, Trade, Alert schemas
│ ├── 📂 routes/ ← API route definitions
│ ├── 📂 services/ ← Alpha Vantage integration + demo fallback
│ └── 📄 index.js ← App entry point
│
└── 📄 package.json ← Root scripts (start, dev, build)
- 🟢 Node.js v18+
- 🍃 MongoDB URI (local or MongoDB Atlas)
- 📡 Alpha Vantage API key — free at alphavantage.co (optional — demo data works without it)
git clone https://github.com/maniishh/trendedge.git
cd trendedgenpm run install:allThis installs both server and client dependencies in one shot.
Create a .env file in the project root:
# ── Server ────────────────────────────────────────
NODE_ENV=development
PORT=5000
# ── MongoDB ───────────────────────────────────────
MONGODB_URI=mongodb://localhost:27017/trendedge
# ── JWT Secrets (use long random strings!) ────────
ACCESS_TOKEN_SECRET=your_super_secret_access_key
REFRESH_TOKEN_SECRET=your_super_secret_refresh_key
ACCESS_TOKEN_EXPIRY=15m
REFRESH_TOKEN_EXPIRY=7d
# ── CORS ──────────────────────────────────────────
CLIENT_URL=http://localhost:5173
# ── Stock Data ────────────────────────────────────
ALPHA_API_KEY=your_alpha_vantage_key # optional — demo mode if omittedCreate a client/.env file:
# Your backend URL — no trailing slash
VITE_API_URL=http://localhost:5000# Run frontend + backend together
npm run dev:full
# Or separately:
npm run dev # backend → http://localhost:5000
npm run dev:client # frontend → http://localhost:5173http://localhost:5173
Create an account and start trading! 🚀
🟢 Backend → Render
| Variable | Value |
|---|---|
NODE_ENV |
production |
MONGODB_URI |
Your Atlas connection string |
ACCESS_TOKEN_SECRET |
Long random secret |
REFRESH_TOKEN_SECRET |
Different long random secret |
CLIENT_URL |
Your Vercel frontend URL |
ALPHA_API_KEY |
Your Alpha Vantage key |
Build command: npm install
Start command: npm start
▲ Frontend → Vercel
| Variable | Value |
|---|---|
VITE_API_URL |
Your Render backend URL (no trailing slash) |
Root directory: client
Build command: npm run build
Output directory: dist
✅
vercel.jsonis already included — React Router works correctly on page refresh and direct URL access.
🔐 Auth — click to expand
POST /api/auth/register Create a new account
POST /api/auth/login Login and receive tokens
POST /api/auth/refresh-token Rotate access token via HttpOnly cookie
POST /api/auth/logout Invalidate session
GET /api/auth/me Get current user profile
PATCH /api/auth/me Update profile (name, avatar)
POST /api/auth/change-password Change password — invalidates all sessions
PATCH /api/auth/watchlist Update watchlist symbols (max 20)
📈 Stocks — click to expand
GET /api/stocks Dashboard data for watchlist symbols
GET /api/stocks/search?q=... Search symbols with autocomplete
GET /api/stocks/:symbol Full detail + 30-day price history
💼 Portfolio — click to expand
GET /api/portfolio Holdings with real-time P&L
POST /api/portfolio/trade Log a BUY or SELL trade
GET /api/portfolio/trades Trade history with filters
🔔 Alerts — click to expand
GET /api/alerts List all alerts
POST /api/alerts Create a price alert (above / below)
DELETE /api/alerts/:id Delete an alert
PATCH /api/alerts/:id/toggle Enable or disable an alert
🏥 Health — click to expand
GET /api/health Server status + environment info
🟡 No Alpha Vantage key? No problem.
If ALPHA_API_KEY is not set, TrendEdge automatically serves realistic demo data with simulated price jitter. A yellow banner appears on the Dashboard and Markets pages to let you know. Everything else — auth, portfolio, alerts — works exactly the same.
- 🔑 JWT rotation — short-lived access tokens (15m) + long-lived refresh tokens (7d) in
HttpOnlycookies - 🕵️ Token theft detection — reusing a rotated token immediately wipes all sessions for that user
- 🛡️ Helmet.js — secure HTTP headers out of the box
- 🚦 Rate limiting — auth endpoints throttled to block brute-force attacks
- 🔐 bcrypt — passwords hashed with 12 salt rounds
- ✅ Input validation — every input sanitized with
express-validatorbefore touching business logic
Pull requests are welcome! For major changes, please open an issue first to discuss what you'd like to change.
# 1. Fork the repo
# 2. Create your feature branch
git checkout -b feature/amazing-feature
# 3. Commit your changes
git commit -m 'Add amazing feature'
# 4. Push to the branch
git push origin feature/amazing-feature
# 5. Open a Pull Request 🎉Made with ❤️ and ☕ by a trader, for traders.
⭐ Star this repo if you found it useful! ⭐