How prabuselvamnatarajan/moneymaker_aws works
Purpose and topology
MoneyMaker is a containerized trading platform supporting backtesting and live strategy execution. It combines a management API/UI, market-data and broker integration services, Kafka-driven strategy/processing workers, and scheduled/bootstrap jobs. Compose/Swarm deployment is centered on docker-compose.yml, docker-compose.ci.yml, and scripts/deploy-stack.sh.
Operator-facing API and UI
The primary management backend is a Node.js application entered through BackTest/BackTestApp/src/server.js and assembled in BackTest/BackTestApp/src/app.js. Its route/controller/service layers manage accounts, brokers, strategies, deployments, trades, positions, ledgers, symbols, Docker resources, and volumes; representative boundaries are BackTest/BackTestApp/src/routes/deploymentRoute.js, BackTest/BackTestApp/src/controllers/trade.js, and BackTest/BackTestApp/src/services/strategy.js.
The main richer frontend is a Vite/React TypeScript UI entered at BackTest/BackTestUI/src/main.tsx, with shell/API integration in BackTest/BackTestUI/src/App.tsx and BackTest/BackTestUI/src/api.ts. A separate lightweight React client exists at client/src/main.jsx, with a backtest page at client/src/pages/BackTest.jsx.
Identity and persistent state
The API has a dedicated IAM subsystem for JWT/session, MFA, roles, permissions, and personal access tokens: BackTest/BackTestApp/src/iam/index.js, BackTest/BackTestApp/src/iam/services/authService.js, and BackTest/BackTestApp/src/iam/middlewares/authorizationMiddleware.js. It also retains older/general authentication middleware under BackTest/BackTestApp/src/middlewares/authMiddleware.js.
MongoDB is the durable domain store, with connection and model boundaries at BackTest/BackTestApp/src/db/connection.js, BackTest/BackTestApp/src/models/deployment.js, and BackTest/BackTestApp/src/models/trade.js. Redis is used for operational/state coordination through BackTest/BackTestApp/src/utils/positionRedis.js and reusable wrappers in redis_operations/index.js; Mongo replica-set setup is represented by mongo/mongod.conf and init-mongo-replica.sh.
Backtest lifecycle
The API creates and tracks strategy deployments/runs, while specialized backtest processes execute and stream results. Relevant execution entry points are BackTest/BacktestClient/clientServer.js and BackTest/BacktestStreamer/streamer.js; completion reconciliation is isolated in BackTest/BackTestApp/src/services/backtestCompletionWatcher.js. Backtest state must remain scoped per run/deployment, as indicated by dedicated run-ID synchronization and parallel-isolation service tests.
The UI consumes API and streaming outcomes for deployment analysis, transactions, positions, and candle views, notably BackTest/BackTestUI/src/components/DeploymentAnalysisView.tsx, BackTest/BackTestUI/src/components/TransactionList.tsx, and BackTest/BackTestUI/src/components/LiveCandlestickView.tsx.
Live market-data and execution boundary
Upstox is the evident external broker/vendor boundary. Microservices provide login, WebSocket market feed connectivity, quotes, option-chain data, order placement/order book access, and funds/margin retrieval: MicroServices/UpstoxLogin/server.js, MicroServices/ConnectWS-Upstox/server.js, and MicroServices/Orders/placeOrders/server.js. Shared authorization/client logic is at MicroServices/Shared/AuthorisedUpstox/AuthoriseUpstoxClient.js.
The API’s broker abstraction and external-broker identity mapping separate platform entities from vendor credentials: BackTest/BackTestApp/src/services/broker.js, BackTest/BackTestApp/src/services/externalBroker.js, and BackTest/BackTestApp/src/models/externalBrokerId.js.
Event pipeline and strategy execution
Kafka is the principal asynchronous control/data plane. Incoming WebSocket data is split and forwarded by kafka/services/wsDataSplitterConsumer/wsDataSplitterConsumer.js; strategy selection and deployment-symbol resolution are handled by kafka/services/StrategyChooserConsumer/StrategyChooserConsumer.js and kafka/services/deploymentSymbolResolverConsumer/deploymentSymbolResolverConsumer.js. Positions and persisted events are processed by kafka/services/positionTrackerConsumer/positionTrackerConsumer.js and kafka/services/storerConsumer/storerConsumer.js; client streaming has its own WebSocket service at kafka/services/streamToClient/wsServer.js.
Runnable strategy workers include MSB, MSB PTS, and liquidity sweep: kafka/services/Strategies/MSB/server.js, kafka/services/Strategies/msb_pts/server.js, and kafka/services/Strategies/liquidity_sweep/server.js. They consume market events, use Redis-backed strategy state/concurrency controls, and can lead to broker order calls.
Bootstrap, scheduling, and runtime infrastructure
Startup orchestration initializes live strategy choice and WebSocket listening via appInit/start.js, appInit/Init/strategyChooser_Live.js, and appInit/Init/webSocketListening_Live.js. Periodic services export data and initialize MSB strategy work through ScheduledServices/ExportToFile/scheduler.js and ScheduledServices/MSBStrategyInit/scheduler.js.
Docker is the material runtime for each service, with Kafka/Zookeeper images under kafka/broker/Dockerfile and kafka/zookeeper/Dockerfile; reverse-proxy TLS configuration resides at certs/nginx.conf. System-level intended flows are additionally documented in system_flows/live_trading_flow.md and system_flows/backtest_flow.md.
Main entry points: src/server.js Management API · Dockerfile Kafka · MSB/server.js Strategy workers · ConnectWS-Upstox/server.js Upstox integration services
Components 21
Operator surfaces
- React management UI
BackTest/BackTestUI/src/main.tsx - Lightweight backtest UI
client/src/main.jsx
Management platform
- Management API · Routes and services manage platform entities and deployments.
BackTest/BackTestApp/src/server.js - IAM · JWT, sessions, MFA, roles, permissions, and access tokens.
BackTest/BackTestApp/src/iam/index.js - Domain store
BackTest/BackTestApp/src/db/connection.js - Operational state · Position and strategy coordination state.
BackTest/BackTestApp/src/utils/positionRedis.js - Broker abstraction · Maps platform brokers to external broker identities.
BackTest/BackTestApp/src/services/broker.js
Backtest runtime
- Backtest completion watcher · Reconciles completed runs into deployment state.
BackTest/BackTestApp/src/services/backtestCompletionWatcher.js - Backtest executor
BackTest/BacktestClient/clientServer.js - Backtest streamer · Streams run-scoped backtest results.
BackTest/BacktestStreamer/streamer.js
Live event pipeline
- Kafka · Asynchronous market-data and strategy control plane.
kafka/broker/Dockerfile - Market data splitter
kafka/services/wsDataSplitterConsumer/wsDataSplitterConsumer.js - Strategy routing · Chooses strategies and resolves deployment symbols.
kafka/services/StrategyChooserConsumer/StrategyChooserConsumer.js - Strategy workers · Execute live trading logic from market events.
kafka/services/Strategies/MSB/server.js - Position and event persistence
kafka/services/positionTrackerConsumer/positionTrackerConsumer.js - Live client stream
kafka/services/streamToClient/wsServer.js
Broker and runtime
- Upstox integration services · Login, market feed, quotes, orders, and funds integration.
MicroServices/ConnectWS-Upstox/server.js - Upstox
- Live startup orchestration · Initializes strategy selection and WebSocket listening.
appInit/start.js - Scheduled jobs · Exports data and initializes MSB work.
ScheduledServices/MSBStrategyInit/scheduler.js - Container deployment
docker-compose.yml
Connections 28
- React management UI → Management API: management API
- Lightweight backtest UI → Management API: backtest API
- Management API → IAM: authenticates requests
- Management API → Domain store: domain reads/writes
- Management API → Operational state: position coordination
- Management API → Broker abstraction: broker operations
- Broker abstraction → Upstox integration services: vendor calls
- Upstox integration services → Upstox: broker API and feed
- Management API → Backtest executor: starts and tracks runs
- Backtest executor → Backtest streamer: run results
- Backtest streamer → React management UI: analysis stream
- Backtest streamer → Backtest completion watcher: completion outcome
- Backtest completion watcher → Domain store: reconciles run state
- Upstox integration services → Kafka: market events
- Kafka → Market data splitter: raw feed
- Market data splitter → Kafka: split events
- Kafka → Strategy routing: market events
- Strategy routing → Strategy workers: selected deployment events
- Strategy workers → Operational state: strategy state and locks
- Strategy workers → Upstox integration services: order requests
- Kafka → Position and event persistence: trade and position events
- Position and event persistence → Domain store: persists events
- Kafka → Live client stream: live updates
- Live client stream → React management UI: live candles and positions
- Live startup orchestration → Kafka: starts live selection
- Scheduled jobs → Strategy workers: initializes MSB work
- Container deployment → Management API: runs
- Container deployment → Kafka: runs