# jinay-bhatt/backend-api architecture

> Architecture diagram of the GitHub repository jinay-bhatt/backend-api, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jinay-bhatt/backend-api
- Repository: https://github.com/jinay-bhatt/backend-api

## Overview

JBSnap is a visual backend-workflow builder: developers create projects, design and test API pipelines, then monitor executions and export deployable code. Its major branches include AI-assisted workflow generation, service-mesh configuration, analytics/live monitoring, and account management. The README documents these capabilities; sampled backend and frontend files confirm the server setup, gateway execution dependencies, export worker, service configuration, and API client. Several feature implementations were not sampled, so their internal call relationships are omitted.

Main entry points: [`backend/src/index.ts`](https://github.com/jinay-bhatt/backend-api/blob/main/backend/src/index.ts) (Fastify API Server), [`frontend/src/services/api.ts`](https://github.com/jinay-bhatt/backend-api/blob/main/frontend/src/services/api.ts) (Frontend API Client), [`backend/src/routes/gateway.ts`](https://github.com/jinay-bhatt/backend-api/blob/main/backend/src/routes/gateway.ts) (Gateway Execution), [`backend/src/queue/processor.ts`](https://github.com/jinay-bhatt/backend-api/blob/main/backend/src/queue/processor.ts) (Export Processor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workspace["Workspace and Identity"]
  node_dashboard["Project Dashboard<br/>[page.tsx]"]
  node_authui["Sign-in and Registration<br/>[page.tsx]"]
  node_auth["Authentication<br/>[auth.ts]"]
  node_projects["Project Management<br/>[projects.ts]"]
end

subgraph group_workflow["Workflow Design and Runtime"]
  node_builder["Visual Workflow Builder<br/>[page.tsx]"]
  node_customnodes["Workflow Nodes<br/>[customNodes.tsx]"]
  node_workflows["Workflow Management<br/>[workflows.ts]"]
  node_gateway["Gateway Execution<br/>[gateway.ts]"]
  node_dag["DAG Ordering<br/>[dag.ts]"]
  node_sandbox["Code Sandbox<br/>[sandbox.ts]"]
  node_ai["AI Workflow Synthesis<br/>[ai.ts]"]
end

subgraph group_operations["Monitoring and Services"]
  node_analytics["Analytics and Logs<br/>[analytics.ts]"]
  node_monitor["Live Monitor<br/>[page.tsx]"]
  node_websocket["Live WebSocket<br/>[websocket.ts]"]
  node_servicesui["Service Mesh Workspace<br/>[page.tsx]"]
  node_services["Service Registry<br/>[services.ts]"]
end

subgraph group_delivery["Compilation and Export"]
  node_compiler["Backend Compiler<br/>[compiler.ts]"]
  node_exportui["Export Workspace<br/>[page.tsx]"]
  node_exportqueue["Export Queue<br/>[exportQueue.ts]"]
  node_worker["Export Worker<br/>[worker.ts]"]
  node_processor["Export Processor<br/>[processor.ts]"]
  node_github["GitHub Integration<br/>[github.ts]"]
end

subgraph group_platform["Platform Core"]
  node_api["Frontend API Client<br/>[api.ts]"]
  node_server["Fastify API Server<br/>[index.ts]"]
  node_database[("PostgreSQL Database<br/>[db.ts]")]
  node_cache["Workflow Cache<br/>[cache.ts]"]
  node_security["Security Middleware<br/>[security.ts]"]
end

node_developer(("Developer"))

node_developer -->|"manages projects"| node_dashboard
node_developer -->|"signs in"| node_authui
node_dashboard -->|"requests data"| node_api
node_authui -->|"authenticates through"| node_api
node_api -->|"calls API"| node_server
node_server -->|"registers routes"| node_auth
node_server -->|"registers routes"| node_projects
node_server -->|"registers routes"| node_workflows
node_server -->|"registers routes"| node_gateway
node_server -->|"registers routes"| node_services
node_server -->|"registers routes"| node_analytics
node_builder -->|"saves workflows"| node_api
node_builder -->|"renders nodes"| node_customnodes
node_developer -->|"designs pipelines"| node_builder
node_developer -->|"describes workflow"| node_ai
node_developer -->|"tests and invokes"| node_gateway
node_gateway -->|"loads workflow data"| node_database
node_gateway -->|"orders steps"| node_dag
node_gateway -->|"executes code"| node_sandbox
node_gateway -->|"uses cache"| node_cache
node_developer -->|"monitors runs"| node_monitor
node_monitor -->|"requests metrics"| node_api
node_developer -->|"maps services"| node_servicesui
node_servicesui -->|"configures services"| node_api
node_services -->|"persists configuration"| node_database
node_services -->|"invalidates workflows"| node_cache
node_developer -->|"exports backend"| node_exportui
node_exportui -->|"requests export"| node_api
node_server -->|"initializes queue"| node_exportqueue
node_exportqueue -->|"dispatches jobs"| node_processor
node_server -->|"starts worker"| node_worker
node_worker -->|"processes jobs"| node_processor
node_processor -->|"compiles project"| node_compiler
node_processor -->|"publishes code"| node_github
node_processor -->|"loads project data"| node_database
node_server -->|"initializes socket"| node_websocket
node_server -->|"registers hooks"| node_security
node_monitor -->|"streams execution data"| node_websocket

click node_dashboard "https://github.com/jinay-bhatt/backend-api/blob/main/frontend/src/app/dashboard/page.tsx"
click node_authui "https://github.com/jinay-bhatt/backend-api/blob/main/frontend/src/app/login/page.tsx"
click node_api "https://github.com/jinay-bhatt/backend-api/blob/main/frontend/src/services/api.ts"
click node_server "https://github.com/jinay-bhatt/backend-api/blob/main/backend/src/index.ts"
click node_auth "https://github.com/jinay-bhatt/backend-api/blob/main/backend/src/controllers/auth.ts"
click node_projects "https://github.com/jinay-bhatt/backend-api/blob/main/backend/src/controllers/projects.ts"
click node_builder "https://github.com/jinay-bhatt/backend-api/blob/main/frontend/src/app/projects/%5Bid%5D/builder/page.tsx"
click node_customnodes "https://github.com/jinay-bhatt/backend-api/blob/main/frontend/src/components/customNodes.tsx"
click node_workflows "https://github.com/jinay-bhatt/backend-api/blob/main/backend/src/controllers/workflows.ts"
click node_gateway "https://github.com/jinay-bhatt/backend-api/blob/main/backend/src/routes/gateway.ts"
click node_dag "https://github.com/jinay-bhatt/backend-api/blob/main/backend/src/services/dag.ts"
click node_sandbox "https://github.com/jinay-bhatt/backend-api/blob/main/backend/src/services/sandbox.ts"
click node_ai "https://github.com/jinay-bhatt/backend-api/blob/main/backend/src/services/ai.ts"
click node_analytics "https://github.com/jinay-bhatt/backend-api/blob/main/backend/src/controllers/analytics.ts"
click node_monitor "https://github.com/jinay-bhatt/backend-api/blob/main/frontend/src/app/projects/%5Bid%5D/monitor/page.tsx"
click node_websocket "https://github.com/jinay-bhatt/backend-api/blob/main/backend/src/websocket.ts"
click node_servicesui "https://github.com/jinay-bhatt/backend-api/blob/main/frontend/src/app/projects/%5Bid%5D/services/page.tsx"
click node_services "https://github.com/jinay-bhatt/backend-api/blob/main/backend/src/controllers/services.ts"
click node_compiler "https://github.com/jinay-bhatt/backend-api/blob/main/backend/src/services/compiler.ts"
click node_exportui "https://github.com/jinay-bhatt/backend-api/blob/main/frontend/src/app/projects/%5Bid%5D/export/page.tsx"
click node_exportqueue "https://github.com/jinay-bhatt/backend-api/blob/main/backend/src/queue/exportQueue.ts"
click node_worker "https://github.com/jinay-bhatt/backend-api/blob/main/backend/src/queue/worker.ts"
click node_processor "https://github.com/jinay-bhatt/backend-api/blob/main/backend/src/queue/processor.ts"
click node_github "https://github.com/jinay-bhatt/backend-api/blob/main/backend/src/services/github.ts"
click node_database "https://github.com/jinay-bhatt/backend-api/blob/main/backend/src/services/db.ts"
click node_cache "https://github.com/jinay-bhatt/backend-api/blob/main/backend/src/services/cache.ts"
click node_security "https://github.com/jinay-bhatt/backend-api/blob/main/backend/src/middleware/security.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_dashboard,node_authui,node_auth,node_projects toneBlue
class node_builder,node_customnodes,node_workflows,node_gateway,node_dag,node_sandbox,node_ai toneAmber
class node_analytics,node_monitor,node_websocket,node_servicesui,node_services toneMint
class node_compiler,node_exportui,node_exportqueue,node_worker,node_processor,node_github toneRose
class node_api,node_server,node_database,node_cache,node_security,node_developer toneIndigo
```

## Components

### Workspace and Identity

- [Project Dashboard](https://github.com/jinay-bhatt/backend-api/blob/main/frontend/src/app/dashboard/page.tsx): `frontend/src/app/dashboard/page.tsx`
- [Sign-in and Registration](https://github.com/jinay-bhatt/backend-api/blob/main/frontend/src/app/login/page.tsx): `frontend/src/app/login/page.tsx`
- [Authentication](https://github.com/jinay-bhatt/backend-api/blob/main/backend/src/controllers/auth.ts): `backend/src/controllers/auth.ts`
- [Project Management](https://github.com/jinay-bhatt/backend-api/blob/main/backend/src/controllers/projects.ts): `backend/src/controllers/projects.ts`

### Workflow Design and Runtime

- [Visual Workflow Builder](https://github.com/jinay-bhatt/backend-api/blob/main/frontend/src/app/projects/%5Bid%5D/builder/page.tsx): `frontend/src/app/projects/[id]/builder/page.tsx`
- [Workflow Nodes](https://github.com/jinay-bhatt/backend-api/blob/main/frontend/src/components/customNodes.tsx): `frontend/src/components/customNodes.tsx`
- [Workflow Management](https://github.com/jinay-bhatt/backend-api/blob/main/backend/src/controllers/workflows.ts): `backend/src/controllers/workflows.ts`
- [Gateway Execution](https://github.com/jinay-bhatt/backend-api/blob/main/backend/src/routes/gateway.ts): `backend/src/routes/gateway.ts`
- [DAG Ordering](https://github.com/jinay-bhatt/backend-api/blob/main/backend/src/services/dag.ts): `backend/src/services/dag.ts`
- [Code Sandbox](https://github.com/jinay-bhatt/backend-api/blob/main/backend/src/services/sandbox.ts): `backend/src/services/sandbox.ts`
- [AI Workflow Synthesis](https://github.com/jinay-bhatt/backend-api/blob/main/backend/src/services/ai.ts): `backend/src/services/ai.ts`

### Monitoring and Services

- [Analytics and Logs](https://github.com/jinay-bhatt/backend-api/blob/main/backend/src/controllers/analytics.ts): `backend/src/controllers/analytics.ts`
- [Live Monitor](https://github.com/jinay-bhatt/backend-api/blob/main/frontend/src/app/projects/%5Bid%5D/monitor/page.tsx): `frontend/src/app/projects/[id]/monitor/page.tsx`
- [Live WebSocket](https://github.com/jinay-bhatt/backend-api/blob/main/backend/src/websocket.ts): `backend/src/websocket.ts`
- [Service Mesh Workspace](https://github.com/jinay-bhatt/backend-api/blob/main/frontend/src/app/projects/%5Bid%5D/services/page.tsx): `frontend/src/app/projects/[id]/services/page.tsx`
- [Service Registry](https://github.com/jinay-bhatt/backend-api/blob/main/backend/src/controllers/services.ts): `backend/src/controllers/services.ts`

### Compilation and Export

- [Backend Compiler](https://github.com/jinay-bhatt/backend-api/blob/main/backend/src/services/compiler.ts): `backend/src/services/compiler.ts`
- [Export Workspace](https://github.com/jinay-bhatt/backend-api/blob/main/frontend/src/app/projects/%5Bid%5D/export/page.tsx): `frontend/src/app/projects/[id]/export/page.tsx`
- [Export Queue](https://github.com/jinay-bhatt/backend-api/blob/main/backend/src/queue/exportQueue.ts): `backend/src/queue/exportQueue.ts`
- [Export Worker](https://github.com/jinay-bhatt/backend-api/blob/main/backend/src/queue/worker.ts): `backend/src/queue/worker.ts`
- [Export Processor](https://github.com/jinay-bhatt/backend-api/blob/main/backend/src/queue/processor.ts): `backend/src/queue/processor.ts`
- [GitHub Integration](https://github.com/jinay-bhatt/backend-api/blob/main/backend/src/services/github.ts): `backend/src/services/github.ts`

### Platform Core

- [Frontend API Client](https://github.com/jinay-bhatt/backend-api/blob/main/frontend/src/services/api.ts): `frontend/src/services/api.ts`
- [Fastify API Server](https://github.com/jinay-bhatt/backend-api/blob/main/backend/src/index.ts): `backend/src/index.ts`
- [PostgreSQL Database](https://github.com/jinay-bhatt/backend-api/blob/main/backend/src/services/db.ts): `backend/src/services/db.ts`
- [Workflow Cache](https://github.com/jinay-bhatt/backend-api/blob/main/backend/src/services/cache.ts): `backend/src/services/cache.ts`
- [Security Middleware](https://github.com/jinay-bhatt/backend-api/blob/main/backend/src/middleware/security.ts): `backend/src/middleware/security.ts`

### Other components

- **Developer**

## Connections

- Developer → Project Dashboard: manages projects (evidence: `README.md`)
- Developer → Sign-in and Registration: signs in (evidence: `README.md`)
- Project Dashboard → Frontend API Client: requests data (evidence: `frontend/src/app/dashboard/page.tsx`)
- Sign-in and Registration → Frontend API Client: authenticates through (evidence: `frontend/src/app/login/page.tsx`)
- Frontend API Client → Fastify API Server: calls API (evidence: `frontend/src/services/api.ts`)
- Fastify API Server → Authentication: registers routes (evidence: `backend/src/index.ts`)
- Fastify API Server → Project Management: registers routes (evidence: `backend/src/index.ts`)
- Fastify API Server → Workflow Management: registers routes (evidence: `backend/src/index.ts`)
- Fastify API Server → Gateway Execution: registers routes (evidence: `backend/src/index.ts`)
- Fastify API Server → Service Registry: registers routes (evidence: `backend/src/index.ts`)
- Fastify API Server → Analytics and Logs: registers routes (evidence: `backend/src/index.ts`)
- Visual Workflow Builder → Frontend API Client: saves workflows (evidence: `frontend/src/app/projects/[id]/builder/page.tsx`)
- Visual Workflow Builder → Workflow Nodes: renders nodes (evidence: `frontend/src/app/projects/[id]/builder/page.tsx`)
- Developer → Visual Workflow Builder: designs pipelines (evidence: `README.md`)
- Developer → AI Workflow Synthesis: describes workflow (evidence: `README.md`)
- Developer → Gateway Execution: tests and invokes (evidence: `README.md`)
- Gateway Execution → PostgreSQL Database: loads workflow data (evidence: `backend/src/routes/gateway.ts`)
- Gateway Execution → DAG Ordering: orders steps (evidence: `backend/src/routes/gateway.ts`)
- Gateway Execution → Code Sandbox: executes code (evidence: `backend/src/routes/gateway.ts`)
- Gateway Execution → Workflow Cache: uses cache (evidence: `backend/src/routes/gateway.ts`)
- Developer → Live Monitor: monitors runs (evidence: `README.md`)
- Live Monitor → Frontend API Client: requests metrics (evidence: `README.md`)
- Developer → Service Mesh Workspace: maps services (evidence: `README.md`)
- Service Mesh Workspace → Frontend API Client: configures services (evidence: `README.md`)
- Service Registry → PostgreSQL Database: persists configuration (evidence: `backend/src/controllers/services.ts`)
- Service Registry → Workflow Cache: invalidates workflows (evidence: `backend/src/controllers/services.ts`)
- Developer → Export Workspace: exports backend (evidence: `README.md`)
- Export Workspace → Frontend API Client: requests export (evidence: `README.md`)
- Fastify API Server → Export Queue: initializes queue (evidence: `backend/src/index.ts`)
- Export Queue → Export Processor: dispatches jobs (evidence: `backend/src/queue/exportQueue.ts`)
- Fastify API Server → Export Worker: starts worker (evidence: `backend/src/index.ts`)
- Export Worker → Export Processor: processes jobs (evidence: `backend/src/queue/worker.ts`)
- Export Processor → Backend Compiler: compiles project (evidence: `backend/src/queue/processor.ts`)
- Export Processor → GitHub Integration: publishes code (evidence: `backend/src/queue/processor.ts`)
- Export Processor → PostgreSQL Database: loads project data (evidence: `backend/src/queue/processor.ts`)
- Fastify API Server → Live WebSocket: initializes socket (evidence: `backend/src/index.ts`)
- Fastify API Server → Security Middleware: registers hooks (evidence: `backend/src/index.ts`)
- Live Monitor → Live WebSocket: streams execution data (evidence: `README.md`)
