# shreyashxp095/n8nlocalone architecture

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

- Interactive diagram: https://gitdiagram.com/shreyashxp095/n8nlocalone
- Repository: https://github.com/shreyashxp095/n8nlocalone

## Overview

1. **What this repo is**
   - This is a **Next.js App Router** application that implements a **workflow automation platform**.
   - The core product concept is: users sign in, build workflows in a visual editor, store credentials, and then run or receive executions from triggers and actions.

2. **Top-level application structure**
   - The app is split into route groups under `src/app`:
     - `/(auth)` for login/signup
     - `/(dashboard)` for the main product UI
     - `/api` for backend endpoints
   - This separation matters because the same codebase contains both the interactive UI and server-side automation endpoints.

3. **Primary user-facing subsystems**
   - `src/features/workflows` handles workflow lists and workflow metadata.
   - `src/features/editor` owns the visual workflow editor and execution controls.
   - `src/features/credentials` manages stored integration credentials.
   - `src/features/executions` shows execution history and execution details.
   - `src/features/auth` contains the sign-in and sign-up forms and layout.
   - These feature folders are the main domain boundaries for the diagram.

4. **Workflow editor as the central UI**
   - The editor is built around **React Flow-style node graphs** using reusable node components in `src/components/react-flow` and workflow-specific UI in `src/features/editor/components`.
   - Supporting components like `add-node-button`, `node-selector`, `workflow-node`, and `initial-node` indicate the editor is a node/edge builder rather than a form-based configuration screen.
   - The editor likely reads workflow definitions from the backend, renders nodes, and sends updates back through the data layer.

5. **Trigger/action/execution model**
   - The domain is split into:
     - **Triggers** in `src/features/triggers`
     - **Executions/actions** in `src/features/executions`
   - Trigger implementations include `manual-trigger`, `google-form-trigger`, and `stripe-trigger`.
   - Execution/action implementations include `slack`, `discord`, `openai`, `gemini`, `groq`, and `http-request`.
   - This suggests workflows are composed of heterogeneous nodes where trigger nodes start the workflow and action nodes perform downstream work.

6. **Runtime orchestration**
   - `src/inngest` is the background execution layer.
   - It contains:
     - channel implementations for each integration type
     - `functions.ts` for registered background functions
     - a client and utility helpers
   - This is the likely system that actually processes workflow runs asynchronously, especially for external-event triggers and multi-step execution.

7. **API surface and server boundaries**
   - The repo exposes several backend entry points under `src/app/api`:
     - `auth/[...all]` for authentication
     - `trpc/[trpc]` for typed client/server data access
     - `webhooks/google-form` and `webhooks/stripe` for external event ingestion
     - `inngest/route.ts` for the background worker/event gateway
   - These routes are the main boundary between external systems and the app’s internal domain logic.

8. **Data access and server-side state**
   - `src/trpc` provides the typed RPC layer used by the UI.
   - Each feature has server helpers under `server/` such as `routers.ts`, `prefetch.ts`, and `params-loader.ts`, which suggests server-side preloading and shared query definitions.
   - `src/lib/db.ts` indicates Prisma-backed database access, with `prisma/schema.prisma` and a long migration history showing the domain evolved incrementally.

9. **Persistence model**
   - The database schema includes migrations for:
     - auth-related fields
     - workflows
     - React Flow tables
     - AI models/nodes
     - credentials
     - messaging nodes
     - execution history
   - That migration history implies the stored model is not just user accounts; it includes the workflow graph, integrations, execution logs, and node-type-specific configuration.

10. **Credentials and secrets**
   - `src/features/credentials` plus `src/lib/encryption.ts` show a dedicated subsystem for storing integration credentials securely.
   - Credentials are a shared resource used by action nodes and trigger nodes that need third-party API access.
   - This is a critical boundary: workflow definitions are separate from sensitive connection material.

