QuantNest is a workflow-first trading automation platform. It lets users design visual strategies (trigger -> decision -> action), execute them continuously, and receive guided notifications with AI-generated reasoning.
This repository is a Bun/Turbo monorepo containing:
- a React frontend workflow builder,
- an Express backend API,
- an executor service that polls workflows and performs actions,
- shared packages for types, DB models, and executor utilities.
- Overview
- Key Capabilities
- Architecture
- Repository Layout
- Tech Stack
- Getting Started
- Environment Variables
- Running the Platform
- Workflow Model
- Execution Lifecycle
- AI Notification Reasoning
- API Surface
- Operational Notes
- Troubleshooting
- Contributing
- License
QuantNest provides an end-to-end loop for automated trading workflows:
- Define workflow graph in the frontend.
- Persist workflows and credentials via backend APIs.
- Poll and evaluate triggers in executor.
- Execute actions (broker + notifications).
- Record run history and show it in dashboard/executions UI.
- Visual workflow builder with drag-and-connect node graph.
- Trigger support:
- Timer trigger
- Price trigger
- Conditional trigger (indicator expression groups)
- Action support:
- Broker actions (Zerodha, Groww, Lighter)
- Notification actions (Gmail, Discord)
- Conditional branching (
true/false) in workflow execution. - Execution tracking (status + step-level logs).
- AI-enhanced notifications:
- Reasoning
- Risk factors
- Confidence level + numeric score
flowchart LR
U["User"] --> F["Frontend (React/Vite)"]
F --> B["Backend API (Express)"]
B --> M[("MongoDB")]
E["Executor Service"] --> M
E --> X["Broker Integrations"]
E --> N["Notification Integrations"]
E --> A["Gemini AI"]
B --> F
E --> B
- Frontend (
apps/frontend): workflow authoring, dashboard, profile, executions view. - Backend (
apps/backend): auth, workflow CRUD, execution retrieval, token management. - Executor (
apps/executor): polling, trigger evaluation, branch routing, action execution, AI reasoning.
apps/
frontend/ React app (workflow builder + dashboard)
backend/ Express API server
executor/ Polling/execution worker service
packages/
types/ Shared TS types and schemas
db/ Mongoose models and DB exports
executor-utils/ Shared runtime helpers (token status, market status, etc.)
lighter-sdk-ts/ Lighter SDK + generated client
- Runtime: Bun, Node.js >= 18
- Monorepo orchestration: Turbo
- Frontend: React 19, Vite, Tailwind, React Flow (
@xyflow/react) - Backend: Express 5, Mongoose, JWT
- Executor: TypeScript + service modules, broker integrations, Resend, Gemini (
@google/genai) - Database: MongoDB
bun installCreate env files for backend, executor, and frontend (see Environment Variables).
Run each service in a dedicated terminal (see Running the Platform).
| Variable | Required | Description |
|---|---|---|
MONGO_URL |
Yes | MongoDB connection string |
JWT_SECRET |
Yes | JWT signing/verification secret |
NODE_ENV |
No | Runtime mode (development/production) |
| Variable | Required | Description |
|---|---|---|
MONGO_URL |
Yes | MongoDB connection string |
RESEND_API_KEY |
Yes (for Gmail notifications) | Resend API key |
GOOGLE_API_KEY |
Recommended (for AI reasoning) | Gemini API key |
| Variable | Required | Description |
|---|---|---|
VITE_BACKEND_URL |
Recommended | Backend base URL used by frontend HTTP client |
Example:
# apps/frontend/.env.local
VITE_BACKEND_URL=http://localhost:3000/api/v1Terminal 1 (Backend):
cd apps/backend
bun run index.tsTerminal 2 (Executor):
cd apps/executor
bun run index.tsTerminal 3 (Frontend):
cd apps/frontend
bun run devbun run dev
bun run build
bun run lintA workflow is a graph of:
nodes: trigger/action/conditional unitsedges: directed links between nodes (including branch handles)
timerprice-triggerconditional-trigger
- Trading:
zerodha,groww,lighter - Notifications:
gmail,discord
Conditional nodes expose true and false source handles. The executor evaluates condition metadata and traverses only matching branch edges.
- Executor starts and connects to MongoDB.
- Poll loop runs every
POLL_INTERVAL(currently 2000ms). - For each workflow:
- resolve trigger type,
- evaluate trigger condition (timer/price/conditional),
- enforce execution cooldown,
- execute graph recursively.
- Each run writes step-level status to
ExecutionModel. - Frontend executions page displays run history and details.
apps/executor/config/constants.tsPOLL_INTERVAL = 2000EXECUTION_COOLDOWN_MS = 5000
QuantNest enriches notifications with guided context.
- concise reasoning for the setup,
- key risks,
- confidence label + score.
- Executor collects trigger context (
triggerType, symbol, market, branches, timer interval). - If conditional expression exists, indicator references are registered.
- For simple workflows, default indicator references are synthesized.
- Indicator snapshots are collected and sent to Gemini as structured JSON.
- AI response is normalized and appended to Gmail/Discord content.
- If AI or parsing fails, deterministic fallback insight is used.
apps/executor/ai-models/gemini.tsapps/executor/services/indicator.engine.tsapps/executor/executors/gmail.tsapps/executor/executors/discord.tsapps/executor/executors/notificationContent.ts
Base backend routes:
/api/v1/user/api/v1/workflow/api/v1/zerodha-token
Examples:
POST /api/v1/user/signupPOST /api/v1/user/signinGET /api/v1/user/profilePOST /api/v1/workflowPUT /api/v1/workflow/:workflowIdGET /api/v1/workflow/:workflowIdGET /api/v1/workflow/getAllGET /api/v1/workflow/executions/:workflowIdDELETE /api/v1/workflow/:workflowIdGET /api/v1/zerodha-token/status/:workflowId
Market status endpoint is exposed by backend as:
GET /market-status
- Mongo is used by both backend and executor.
- Auth uses Bearer token (
Authorization: Bearer <token>). - Zerodha token lifecycle is managed per workflow/user.
- Notification delivery depends on external provider uptime and credentials.
- AI enrichment is additive; workflow notifications still send with fallback if AI is unavailable.
- Verify
VITE_BACKEND_URLpoints to running backend. - Confirm backend is listening on expected port.
- Check Mongo connectivity (
MONGO_URL). - Ensure workflows contain a valid trigger node.
- Check cooldown and trigger conditions.
- Gmail path: verify
RESEND_API_KEYand sender setup. - Discord path: validate webhook URL.
- Set
GOOGLE_API_KEYinapps/executor/.env. - Verify logs for Gemini failures.
- For simple workflows, ensure at least one symbol is discoverable or let fallback symbol path run.
- Create a feature branch.
- Keep changes scoped per service/module.
- Run lint/build for affected apps.
- Include migration/config notes in PR description when env/runtime behavior changes.
- Prefer shared types in
packages/typesfor cross-app contracts.
Benchmark scripts are in benchmarks/. Results below are from a local Mac ARM dev environment (Docker MongoDB + Redis).
| Metric | p50 | p95 | Mean |
|---|---|---|---|
| API request (no DB) | 1.0ms | 1.8ms | ~1ms |
| Burst (50 concurrent) | 1.9ms | 17ms | 4ms |
| Signin (bcrypt+MongoDB+JWT) | 89ms | 104ms | 90ms |
| Concurrent signins (1000 users) | 8.4s | 14.6s | 8.4s |
| Redis SET | 3.7ms | 5.3ms | 4.0ms |
| Redis GET | 3.5ms | 4.1ms | 3.5ms |
| AI framework overhead | — | — | 61µs |
Run all:
bash benchmarks/run-all.shSee benchmarks/README.md for details.
See LICENSE at repo root.