RESTful API for India's first AI-powered financial literacy platform
Latest Update: Stock data populated with 1,999 NSE stocks
Devion Backend is a comprehensive API platform that powers financial literacy education for teenagers through:
- User Authentication - JWT-based secure auth system
- Paper Trading - Risk-free portfolio simulation
- Real Market Data - Live NSE stock prices (1,999 stocks)
- AI Tutor - GPT-5 powered conversational learning
- Voice AI - ElevenLabs powered natural voice interactions
- Gamification - Badges, leaderboards, and progress tracking
- Node.js >= 18.x
- npm >= 9.x
- Supabase account & project
- OpenAI API key
- ElevenLabs API key
# Clone repository
git clone https://github.com/devion-industries/devion.in-backend.git
cd devion.in-backend
# Install dependencies
npm install
# Create environment file
cp .env.example .env
# Edit .env and add your API keys
# Build TypeScript
npm run build
# Start development server
npm run devServer runs on http://localhost:3001
# Import 1,999 NSE equity stocks
npm run build
node dist/scripts/import-nse-stocks.js- Runtime: Node.js 20.x
- Framework: Express.js
- Language: TypeScript
- Database: Supabase (PostgreSQL)
- Authentication: JWT (jsonwebtoken + bcryptjs)
- AI Integration: OpenAI GPT-5
- Voice AI: ElevenLabs
- Market Data: Yahoo Finance (yahoo-finance2)
- Logging: Winston
- Security: Helmet, CORS, Rate Limiting
- Validation: Zod
- File Parsing: csv-parse
users- User accounts & profilesportfolios- User portfolios with flexible budgetholdings- Current stock holdingstrades- Complete trade history (buy/sell)stocks- NSE stock master data (1,999 stocks)stock_prices- Historical price data cache
lessons- Educational content modulesuser_progress- Lesson completion trackingquizzes- Quiz questions & answersquiz_attempts- User quiz submissions & scores
badges- Achievement badge definitionsuser_badges- User badge collectioncohorts- Teacher-led class management
voice_sessions- Voice interaction sessionsvoice_interactions- Individual voice Q&A exchangesuser_voice_preferences- Voice settings per user
subscription_plans- Free/Pro/Ultra tiersuser_subscriptions- User plan assignmentspayments- Payment transaction history
POST /api/auth/signup Register new user
POST /api/auth/login User login
GET /api/auth/profile Get user profile
PUT /api/auth/profile Update user profile
GET /api/market/featured Get top 500 featured stocks
GET /api/market/search Search stocks by symbol/name
GET /api/market/stock/:symbol Get stock details & price
GET /api/market/history/:symbol Historical price data
POST /api/market/sync Sync stocks from Yahoo Finance
GET /api/portfolio Get user portfolio summary
GET /api/portfolio/holdings Get all holdings
GET /api/portfolio/trades Get trade history
POST /api/portfolio/buy Execute buy order
POST /api/portfolio/sell Execute sell order
PUT /api/portfolio/budget Update portfolio budget
GET /api/portfolio/budget/history Budget change history
POST /api/ai/ask Ask AI a financial question
GET /api/ai/portfolio-insights Get AI-powered portfolio analysis
POST /api/ai/explain Explain financial concept
GET /api/ai/learning-path Get personalized learning path
GET /api/ai/health Check AI service health
POST /api/voice/ask Ask question with voice response
POST /api/voice/explain Explain concept with voice
GET /api/voice/portfolio-insights Narrated portfolio insights
POST /api/voice/tts Text-to-speech conversion
POST /api/voice/session/start Start voice session
POST /api/voice/session/end End voice session
GET /api/voice/voices List available voices
GET /api/voice/usage Get usage statistics
GET /api/voice/health Check voice service health
GET /api/lessons List all lessons
GET /api/lessons/:id Get lesson details
POST /api/lessons/progress Mark lesson complete
GET /api/quiz List quizzes
POST /api/quiz/submit Submit quiz answers
GET /api/badges List badges
GET /api/badges/user Get user badges
GET /api/subscription/plans List subscription plans
POST /api/subscription/subscribe Subscribe to plan
Create a .env file in the root directory:
# Supabase Database
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_KEY=your_supabase_anon_key_here
# JWT Authentication
JWT_SECRET=your_super_secret_jwt_key_minimum_32_characters
JWT_EXPIRES_IN=7d
# OpenAI API (AI Tutor - GPT-5)
OPENAI_API_KEY=sk-proj-xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# ElevenLabs API (Voice AI)
ELEVENLABS_API_KEY=your_elevenlabs_api_key_here
# Server Configuration
PORT=3001
NODE_ENV=developmentThe platform includes 1,999 NSE equity stocks from the National Stock Exchange of India:
- Source:
NSE Stocks Equity.csv(official NSE data) - Total: 1,999 equity stocks (SERIES = 'EQ')
- Featured: Top 500 stocks by market cap
- Update: Real-time prices via Yahoo Finance
- RELIANCE, TCS, INFY, HDFC, ICICI, SBI
- ADANIPORTS, ADANIENT, ADANIPOWER
- BAJAJ-AUTO, BAJAJFINSV, BAJFINANCE
- And 1,990+ more!
# Test all endpoints
./test-api.sh
# Test portfolio features
./test-portfolio-complete.sh
# Test flexible budget system
./test-flexible-budget.sh# Health check
curl http://localhost:3001/health
# Signup
curl -X POST http://localhost:3001/api/auth/signup \
-H "Content-Type: application/json" \
-d '{"email":"test@test.com","password":"Test123!","name":"Test User"}'
# Get featured stocks
curl http://localhost:3001/api/market/featured# Push to GitHub main branch
git add -A
git commit -m "Update: Description"
git push origin main
# Railway auto-deploys from GitHubProduction URL: https://devion-backend-prod-floral-sun-907-production.up.railway.app
Set these in Railway dashboard or CLI:
SUPABASE_URLSUPABASE_KEYJWT_SECRETJWT_EXPIRES_INOPENAI_API_KEYELEVENLABS_API_KEYPORT(usually auto-set)NODE_ENV=production
# Build Docker image
docker build -t devion-backend .
# Run container
docker run -p 3001:3001 --env-file .env devion-backenddevion.in-backend/
โโโ src/
โ โโโ config/
โ โ โโโ env.ts # Environment config
โ โ โโโ database.ts # Supabase client & helpers
โ โโโ middleware/
โ โ โโโ auth.ts # JWT authentication
โ โ โโโ errorHandler.ts # Global error handling
โ โ โโโ logger.ts # Request logging
โ โโโ controllers/
โ โ โโโ auth.controller.ts # Auth logic
โ โ โโโ market.controller.ts # Market data logic
โ โ โโโ portfolio.controller.ts # Portfolio logic
โ โ โโโ ai.controller.ts # AI tutor logic
โ โ โโโ voice.controller.ts # Voice AI logic
โ โโโ routes/
โ โ โโโ auth.routes.ts # Auth endpoints
โ โ โโโ market.routes.ts # Market endpoints
โ โ โโโ portfolio.routes.ts # Portfolio endpoints
โ โ โโโ ai.routes.ts # AI endpoints
โ โ โโโ voice.routes.ts # Voice endpoints
โ โโโ services/
โ โ โโโ yahoo.service.ts # Yahoo Finance integration
โ โ โโโ ai.service.ts # OpenAI integration
โ โ โโโ voice.service.ts # ElevenLabs integration
โ โโโ scripts/
โ โ โโโ import-nse-stocks.ts # NSE stock import script
โ โโโ utils/
โ โ โโโ logger.ts # Winston logger config
โ โโโ index.ts # Express server entry
โโโ dist/ # Compiled JavaScript
โโโ logs/ # Application logs
โโโ Dockerfile # Docker config
โโโ package.json # Dependencies
โโโ tsconfig.json # TypeScript config
โโโ .env # Environment variables (gitignored)
โโโ README.md # This file
- โ User authentication (signup/login/JWT)
- โ Flexible budget portfolio system
- โ Buy/sell stock execution
- โ Real-time market data (Yahoo Finance)
- โ 1,999 NSE stocks imported
- โ AI tutor (GPT-5 Q&A)
- โ Voice AI (ElevenLabs TTS)
- โ Trade history & P&L tracking
- โ Stock search & filtering
- โ Budget management & history
- ๐ง Lessons & quiz system
- ๐ง Badge & achievement system
- ๐ง Leaderboard rankings
- ๐ง Cohort management (for teachers)
- ๐ Subscription tier enforcement
- ๐ Payment gateway (Razorpay)
- ๐ Email notifications
- ๐ Admin dashboard
- ๐ Advanced analytics
| Component | Status | Details |
|---|---|---|
| API Server | โ Live | Railway (Auto-deploy from GitHub) |
| Database | โ Live | Supabase PostgreSQL (Mumbai) |
| Stock Data | โ Synced | 1,999 NSE stocks |
| AI Tutor | โ Active | OpenAI GPT-5 |
| Voice AI | โ Active | ElevenLabs |
| Market Data | โ Active | Yahoo Finance |
AI_SYSTEM_COMPLETE.md- AI tutor implementation guideVOICE_AI_COMPLETE.md- Voice AI integration detailsPORTFOLIO_API_SUCCESS.md- Portfolio API documentationFLEXIBLE_BUDGET_SYSTEM.md- Budget system designNSE_IMPORT_SUCCESS.md- Stock data import guideYAHOO_FINANCE_MIGRATION.md- Yahoo Finance integrationDEPLOY_FLYIO.md- Fly.io deployment (legacy)
This is a proprietary project by Devion Industries.
Proprietary - All rights reserved by Devion Industries
Devion Industries
Building the future of financial literacy in India ๐ฎ๐ณ
API Base URL: https://devion-backend-prod-floral-sun-907-production.up.railway.app/api
Made with โค๏ธ in India | Demo Live at Global Fintech Fest ๐