11. **Authentication and subscription gating**
   - Authentication is handled through `src/lib/auth.ts`, `auth-client.ts`, and `auth-utils.ts`, with a Next.js route handler under `/api/auth`.
   - `src/features/subscriptions` and `src/lib/polar.ts` suggest billing/subscription enforcement is part of the architecture, likely used to gate premium workflow or execution features.
   - `src/components/upgrade-modal.tsx` supports that product-level constraint in the UI.

12. **Observability and runtime support**
   - `sentry.server.config.ts`, `sentry.edge.config.ts`, and `src/instrumentation*.ts` show the app is instrumented for error tracking across server and edge/runtime boundaries.
   - This is relevant for a workflow engine because failures can happen in UI, API routes, webhook handlers, or background executions.

13. **Shared UI and design system**
   - `src/components/ui` is a large reusable component library, likely generated from a design system setup.
   - Higher-level application chrome lives in `app-header`, `app-sidebar`, and dashboard layouts.
   - These pieces support the main feature modules but are not themselves domain logic.

14. **How the main data flow likely works**
   - User authenticates through the auth subsystem.
   - User creates or edits a workflow in the dashboard editor.
   - Workflow definitions and credentials are persisted in Prisma-backed storage.
   - External events arrive through webhooks or manual invocation.
   - Inngest/background functions execute the relevant trigger/action chain.
   - Execution results are stored and surfaced in the executions UI.

15. **What to emphasize in an architecture diagram**
   - Show **three major zones**: browser UI, Next.js server/API, and background execution/integration runtime.
   - Inside the server/API zone, separate **auth**, **typed app queries (tRPC)**, **webhooks**, and **Inngest entrypoints**.
   - Inside the domain, separate **workflow graph editing**, **credentials**, **executions/history**, and **trigger/action node implementations**.
   - Show the database as shared persistence for workflows, credentials, and execution history.

