# rey1332/etnav2 architecture

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

- Interactive diagram: https://gitdiagram.com/rey1332/etnav2
- Repository: https://github.com/rey1332/etnav2

## Overview

BettyWhite is a web and Electron ERP platform with operational business records, workspace access controls, workflow automation, reporting, and standalone statistical analysis tools. The principal workflow is a signed-in user working in ERP screens, which call server APIs to read or change scoped business data; analytics and workflow features extend that flow. The graph also shows authentication and major integrations. The README is empty, and sampled source is incomplete, so links for unsampled feature internals are omitted rather than inferred.

Main entry points: [`src/app/erp`](https://github.com/rey1332/etnav2/tree/main/src/app/erp) (ERP screens), [`src/server/currency/service.ts`](https://github.com/rey1332/etnav2/blob/main/src/server/currency/service.ts) (Currency service), [`src/app/api/erp/workflows`](https://github.com/rey1332/etnav2/tree/main/src/app/api/erp/workflows) (Workflow API), [`src/app/api/erp/workspace/route.ts`](https://github.com/rey1332/etnav2/blob/main/src/app/api/erp/workspace/route.ts) (Workspace access)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_erp["ERP operations"]
  node_erpui["ERP screens"]
  node_workspace["Workspace access<br/>[route.ts]"]
  node_businessapi["Business data API<br/>[route.ts]"]
  node_erpservice["ERP service layer<br/>[erpService.ts]"]
  node_export["Data export<br/>[route.ts]"]
  node_currency["Currency service<br/>[service.ts]"]
  node_currencyapi["Currency API<br/>[route.ts]"]
end

subgraph group_workflow["Workflow automation"]
  node_workflowui["Workflow editor"]
  node_workflowclient["Workflow API client<br/>[storage.ts]"]
  node_workflowroutes["Workflow API"]
  node_workflowruntime["Workflow runtime"]
end

subgraph group_analytics["Analytics and statistics"]
  node_analyticsui["ERP reports<br/>[page.tsx]"]
  node_analyticsapi["Analytics query API<br/>[route.ts]"]
  node_analyticsquery["Query and catalog<br/>[query.ts]"]
  node_statsui["Statistical tools"]
  node_regressionui["Regression analysis"]
  node_distributionui["Distribution analysis"]
end

subgraph group_platform["Access and platform"]
  node_authui["Sign-in screens<br/>[page.tsx]"]
  node_authapi["Authentication API<br/>[route.ts]"]
  node_authservice["Authentication service<br/>[service.ts]"]
  node_consoleui["In-app console<br/>[ConsoleHost.tsx]"]
  node_consoleapi["Console API<br/>[route.ts]"]
  node_aiapi["AI generation API<br/>[route.ts]"]
end

node_user(("ERP user"))
node_rateprovider["Exchange-rate provider"]
node_database[("ERP database")]
node_openai["OpenAI service"]

node_user -->|"uses"| node_erpui
node_user -->|"signs in"| node_authui
node_erpui -->|"requests data"| node_erpservice
node_erpservice -->|"calls"| node_businessapi
node_businessapi -->|"executes queries"| node_database
node_erpui -->|"manages access"| node_workspace
node_workspace -->|"runs RPCs"| node_database
node_erpui -->|"requests export"| node_export
node_export -->|"reads records"| node_database
node_currencyapi -->|"dispatches actions"| node_currency
node_currency -->|"reads and writes"| node_database
node_currency -.->|"fetches rates"| node_rateprovider
node_user -->|"builds workflows"| node_workflowui
node_workflowui -->|"uses"| node_workflowclient
node_workflowclient -->|"calls endpoints"| node_workflowroutes
node_workflowroutes -->|"reads and writes"| node_database
node_workflowroutes -->|"uses runtime"| node_workflowruntime
node_user -->|"requests reports"| node_analyticsui
node_analyticsui -->|"queries"| node_analyticsapi
node_analyticsapi -->|"validates and shapes"| node_analyticsquery
node_analyticsquery -->|"describes data queries"| node_database
node_user -->|"analyzes data"| node_statsui
node_user -->|"analyzes data"| node_regressionui
node_user -->|"analyzes data"| node_distributionui
node_authapi -->|"dispatches auth actions"| node_authservice
node_authservice -->|"uses auth store"| node_database
node_user -->|"opens console"| node_consoleui
node_consoleui -->|"sends commands"| node_consoleapi
node_consoleapi -->|"runs commands"| node_database
node_user -->|"requests generation"| node_aiapi
node_aiapi -->|"sends prompt"| node_openai

click node_erpui "https://github.com/rey1332/etnav2/tree/main/src/app/erp"
click node_workspace "https://github.com/rey1332/etnav2/blob/main/src/app/api/erp/workspace/route.ts"
click node_businessapi "https://github.com/rey1332/etnav2/blob/main/src/app/api/data/route.ts"
click node_erpservice "https://github.com/rey1332/etnav2/blob/main/src/app/erp/lib/erpService.ts"
click node_export "https://github.com/rey1332/etnav2/blob/main/src/app/api/erp/export/route.ts"
click node_currency "https://github.com/rey1332/etnav2/blob/main/src/server/currency/service.ts"
click node_currencyapi "https://github.com/rey1332/etnav2/blob/main/src/app/api/erp/currency/route.ts"
click node_workflowui "https://github.com/rey1332/etnav2/tree/main/src/app/erp/workflows"
click node_workflowclient "https://github.com/rey1332/etnav2/blob/main/src/lib/workflow/storage.ts"
click node_workflowroutes "https://github.com/rey1332/etnav2/tree/main/src/app/api/erp/workflows"
click node_workflowruntime "https://github.com/rey1332/etnav2/tree/main/src/lib/workflow"
click node_analyticsui "https://github.com/rey1332/etnav2/blob/main/src/app/erp/reports/page.tsx"
click node_analyticsapi "https://github.com/rey1332/etnav2/blob/main/src/app/api/erp/analytics/query/route.ts"
click node_analyticsquery "https://github.com/rey1332/etnav2/blob/main/src/lib/analytics/query.ts"
click node_statsui "https://github.com/rey1332/etnav2/tree/main/src/app/statistics"
click node_regressionui "https://github.com/rey1332/etnav2/tree/main/src/app/regression"
click node_distributionui "https://github.com/rey1332/etnav2/tree/main/src/app/distribution"
click node_authui "https://github.com/rey1332/etnav2/blob/main/src/app/login/page.tsx"
click node_authapi "https://github.com/rey1332/etnav2/blob/main/src/app/api/auth/%5Baction%5D/route.ts"
click node_authservice "https://github.com/rey1332/etnav2/blob/main/src/server/auth/service.ts"
click node_consoleui "https://github.com/rey1332/etnav2/blob/main/src/components/console/ConsoleHost.tsx"
click node_consoleapi "https://github.com/rey1332/etnav2/blob/main/src/app/api/console/route.ts"
click node_aiapi "https://github.com/rey1332/etnav2/blob/main/src/app/api/ai/generate/route.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_erpui,node_workspace,node_businessapi,node_erpservice,node_export,node_currency,node_currencyapi,node_user toneBlue
class node_workflowui,node_workflowclient,node_workflowroutes,node_workflowruntime,node_database toneAmber
class node_analyticsui,node_analyticsapi,node_analyticsquery,node_statsui,node_regressionui,node_distributionui toneMint
class node_authui,node_authapi,node_authservice,node_consoleui,node_consoleapi,node_aiapi toneRose
class node_rateprovider,node_openai toneIndigo
```

## Components

### ERP operations

- [ERP screens](https://github.com/rey1332/etnav2/tree/main/src/app/erp): `src/app/erp`
- [Workspace access](https://github.com/rey1332/etnav2/blob/main/src/app/api/erp/workspace/route.ts): `src/app/api/erp/workspace/route.ts`
- [Business data API](https://github.com/rey1332/etnav2/blob/main/src/app/api/data/route.ts): `src/app/api/data/route.ts`
- [ERP service layer](https://github.com/rey1332/etnav2/blob/main/src/app/erp/lib/erpService.ts): `src/app/erp/lib/erpService.ts`
- [Data export](https://github.com/rey1332/etnav2/blob/main/src/app/api/erp/export/route.ts): `src/app/api/erp/export/route.ts`
- [Currency service](https://github.com/rey1332/etnav2/blob/main/src/server/currency/service.ts): `src/server/currency/service.ts`
- [Currency API](https://github.com/rey1332/etnav2/blob/main/src/app/api/erp/currency/route.ts): `src/app/api/erp/currency/route.ts`

### Workflow automation

- [Workflow editor](https://github.com/rey1332/etnav2/tree/main/src/app/erp/workflows): `src/app/erp/workflows`
- [Workflow API client](https://github.com/rey1332/etnav2/blob/main/src/lib/workflow/storage.ts): `src/lib/workflow/storage.ts`
- [Workflow API](https://github.com/rey1332/etnav2/tree/main/src/app/api/erp/workflows): `src/app/api/erp/workflows`
- [Workflow runtime](https://github.com/rey1332/etnav2/tree/main/src/lib/workflow): `src/lib/workflow`

### Analytics and statistics

- [ERP reports](https://github.com/rey1332/etnav2/blob/main/src/app/erp/reports/page.tsx): `src/app/erp/reports/page.tsx`
- [Analytics query API](https://github.com/rey1332/etnav2/blob/main/src/app/api/erp/analytics/query/route.ts): `src/app/api/erp/analytics/query/route.ts`
- [Query and catalog](https://github.com/rey1332/etnav2/blob/main/src/lib/analytics/query.ts): `src/lib/analytics/query.ts`
- [Statistical tools](https://github.com/rey1332/etnav2/tree/main/src/app/statistics): `src/app/statistics`
- [Regression analysis](https://github.com/rey1332/etnav2/tree/main/src/app/regression): `src/app/regression`
- [Distribution analysis](https://github.com/rey1332/etnav2/tree/main/src/app/distribution): `src/app/distribution`

### Access and platform

- [Sign-in screens](https://github.com/rey1332/etnav2/blob/main/src/app/login/page.tsx): `src/app/login/page.tsx`
- [Authentication API](https://github.com/rey1332/etnav2/blob/main/src/app/api/auth/%5Baction%5D/route.ts): `src/app/api/auth/[action]/route.ts`
- [Authentication service](https://github.com/rey1332/etnav2/blob/main/src/server/auth/service.ts): `src/server/auth/service.ts`
- [In-app console](https://github.com/rey1332/etnav2/blob/main/src/components/console/ConsoleHost.tsx): `src/components/console/ConsoleHost.tsx`
- [Console API](https://github.com/rey1332/etnav2/blob/main/src/app/api/console/route.ts): `src/app/api/console/route.ts`
- [AI generation API](https://github.com/rey1332/etnav2/blob/main/src/app/api/ai/generate/route.ts): `src/app/api/ai/generate/route.ts`

### Other components

- **ERP user**
- **Exchange-rate provider**
- **ERP database**
- **OpenAI service**

## Connections

- ERP user → ERP screens: uses
- ERP user → Sign-in screens: signs in
- ERP screens → ERP service layer: requests data
- ERP service layer → Business data API: calls
- Business data API → ERP database: executes queries
- ERP screens → Workspace access: manages access
- Workspace access → ERP database: runs RPCs
- ERP screens → Data export: requests export
- Data export → ERP database: reads records
- Currency API → Currency service: dispatches actions
- Currency service → ERP database: reads and writes
- Currency service → Exchange-rate provider: fetches rates
- ERP user → Workflow editor: builds workflows
- Workflow editor → Workflow API client: uses
- Workflow API client → Workflow API: calls endpoints
- Workflow API → ERP database: reads and writes
- Workflow API → Workflow runtime: uses runtime
- ERP user → ERP reports: requests reports
- ERP reports → Analytics query API: queries
- Analytics query API → Query and catalog: validates and shapes
- Query and catalog → ERP database: describes data queries
- ERP user → Statistical tools: analyzes data
- ERP user → Regression analysis: analyzes data
- ERP user → Distribution analysis: analyzes data
- Authentication API → Authentication service: dispatches auth actions
- Authentication service → ERP database: uses auth store
- ERP user → In-app console: opens console
- In-app console → Console API: sends commands
- Console API → ERP database: runs commands
- ERP user → AI generation API: requests generation
- AI generation API → OpenAI service: sends prompt
