Skip to content

anshukaushik4700/Trading-n8n

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Trading Workflow Monorepo

A monorepo for building and running automated trading workflows. It includes:

  • Frontend (apps/frontend) – React + Vite UI with a canvas (React Flow) to assemble trigger/action nodes, manage workflows, and view executions.
  • Backend (apps/backend) – Express API with JWT auth, MongoDB persistence, and Zod validation for workflows, users, and nodes.
  • Executor (apps/executor) – Worker that polls workflows, evaluates trigger nodes, and executes action nodes (trading logic stubbed for now).
  • Shared packages (packages/common, packages/db) – Zod schemas/types, metadata, and Mongoose models reused across apps.

Features

  • Create and visualize workflows composed of trigger and action nodes.
  • User signup/signin with JWT-based authorization.
  • Persist workflows, nodes, and execution history in MongoDB.
  • Executor loop that schedules executions (e.g., timer trigger) and runs action handlers.
  • Type-safe contracts across services via shared Zod schemas and Mongoose models.

Repository layout

  • apps/frontend – React UI (Vite). Scripts: bun run dev, bun run build, bun run lint.
  • apps/backend – Express API server. Entry: index.ts.
  • apps/executor – Background worker. Entry: index.ts.
  • packages/common – Shared types/metadata (e.g., workflow schemas, supported assets).
  • packages/db – Mongoose models for users, workflows, nodes, executions.
  • packages/eslint-config, packages/typescript-config – Shared tooling presets.

Prerequisites

  • Node.js 18+
  • Bun 1.3.x
  • MongoDB instance (local or remote)

Installation

bun install

The workspace is managed with Bun workspaces (see package.json), so a single install at the repo root resolves all app and package dependencies.

Environment variables

Create a .env in each runtime app (apps/backend, apps/executor, apps/frontend) with the values you need. Typical vars:

Backend / Executor:

MONGO_URL=mongodb://localhost:27017/trading-workflows
JWT_SECRET=super-secret-key
PORT=3000            # optional, backend only (defaults to 3000)

Frontend:

VITE_API_URL=http://localhost:3000

Running the stack (local)

In separate terminals:

# Backend API
cd apps/backend
bun run index.ts

# Executor worker
cd apps/executor
bun run index.ts

# Frontend (runs on Vite default 5173)
cd apps/frontend
bun run dev -- --host

Then open the frontend (http://localhost:5173 by default) and point it to the backend URL via VITE_API_URL.

API highlights (backend)

  • POST /signup – create user
  • POST /signin – login, returns JWT token
  • POST /workflow – create workflow (auth required)
  • PUT /workflow/:workflowId – update workflow (auth required)
  • GET /workflow/:workflowId – fetch workflow (auth required)
  • GET /workflows – list user workflows (auth required)
  • GET /workflow/executions/:workflowId – list executions (auth required)
  • GET /nodes – list available node definitions

Requests are validated with Zod schemas from packages/common/types.

Execution model (worker)

  • Connects to MongoDB and fetches workflows.
  • Detects trigger nodes (e.g., timer) and schedules executions.
  • Runs execute for downstream action nodes (e.g., lighter), where trading logic can be implemented (apps/executor/executors/lighter.ts currently stubbed).
  • Records execution status and timestamps in the Executions collection.

Development notes

  • Use bun run format at the repo root to format Markdown/TS/TSX.
  • Root scripts (package.json) also include lint, dev, build, and check-types via Turbo if you add per-package targets.
  • Shared schemas/types live in packages/common; reuse them across services to keep API contracts consistent.

Roadmap ideas

  • Implement real trading logic in apps/executor/executors/lighter.ts (and add more action handlers).
  • Add secure password hashing for auth.
  • Seed node definitions in MongoDB for actions/triggers exposed by the UI.
  • Add tests and CI for API and executor flows.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors