# aavoraa/wewin architecture

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

- Interactive diagram: https://gitdiagram.com/aavoraa/wewin
- Repository: https://github.com/aavoraa/wewin

## Overview

This is a garment-manufacturing ERP: users manage orders and production, track materials and jobwork, then handle export and accounts documents. The API exposes permission-checked workflows and persists transactional business state; the web app provides operational screens. The tree shows broad product areas, but the README is empty and source excerpts are selective. Edges below are limited to relationships visible in excerpts or the SOURCE INDEX, so several important product areas appear without asserted connections.

Main entry points: [`apps/api/src/modules/accounts/bills.service.ts`](https://github.com/aavoraa/wewin/blob/main/apps/api/src/modules/accounts/bills.service.ts) (Vendor bills), [`apps/api/src/core/db.ts`](https://github.com/aavoraa/wewin/blob/main/apps/api/src/core/db.ts) (Transaction layer), [`apps/api/src/core/auth/auth.middleware.ts`](https://github.com/aavoraa/wewin/blob/main/apps/api/src/core/auth/auth.middleware.ts) (Authentication), [`apps/api/src/core/http.ts`](https://github.com/aavoraa/wewin/blob/main/apps/api/src/core/http.ts) (HTTP handling)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_webapp["Web screens"]
  node_scanreview["Scan review<br/>[ScanReviewPage.tsx]"]
end

subgraph group_ops["Factory operations"]
  node_orders["Orders"]
  node_production["Production floor"]
  node_panels["Panel documents<br/>[panels.service.ts]"]
  node_jobwork["Jobwork<br/>[jobwork.service.ts]"]
  node_stock["Stock control"]
  node_quality["Quality control"]
  node_purchase["Purchasing"]
end

subgraph group_finance["Commercial workflows"]
  node_export["Export documents"]
  node_accounts["Accounts<br/>[accounts.routes.ts]"]
  node_bills["Vendor bills<br/>[bills.service.ts]"]
  node_reports["Reports"]
  node_scans["Invoice scans"]
end

subgraph group_platform["API platform"]
  node_masters["Business masters<br/>[masters.service.ts]"]
  node_auth["Authentication<br/>[auth.middleware.ts]"]
  node_http["HTTP handling<br/>[http.ts]"]
  node_documents["Document routing<br/>[doc-routes.ts]"]
  node_settings["Settings"]
  node_dbtx["Transaction layer<br/>[db.ts]"]
  node_database[("Database<br/>[index.ts]")]
  node_audit["Audit service<br/>[audit.service.ts]"]
  node_numbering["Document numbering"]
  node_excel["Spreadsheet export<br/>[excel.ts]"]
  node_apierrors["API errors<br/>[app-error.ts]"]
end

node_operator(("ERP user"))

node_operator -.->|"uses"| node_webapp
node_operator -.->|"reviews scans"| node_scanreview
node_accounts -->|"routes calls"| node_bills
node_bills -->|"runs transactions"| node_dbtx
node_bills -->|"reads masters"| node_masters
node_bills -->|"checks jobwork"| node_jobwork
node_bills -->|"checks panels"| node_panels
node_bills -->|"records audit"| node_audit
node_panels -->|"uses transactions"| node_dbtx
node_auth -->|"loads switches"| node_settings
node_auth -.->|"reads access data"| node_dbtx
node_http -->|"builds exports"| node_excel
node_http -->|"raises errors"| node_apierrors
node_dbtx -->|"uses Prisma client"| node_database

click node_webapp "https://github.com/aavoraa/wewin/tree/main/apps/web/src"
click node_scanreview "https://github.com/aavoraa/wewin/blob/main/apps/web/src/features/scans/ScanReviewPage.tsx"
click node_orders "https://github.com/aavoraa/wewin/tree/main/apps/api/src/modules/orders"
click node_production "https://github.com/aavoraa/wewin/tree/main/apps/api/src/modules/cutting"
click node_panels "https://github.com/aavoraa/wewin/blob/main/apps/api/src/modules/panels/panels.service.ts"
click node_jobwork "https://github.com/aavoraa/wewin/blob/main/apps/api/src/modules/jobwork/jobwork.service.ts"
click node_stock "https://github.com/aavoraa/wewin/tree/main/apps/api/src/modules/stock"
click node_quality "https://github.com/aavoraa/wewin/tree/main/apps/api/src/modules/quality"
click node_purchase "https://github.com/aavoraa/wewin/tree/main/apps/api/src/modules/purchase"
click node_export "https://github.com/aavoraa/wewin/tree/main/apps/api/src/modules/export"
click node_accounts "https://github.com/aavoraa/wewin/blob/main/apps/api/src/modules/accounts/accounts.routes.ts"
click node_bills "https://github.com/aavoraa/wewin/blob/main/apps/api/src/modules/accounts/bills.service.ts"
click node_reports "https://github.com/aavoraa/wewin/tree/main/apps/api/src/modules/reports"
click node_scans "https://github.com/aavoraa/wewin/tree/main/apps/api/src/modules/scans"
click node_masters "https://github.com/aavoraa/wewin/blob/main/apps/api/src/modules/masters/masters.service.ts"
click node_auth "https://github.com/aavoraa/wewin/blob/main/apps/api/src/core/auth/auth.middleware.ts"
click node_http "https://github.com/aavoraa/wewin/blob/main/apps/api/src/core/http.ts"
click node_documents "https://github.com/aavoraa/wewin/blob/main/apps/api/src/core/doc-routes.ts"
click node_settings "https://github.com/aavoraa/wewin/blob/main/apps/api/src/core/settings/settings.service.ts"
click node_dbtx "https://github.com/aavoraa/wewin/blob/main/apps/api/src/core/db.ts"
click node_database "https://github.com/aavoraa/wewin/blob/main/packages/db/src/index.ts"
click node_audit "https://github.com/aavoraa/wewin/blob/main/apps/api/src/core/audit/audit.service.ts"
click node_numbering "https://github.com/aavoraa/wewin/blob/main/apps/api/src/core/numbering/numbering.service.ts"
click node_excel "https://github.com/aavoraa/wewin/blob/main/apps/api/src/core/excel.ts"
click node_apierrors "https://github.com/aavoraa/wewin/blob/main/apps/api/src/core/errors/app-error.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_webapp,node_scanreview,node_operator toneBlue
class node_orders,node_production,node_panels,node_jobwork,node_stock,node_quality,node_purchase toneAmber
class node_export,node_accounts,node_bills,node_reports,node_scans toneMint
class node_masters,node_auth,node_http,node_documents,node_settings,node_dbtx,node_database,node_audit,node_numbering,node_excel,node_apierrors toneRose
```

## Components

### Web application

- [Web screens](https://github.com/aavoraa/wewin/tree/main/apps/web/src): `apps/web/src`
- [Scan review](https://github.com/aavoraa/wewin/blob/main/apps/web/src/features/scans/ScanReviewPage.tsx): `apps/web/src/features/scans/ScanReviewPage.tsx`

### Factory operations

- [Orders](https://github.com/aavoraa/wewin/tree/main/apps/api/src/modules/orders): `apps/api/src/modules/orders`
- [Production floor](https://github.com/aavoraa/wewin/tree/main/apps/api/src/modules/cutting): `apps/api/src/modules/cutting`
- [Panel documents](https://github.com/aavoraa/wewin/blob/main/apps/api/src/modules/panels/panels.service.ts): `apps/api/src/modules/panels/panels.service.ts`
- [Jobwork](https://github.com/aavoraa/wewin/blob/main/apps/api/src/modules/jobwork/jobwork.service.ts): `apps/api/src/modules/jobwork/jobwork.service.ts`
- [Stock control](https://github.com/aavoraa/wewin/tree/main/apps/api/src/modules/stock): `apps/api/src/modules/stock`
- [Quality control](https://github.com/aavoraa/wewin/tree/main/apps/api/src/modules/quality): `apps/api/src/modules/quality`
- [Purchasing](https://github.com/aavoraa/wewin/tree/main/apps/api/src/modules/purchase): `apps/api/src/modules/purchase`

### Commercial workflows

- [Export documents](https://github.com/aavoraa/wewin/tree/main/apps/api/src/modules/export): `apps/api/src/modules/export`
- [Accounts](https://github.com/aavoraa/wewin/blob/main/apps/api/src/modules/accounts/accounts.routes.ts): `apps/api/src/modules/accounts/accounts.routes.ts`
- [Vendor bills](https://github.com/aavoraa/wewin/blob/main/apps/api/src/modules/accounts/bills.service.ts): `apps/api/src/modules/accounts/bills.service.ts`
- [Reports](https://github.com/aavoraa/wewin/tree/main/apps/api/src/modules/reports): `apps/api/src/modules/reports`
- [Invoice scans](https://github.com/aavoraa/wewin/tree/main/apps/api/src/modules/scans): `apps/api/src/modules/scans`

### API platform

- [Business masters](https://github.com/aavoraa/wewin/blob/main/apps/api/src/modules/masters/masters.service.ts): `apps/api/src/modules/masters/masters.service.ts`
- [Authentication](https://github.com/aavoraa/wewin/blob/main/apps/api/src/core/auth/auth.middleware.ts): `apps/api/src/core/auth/auth.middleware.ts`
- [HTTP handling](https://github.com/aavoraa/wewin/blob/main/apps/api/src/core/http.ts): `apps/api/src/core/http.ts`
- [Document routing](https://github.com/aavoraa/wewin/blob/main/apps/api/src/core/doc-routes.ts): `apps/api/src/core/doc-routes.ts`
- [Settings](https://github.com/aavoraa/wewin/blob/main/apps/api/src/core/settings/settings.service.ts): `apps/api/src/core/settings/settings.service.ts`
- [Transaction layer](https://github.com/aavoraa/wewin/blob/main/apps/api/src/core/db.ts): `apps/api/src/core/db.ts`
- [Database](https://github.com/aavoraa/wewin/blob/main/packages/db/src/index.ts): `packages/db/src/index.ts`
- [Audit service](https://github.com/aavoraa/wewin/blob/main/apps/api/src/core/audit/audit.service.ts): `apps/api/src/core/audit/audit.service.ts`
- [Document numbering](https://github.com/aavoraa/wewin/blob/main/apps/api/src/core/numbering/numbering.service.ts): `apps/api/src/core/numbering/numbering.service.ts`
- [Spreadsheet export](https://github.com/aavoraa/wewin/blob/main/apps/api/src/core/excel.ts): `apps/api/src/core/excel.ts`
- [API errors](https://github.com/aavoraa/wewin/blob/main/apps/api/src/core/errors/app-error.ts): `apps/api/src/core/errors/app-error.ts`

### Other components

- **ERP user**

## Connections

- ERP user → Web screens: uses
- ERP user → Scan review: reviews scans
- Accounts → Vendor bills: routes calls (evidence: `apps/api/src/modules/accounts/accounts.routes.ts`)
- Vendor bills → Transaction layer: runs transactions (evidence: `apps/api/src/modules/accounts/bills.service.ts`)
- Vendor bills → Business masters: reads masters (evidence: `apps/api/src/modules/accounts/bills.service.ts`)
- Vendor bills → Jobwork: checks jobwork (evidence: `apps/api/src/modules/accounts/bills.service.ts`)
- Vendor bills → Panel documents: checks panels (evidence: `apps/api/src/modules/accounts/bills.service.ts`)
- Vendor bills → Audit service: records audit (evidence: `apps/api/src/modules/accounts/bills.service.ts`)
- Panel documents → Transaction layer: uses transactions
- Authentication → Settings: loads switches (evidence: `apps/api/src/core/auth/auth.middleware.ts`)
- Authentication → Transaction layer: reads access data
- HTTP handling → Spreadsheet export: builds exports (evidence: `apps/api/src/core/http.ts`)
- HTTP handling → API errors: raises errors (evidence: `apps/api/src/core/http.ts`)
- Transaction layer → Database: uses Prisma client (evidence: `apps/api/src/core/db.ts`)