Main entry points: [`src/lib/db.ts`](https://github.com/shreyashxp095/n8nlocalone/blob/main/src/lib/db.ts) (DB Client), [`src/features/editor/components/editor.tsx`](https://github.com/shreyashxp095/n8nlocalone/blob/main/src/features/editor/components/editor.tsx) (Editor), [`src/app/api/trpc/[trpc]/route.ts`](https://github.com/shreyashxp095/n8nlocalone/blob/main/src/app/api/trpc/[trpc]/route.ts) (tRPC API), [`src/app/(dashboard)/layout.tsx`](https://github.com/shreyashxp095/n8nlocalone/blob/main/src/app/(dashboard)/layout.tsx) (Dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Browser UI"]
  node_auth_ui["Auth UI<br/>feature<br/>[auth-layout.tsx]"]
  node_dashboard_shell["Dashboard<br/>layout<br/>[layout.tsx]"]
  node_workflow_list["Workflows<br/>feature<br/>[workflows.tsx]"]
  node_workflow_editor["Editor<br/>feature<br/>[editor.tsx]"]
  node_react_flow_ui["Flow Nodes<br/>component set<br/>[base-node.tsx]"]
  node_credentials_ui["Credentials<br/>feature<br/>[credentials.tsx]"]
  node_executions_ui["Executions<br/>feature<br/>[executions.tsx]"]
  node_trigger_nodes["Triggers<br/>domain nodes<br/>[node.tsx]"]
  node_action_nodes["Actions<br/>domain nodes<br/>[node.tsx]"]
end

subgraph group_server["Next.js API"]
  node_api_auth["Auth API<br/>route handler<br/>[route.ts]"]
  node_api_trpc["tRPC API<br/>route handler<br/>[route.ts]"]
  node_api_webhooks["Webhooks<br/>route handlers<br/>[route.ts]"]
  node_api_inngest["Inngest API<br/>route handler<br/>[route.ts]"]
  node_trpc_router["App RPC<br/>server layer<br/>[_app.ts]"]
  node_feature_servers["Feature Servers<br/>server layer<br/>[routers.ts]"]
end

subgraph group_runtime["Execution Runtime"]
  node_inngest_core["Inngest Core<br/>runtime<br/>[functions.ts]"]
  node_channel_impls["Channels<br/>runtime adapters<br/>[slack.ts]"]
end

subgraph group_data["Persistence"]
  node_db[("Database<br/>Prisma schema<br/>[schema.prisma]")]
  node_db_client["DB Client<br/>lib<br/>[db.ts]"]
  node_security["Security<br/>lib<br/>[auth.ts]"]
end

node_auth_ui -->|"sign in/up"| node_api_auth
node_dashboard_shell -->|"hosts"| node_workflow_list
node_dashboard_shell -->|"hosts"| node_workflow_editor
node_dashboard_shell -->|"hosts"| node_credentials_ui
node_dashboard_shell -->|"hosts"| node_executions_ui
node_workflow_editor -->|"renders"| node_react_flow_ui
node_workflow_editor -->|"adds triggers"| node_trigger_nodes
node_workflow_editor -->|"adds actions"| node_action_nodes
node_workflow_list -->|"loads data"| node_api_trpc
node_credentials_ui -->|"loads data"| node_api_trpc
node_executions_ui -->|"loads data"| node_api_trpc
node_workflow_editor -->|"persists edits"| node_api_trpc
node_api_trpc -->|"dispatches to"| node_trpc_router
node_trpc_router -->|"delegates"| node_feature_servers
node_feature_servers -->|"queries"| node_db_client
node_db_client -->|"reads/writes"| node_db
node_api_webhooks -->|"enqueues events"| node_inngest_core
node_api_inngest -->|"serves"| node_inngest_core
node_inngest_core -->|"runs"| node_channel_impls
node_channel_impls -->|"state access"| node_db_client
node_security -->|"protects"| node_api_auth
node_security -->|"secures data"| node_db_client
node_api_auth -->|"accounts"| node_db_client
node_trpc_router -->|"uses"| node_security
node_inngest_core -->|"stores runs"| node_db_client

click node_auth_ui "https://github.com/shreyashxp095/n8nlocalone/blob/main/src/features/auth/components/auth-layout.tsx"
click node_dashboard_shell "https://github.com/shreyashxp095/n8nlocalone/blob/main/src/app/(dashboard)/layout.tsx"
click node_workflow_list "https://github.com/shreyashxp095/n8nlocalone/blob/main/src/features/workflows/components/workflows.tsx"
click node_workflow_editor "https://github.com/shreyashxp095/n8nlocalone/blob/main/src/features/editor/components/editor.tsx"
click node_react_flow_ui "https://github.com/shreyashxp095/n8nlocalone/blob/main/src/components/react-flow/base-node.tsx"
click node_credentials_ui "https://github.com/shreyashxp095/n8nlocalone/blob/main/src/features/credentials/components/credentials.tsx"
click node_executions_ui "https://github.com/shreyashxp095/n8nlocalone/blob/main/src/features/executions/components/executions.tsx"
click node_trigger_nodes "https://github.com/shreyashxp095/n8nlocalone/blob/main/src/features/triggers/components/manual-trigger/node.tsx"
click node_action_nodes "https://github.com/shreyashxp095/n8nlocalone/blob/main/src/features/executions/components/slack/node.tsx"
click node_api_auth "https://github.com/shreyashxp095/n8nlocalone/blob/main/src/app/api/auth/[...all]/route.ts"
click node_api_trpc "https://github.com/shreyashxp095/n8nlocalone/blob/main/src/app/api/trpc/[trpc]/route.ts"
click node_api_webhooks "https://github.com/shreyashxp095/n8nlocalone/blob/main/src/app/api/webhooks/google-form/route.ts"
click node_api_inngest "https://github.com/shreyashxp095/n8nlocalone/blob/main/src/app/api/inngest/route.ts"
click node_trpc_router "https://github.com/shreyashxp095/n8nlocalone/blob/main/src/trpc/routers/_app.ts"
click node_feature_servers "https://github.com/shreyashxp095/n8nlocalone/blob/main/src/features/workflows/server/routers.ts"
click node_inngest_core "https://github.com/shreyashxp095/n8nlocalone/blob/main/src/inngest/functions.ts"
click node_channel_impls "https://github.com/shreyashxp095/n8nlocalone/blob/main/src/inngest/channels/slack.ts"
click node_db "https://github.com/shreyashxp095/n8nlocalone/blob/main/prisma/schema.prisma"
click node_db_client "https://github.com/shreyashxp095/n8nlocalone/blob/main/src/lib/db.ts"
click node_security "https://github.com/shreyashxp095/n8nlocalone/blob/main/src/lib/auth.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_auth_ui,node_dashboard_shell,node_workflow_list,node_workflow_editor,node_react_flow_ui,node_credentials_ui,node_executions_ui,node_trigger_nodes,node_action_nodes toneBlue
class node_api_auth,node_api_trpc,node_api_webhooks,node_api_inngest,node_trpc_router,node_feature_servers toneAmber
class node_inngest_core,node_channel_impls toneMint
class node_db,node_db_client,node_security toneRose
```

## Components

### Browser UI

Auth screens, dashboard layouts, and feature modules rendered in the client/browser.

- [Auth UI](https://github.com/shreyashxp095/n8nlocalone/blob/main/src/features/auth/components/auth-layout.tsx): feature · Sign-in and sign-up screens and shared auth layout. · `src/features/auth/components/auth-layout.tsx`
- [Dashboard](https://github.com/shreyashxp095/n8nlocalone/blob/main/src/app/(dashboard)/layout.tsx): layout · Main application shell and dashboard chrome. · `src/app/(dashboard)/layout.tsx`
- [Workflows](https://github.com/shreyashxp095/n8nlocalone/blob/main/src/features/workflows/components/workflows.tsx): feature · Workflow listing and metadata browsing. · `src/features/workflows/components/workflows.tsx`
- [Editor](https://github.com/shreyashxp095/n8nlocalone/blob/main/src/features/editor/components/editor.tsx): feature · Visual workflow editor and execution controls. · `src/features/editor/components/editor.tsx`
- [Flow Nodes](https://github.com/shreyashxp095/n8nlocalone/blob/main/src/components/react-flow/base-node.tsx): component set · Reusable React Flow node primitives and workflow node chrome. · `src/components/react-flow/base-node.tsx`
- [Credentials](https://github.com/shreyashxp095/n8nlocalone/blob/main/src/features/credentials/components/credentials.tsx): feature · Credential management screens and creation flow. · `src/features/credentials/components/credentials.tsx`
- [Executions](https://github.com/shreyashxp095/n8nlocalone/blob/main/src/features/executions/components/executions.tsx): feature · Execution history and execution detail views. · `src/features/executions/components/executions.tsx`
- [Triggers](https://github.com/shreyashxp095/n8nlocalone/blob/main/src/features/triggers/components/manual-trigger/node.tsx): domain nodes · Trigger node implementations for manual, Google Form, and Stripe events. · `src/features/triggers/components/manual-trigger/node.tsx`
- [Actions](https://github.com/shreyashxp095/n8nlocalone/blob/main/src/features/executions/components/slack/node.tsx): domain nodes · Action/execution nodes for Slack, Discord, OpenAI, Gemini, Groq, and HTTP requests. · `src/features/executions/components/slack/node.tsx`

### Next.js API

Route handlers and typed server entrypoints exposed by the Next.js app.

- [Auth API](https://github.com/shreyashxp095/n8nlocalone/blob/main/src/app/api/auth/[...all]/route.ts): route handler · Authentication route entrypoint. · `src/app/api/auth/[...all]/route.ts`
- [tRPC API](https://github.com/shreyashxp095/n8nlocalone/blob/main/src/app/api/trpc/[trpc]/route.ts): route handler · Typed client/server data access endpoint. · `src/app/api/trpc/[trpc]/route.ts`
- [Webhooks](https://github.com/shreyashxp095/n8nlocalone/blob/main/src/app/api/webhooks/google-form/route.ts): route handlers · External event ingestion for Google Form and Stripe. · `src/app/api/webhooks/google-form/route.ts`
- [Inngest API](https://github.com/shreyashxp095/n8nlocalone/blob/main/src/app/api/inngest/route.ts): route handler · Background worker and event gateway route. · `src/app/api/inngest/route.ts`
- [App RPC](https://github.com/shreyashxp095/n8nlocalone/blob/main/src/trpc/routers/_app.ts): server layer · Shared app router and server-side typed queries. · `src/trpc/routers/_app.ts`
- [Feature Servers](https://github.com/shreyashxp095/n8nlocalone/blob/main/src/features/workflows/server/routers.ts): server layer · Per-feature routers, prefetchers, and parameter loaders. · `src/features/workflows/server/routers.ts`

### Execution Runtime

Background workflow processing and integration-specific execution channels.

- [Inngest Core](https://github.com/shreyashxp095/n8nlocalone/blob/main/src/inngest/functions.ts): runtime · Background execution client, functions, and utilities. · `src/inngest/functions.ts`
- [Channels](https://github.com/shreyashxp095/n8nlocalone/blob/main/src/inngest/channels/slack.ts): runtime adapters · Integration-specific trigger and action channel implementations. · `src/inngest/channels/slack.ts`

### Persistence

Database schema and server-side access layers for workflows, credentials, and executions.

- [Database](https://github.com/shreyashxp095/n8nlocalone/blob/main/prisma/schema.prisma): Prisma schema · Prisma-backed persistence for auth, workflows, credentials, and executions. · `prisma/schema.prisma`
- [DB Client](https://github.com/shreyashxp095/n8nlocalone/blob/main/src/lib/db.ts): lib · Shared database access helper. · `src/lib/db.ts`
- [Security](https://github.com/shreyashxp095/n8nlocalone/blob/main/src/lib/auth.ts): lib · Authentication, encryption, and subscription/billing helpers. · `src/lib/auth.ts`

## Connections

- Auth UI → Auth API: sign in/up · Auth forms submit to the authentication route.
- Dashboard → Workflows: hosts · Dashboard shell contains the workflow browsing area.
- Dashboard → Editor: hosts · Dashboard shell contains the workflow editor area.
- Dashboard → Credentials: hosts · Dashboard shell contains credential management.
- Dashboard → Executions: hosts · Dashboard shell contains execution history screens.
- Editor → Flow Nodes: renders · The editor composes reusable React Flow node primitives.
- Editor → Triggers: adds triggers · Editor places trigger nodes into the workflow graph.
- Editor → Actions: adds actions · Editor places downstream action nodes into the workflow graph.
- Workflows → tRPC API: loads data · Workflow list uses typed app queries.
- Credentials → tRPC API: loads data · Credential screens use typed app queries.
- Executions → tRPC API: loads data · Execution views use typed app queries.
- Editor → tRPC API: persists edits · Editor reads and writes workflow state through typed queries.
- tRPC API → App RPC: dispatches to · Route handler forwards calls into the app router.
- App RPC → Feature Servers: delegates · Feature-specific routers and loaders provide domain data.
- Feature Servers → DB Client: queries · Server helpers use the shared DB client.
- DB Client → Database: reads/writes · Database helper accesses Prisma persistence.
- Webhooks → Inngest Core: enqueues events · Webhook handlers hand off external events to the execution runtime.
- Inngest API → Inngest Core: serves · Inngest route exposes the background function runtime.
- Inngest Core → Channels: runs · Background functions invoke integration channels.
- Channels → DB Client: state access · Executors and channels read/write shared workflow state.
- Security → Auth API: protects · Auth and billing helpers support the authentication boundary.
- Security → DB Client: secures data · Security helpers support protected data access and encryption.
- Auth API → DB Client: accounts · Authentication state is backed by the database.
- App RPC → Security: uses · Typed server layer depends on auth and subscription helpers.
- Inngest Core → DB Client: stores runs · Background execution persists run state and results.
