id field (stringified _id) and use created_at / updated_at timestamps.
Entity relationship diagram
Model summary
Key relationships
User ↔ Index Setting
User.pageAccessis an array ofObjectIdrefs toAppSetting.- Middleware checks
page.indexagainstPageAccessenum values (nifty50,bankNifty). AppSetting.createdBy/updatedByreference the adminUserwho modified the setting.
Index Setting ↔ Orders
- All order models use
indexName(string) matchingAppSetting.index. - Segment-specific config (
cash,futures,options) drives recurring buy and trailing sell behaviour.
Setting ↔ Order routing
Setting.isDummyOrderis a global switch.- When
true, controllers read/writeDummyOrderinstead ofOrder. - Zerodha placement is skipped in dummy mode.
Zerodha token
- Typically one document with
isLoggedIn: true. - Deleted and refreshed daily at 6:00 AM IST by the scheduled job.
Index Data vs Index
- IndexData — snapshots built by the Zerodha market data pipeline (
zerodha-event.utils.ts), stored for historical charts and Excel export. - Index — legacy TrueData tick format with
Symbol,LTP,OIfields. Used by older data paths.