How harshul786/trading-signals works
Project type and purpose
• This is a Node.js/Express backend service for a cryptocurrency trading platform.
• Purpose: expose RESTful endpoints for user authentication, trade management, trade‐plan management, real‐time notifications (via Telegram), and portfolio tracking.
• Future plan: add a user‐facing frontend that consumes these APIs.
File structure
• Top‐level files: index.js (app entry), package.json (dependencies), vercel.json (deployment), README.md, .env (config).
• src/main
• api/ – route handlers (userResource, tradeResource, tradePlanResource).
• config/ – database configuration (mongoose.js).
• middleware/ – JWT authentication (auth.js).
• model/ – Mongoose schemas (user.js, trade.js, tradePlan.js).
• utils/ – algorithmic helpers (supertrend.js, tradeUtils.js), Telegram integration (telegram.js), OHLCV data utilities.
• src/tests – historical signal‐strategy tests against SOL‐USDC pairs over various timeframes.
• Indicates an MVC‐inspired pattern: routes → controllers/resources → service/utils → data (Mongo models).
README insights
• Describes core features and intended future UI.
• Lists environment variables for MongoDB, JWT, Telegram, client CORS and port.
• Deployment target: Vercel (serverless Node).
Main components & interactions
a. Clients
• (Future) Web/mobile UI or API clients
• External schedulers or bots for running tests
b. API Layer (Express.js)
• userResource
• tradeResource
• tradePlanResource
• auth middleware for JWT validation
c. Business Logic / Utilities
• supertrend calculation
• tradeUtils (position sizing, risk management)
• telegram.js (push notifications)
• ohlcv.js (historical data parsing for tests)
d. Data Layer
• MongoDB database
• Mongoose ORM models: User, Trade, TradePlan
e. External services
• Telegram Bot API
• (Potential) Crypto exchange APIs for price data (implied via tests)
f. Deployment
• Vercel serverless functions hosting index.js
Architectural patterns & design principles
• Layered (API → Middleware → Services/Utils → Data)
• Separation of concerns: authentication abstracted into middleware, business logic in utils.
• Stateless RESTful services using JWT.
• Modular, test‐driven approach: isolate strategy tests under src/tests.
Detail level
• Middleware chain and model relationships.
• Don’t overcomplicate—focus on primary flows: user auth, trade management, notifications, and data persistence.