How shreyashxp095/n8nlocalone works
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: db.ts DB Client · editor.tsx Editor · route.ts tRPC API · layout.tsx Dashboard
Components 20
Browser UI
Auth screens, dashboard layouts, and feature modules rendered in the client/browser.
- Auth UI · Sign-in and sign-up screens and shared auth layout.
src/features/auth/components/auth-layout.tsx - Dashboard · Main application shell and dashboard chrome.
src/app/(dashboard)/layout.tsx - Workflows · Workflow listing and metadata browsing.
src/features/workflows/components/workflows.tsx - Editor · Visual workflow editor and execution controls.
src/features/editor/components/editor.tsx - Flow Nodes · Reusable React Flow node primitives and workflow node chrome.
src/components/react-flow/base-node.tsx - Credentials · Credential management screens and creation flow.
src/features/credentials/components/credentials.tsx - Executions · Execution history and execution detail views.
src/features/executions/components/executions.tsx - Triggers · Trigger node implementations for manual, Google Form, and Stripe events.
src/features/triggers/components/manual-trigger/node.tsx - Actions · 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 · Authentication route entrypoint.
src/app/api/auth/[...all]/route.ts - tRPC API · Typed client/server data access endpoint.
src/app/api/trpc/[trpc]/route.ts - Webhooks · External event ingestion for Google Form and Stripe.
src/app/api/webhooks/google-form/route.ts - Inngest API · Background worker and event gateway route.
src/app/api/inngest/route.ts - App RPC · Shared app router and server-side typed queries.
src/trpc/routers/_app.ts - Feature Servers · 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 · Background execution client, functions, and utilities.
src/inngest/functions.ts - Channels · 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.
Connections 25
- 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.