# spibyc/plm architecture

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

- Interactive diagram: https://gitdiagram.com/spibyc/plm
- Repository: https://github.com/spibyc/plm
- Video tour (about a minute): https://gitdiagram.com/spibyc/plm/video

## Overview

PLM is a self-hosted product lifecycle, engineering, inventory, supplier, and controlled-document database. The main workflow spans part and revision management, purchasing and receipt, inventory lots, released BOMs, production builds, and serial traceability; controlled documents form a parallel revision-and-approval workflow. The graph includes the browser/API boundary, domain services, persistence, and the documented file store. Some backend routes and services were not sampled, so their internal links are omitted or marked unverified rather than inferred.

Main entry points: [`backend/app/main.py`](https://github.com/spibyc/plm/blob/main/backend/app/main.py) (FastAPI application), [`frontend/src/lib/api.ts`](https://github.com/spibyc/plm/blob/main/frontend/src/lib/api.ts) (API client), [`backend/app/api/routes/inventory.py`](https://github.com/spibyc/plm/blob/main/backend/app/api/routes/inventory.py) (Inventory routes), [`backend/app/services/items.py`](https://github.com/spibyc/plm/blob/main/backend/app/services/items.py) (Items and revisions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_webapp["PLM browser app<br/>[main.tsx]"]
  node_authstate["Session state<br/>[auth.tsx]"]
  node_apiclient["API client<br/>[api.ts]"]
  node_partui["Parts and revisions<br/>[PartDetail.tsx]"]
  node_lotui["Lots and stock<br/>[Lots.tsx]"]
  node_traceui["Purchasing and genealogy<br/>[Traceability.tsx]"]
  node_documentui["Document register<br/>[Documents.tsx]"]
end

subgraph group_api["API and identity"]
  node_server["FastAPI application<br/>[main.py]"]
  node_authroutes["Authentication routes<br/>[auth.py]"]
  node_deps["Actor and permission checks<br/>[deps.py]"]
  node_itemroutes["Item routes<br/>[items.py]"]
  node_inventoryroutes["Inventory routes<br/>[inventory.py]"]
  node_traceroutes["Traceability routes<br/>[traceability.py]"]
  node_documentroutes["Document routes<br/>[documents.py]"]
  node_authservice["Authentication service<br/>[auth.py]"]
end

subgraph group_engineering["Engineering data"]
  node_itemservice["Items and revisions<br/>[items.py]"]
  node_itemmodels["Part data models<br/>[items.py]"]
  node_documentservice["Controlled documents<br/>[documents.py]"]
end

subgraph group_operations["Inventory and traceability"]
  node_inventoryservice["Inventory operations<br/>[inventory.py]"]
  node_locationservice["Locations<br/>[locations.py]"]
  node_traceabilityservice["Purchasing and production<br/>[traceability.py]"]
  node_tracemodels["Traceability models<br/>[traceability.py]"]
end

subgraph group_controls["Quality controls"]
  node_auditservice["Audit trail<br/>[audit.py]"]
  node_signatureservice["Electronic signatures<br/>[signatures.py]"]
  node_fileassets["Controlled file storage<br/>[files.py]"]
end

node_staff(("Staff or viewer"))
node_database[("PostgreSQL")]
node_filestore[("Content-addressed filestore")]

node_staff -->|"uses"| node_webapp
node_webapp -->|"provides session"| node_authstate
node_authstate -->|"calls"| node_apiclient
node_partui -->|"requests data"| node_apiclient
node_lotui -->|"requests data"| node_apiclient
node_traceui -->|"requests data"| node_apiclient
node_documentui -.->|"requests data"| node_apiclient
node_apiclient -->|"sends API requests"| node_server
node_server -->|"registers"| node_authroutes
node_server -->|"registers"| node_itemroutes
node_server -->|"registers"| node_inventoryroutes
node_server -->|"registers"| node_traceroutes
node_server -->|"registers"| node_documentroutes
node_authroutes -->|"delegates"| node_authservice
node_authroutes -->|"resolves actor"| node_deps
node_itemroutes -->|"delegates"| node_itemservice
node_inventoryroutes -->|"delegates"| node_inventoryservice
node_inventoryroutes -->|"uses locations"| node_locationservice
node_traceroutes -->|"delegates"| node_traceabilityservice
node_documentroutes -.->|"delegates"| node_documentservice
node_authservice -->|"records events"| node_auditservice
node_itemservice -->|"uses inventory"| node_inventoryservice
node_itemservice -->|"records changes"| node_auditservice
node_inventoryservice -->|"records changes"| node_auditservice
node_inventoryservice -->|"uses signatures"| node_signatureservice
node_itemservice -->|"uses signatures"| node_signatureservice
node_itemroutes -->|"uses file service"| node_fileassets
node_inventoryroutes -->|"uses file service"| node_fileassets
node_itemservice -->|"uses models"| node_itemmodels
node_traceabilityservice -.->|"uses models"| node_tracemodels
node_documentservice -.->|"persists records"| node_database
node_itemroutes -->|"reads and writes"| node_database
node_inventoryroutes -->|"reads and writes"| node_database
node_fileassets -.->|"stores files"| node_filestore
node_server -->|"uses PostgreSQL"| node_database
node_server -->|"uses filestore"| node_filestore

click node_webapp "https://github.com/spibyc/plm/blob/main/frontend/src/main.tsx"
click node_authstate "https://github.com/spibyc/plm/blob/main/frontend/src/lib/auth.tsx"
click node_apiclient "https://github.com/spibyc/plm/blob/main/frontend/src/lib/api.ts"
click node_partui "https://github.com/spibyc/plm/blob/main/frontend/src/pages/PartDetail.tsx"
click node_lotui "https://github.com/spibyc/plm/blob/main/frontend/src/pages/Lots.tsx"
click node_traceui "https://github.com/spibyc/plm/blob/main/frontend/src/pages/Traceability.tsx"
click node_documentui "https://github.com/spibyc/plm/blob/main/frontend/src/pages/Documents.tsx"
click node_server "https://github.com/spibyc/plm/blob/main/backend/app/main.py"
click node_authroutes "https://github.com/spibyc/plm/blob/main/backend/app/api/routes/auth.py"
click node_deps "https://github.com/spibyc/plm/blob/main/backend/app/api/deps.py"
click node_itemroutes "https://github.com/spibyc/plm/blob/main/backend/app/api/routes/items.py"
click node_inventoryroutes "https://github.com/spibyc/plm/blob/main/backend/app/api/routes/inventory.py"
click node_traceroutes "https://github.com/spibyc/plm/blob/main/backend/app/api/routes/traceability.py"
click node_documentroutes "https://github.com/spibyc/plm/blob/main/backend/app/api/routes/documents.py"
click node_authservice "https://github.com/spibyc/plm/blob/main/backend/app/services/auth.py"
click node_itemservice "https://github.com/spibyc/plm/blob/main/backend/app/services/items.py"
click node_itemmodels "https://github.com/spibyc/plm/blob/main/backend/app/models/items.py"
click node_documentservice "https://github.com/spibyc/plm/blob/main/backend/app/services/documents.py"
click node_inventoryservice "https://github.com/spibyc/plm/blob/main/backend/app/services/inventory.py"
click node_locationservice "https://github.com/spibyc/plm/blob/main/backend/app/services/locations.py"
click node_traceabilityservice "https://github.com/spibyc/plm/blob/main/backend/app/services/traceability.py"
click node_tracemodels "https://github.com/spibyc/plm/blob/main/backend/app/models/traceability.py"
click node_auditservice "https://github.com/spibyc/plm/blob/main/backend/app/services/audit.py"
click node_signatureservice "https://github.com/spibyc/plm/blob/main/backend/app/services/signatures.py"
click node_fileassets "https://github.com/spibyc/plm/blob/main/backend/app/services/files.py"

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_authstate,node_apiclient,node_partui,node_lotui,node_traceui,node_documentui,node_staff toneBlue
class node_server,node_authroutes,node_deps,node_itemroutes,node_inventoryroutes,node_traceroutes,node_documentroutes,node_authservice,node_database,node_filestore toneAmber
class node_itemservice,node_itemmodels,node_documentservice toneMint
class node_inventoryservice,node_locationservice,node_traceabilityservice,node_tracemodels toneRose
class node_auditservice,node_signatureservice,node_fileassets toneIndigo
```

## Components

### Web client

- [PLM browser app](https://github.com/spibyc/plm/blob/main/frontend/src/main.tsx): `frontend/src/main.tsx`
- [Session state](https://github.com/spibyc/plm/blob/main/frontend/src/lib/auth.tsx): `frontend/src/lib/auth.tsx`
- [API client](https://github.com/spibyc/plm/blob/main/frontend/src/lib/api.ts): `frontend/src/lib/api.ts`
- [Parts and revisions](https://github.com/spibyc/plm/blob/main/frontend/src/pages/PartDetail.tsx): `frontend/src/pages/PartDetail.tsx`
- [Lots and stock](https://github.com/spibyc/plm/blob/main/frontend/src/pages/Lots.tsx): `frontend/src/pages/Lots.tsx`
- [Purchasing and genealogy](https://github.com/spibyc/plm/blob/main/frontend/src/pages/Traceability.tsx): `frontend/src/pages/Traceability.tsx`
- [Document register](https://github.com/spibyc/plm/blob/main/frontend/src/pages/Documents.tsx): `frontend/src/pages/Documents.tsx`

### API and identity

- [FastAPI application](https://github.com/spibyc/plm/blob/main/backend/app/main.py): `backend/app/main.py`
- [Authentication routes](https://github.com/spibyc/plm/blob/main/backend/app/api/routes/auth.py): `backend/app/api/routes/auth.py`
- [Actor and permission checks](https://github.com/spibyc/plm/blob/main/backend/app/api/deps.py): `backend/app/api/deps.py`
- [Item routes](https://github.com/spibyc/plm/blob/main/backend/app/api/routes/items.py): `backend/app/api/routes/items.py`
- [Inventory routes](https://github.com/spibyc/plm/blob/main/backend/app/api/routes/inventory.py): `backend/app/api/routes/inventory.py`
- [Traceability routes](https://github.com/spibyc/plm/blob/main/backend/app/api/routes/traceability.py): `backend/app/api/routes/traceability.py`
- [Document routes](https://github.com/spibyc/plm/blob/main/backend/app/api/routes/documents.py): `backend/app/api/routes/documents.py`
- [Authentication service](https://github.com/spibyc/plm/blob/main/backend/app/services/auth.py): `backend/app/services/auth.py`

### Engineering data

- [Items and revisions](https://github.com/spibyc/plm/blob/main/backend/app/services/items.py): `backend/app/services/items.py`
- [Part data models](https://github.com/spibyc/plm/blob/main/backend/app/models/items.py): `backend/app/models/items.py`
- [Controlled documents](https://github.com/spibyc/plm/blob/main/backend/app/services/documents.py): `backend/app/services/documents.py`

### Inventory and traceability

- [Inventory operations](https://github.com/spibyc/plm/blob/main/backend/app/services/inventory.py): `backend/app/services/inventory.py`
- [Locations](https://github.com/spibyc/plm/blob/main/backend/app/services/locations.py): `backend/app/services/locations.py`
- [Purchasing and production](https://github.com/spibyc/plm/blob/main/backend/app/services/traceability.py): `backend/app/services/traceability.py`
- [Traceability models](https://github.com/spibyc/plm/blob/main/backend/app/models/traceability.py): `backend/app/models/traceability.py`

### Quality controls

- [Audit trail](https://github.com/spibyc/plm/blob/main/backend/app/services/audit.py): `backend/app/services/audit.py`
- [Electronic signatures](https://github.com/spibyc/plm/blob/main/backend/app/services/signatures.py): `backend/app/services/signatures.py`
- [Controlled file storage](https://github.com/spibyc/plm/blob/main/backend/app/services/files.py): `backend/app/services/files.py`

### Other components

- **Staff or viewer**
- **PostgreSQL**
- **Content-addressed filestore**

## Connections

- Staff or viewer → PLM browser app: uses (evidence: `README.md`)
- PLM browser app → Session state: provides session (evidence: `frontend/src/main.tsx`)
- Session state → API client: calls (evidence: `frontend/src/lib/auth.tsx`)
- Parts and revisions → API client: requests data (evidence: `frontend/src/pages/PartDetail.tsx`)
- Lots and stock → API client: requests data (evidence: `frontend/src/pages/Lots.tsx`)
- Purchasing and genealogy → API client: requests data (evidence: `frontend/src/pages/Traceability.tsx`)
- Document register → API client: requests data
- API client → FastAPI application: sends API requests (evidence: `README.md`)
- FastAPI application → Authentication routes: registers (evidence: `backend/app/main.py`)
- FastAPI application → Item routes: registers (evidence: `backend/app/main.py`)
- FastAPI application → Inventory routes: registers (evidence: `backend/app/main.py`)
- FastAPI application → Traceability routes: registers (evidence: `backend/app/main.py`)
- FastAPI application → Document routes: registers (evidence: `backend/app/main.py`)
- Authentication routes → Authentication service: delegates (evidence: `backend/app/api/routes/auth.py`)
- Authentication routes → Actor and permission checks: resolves actor (evidence: `backend/app/api/routes/auth.py`)
- Item routes → Items and revisions: delegates (evidence: `backend/app/api/routes/items.py`)
- Inventory routes → Inventory operations: delegates (evidence: `backend/app/api/routes/inventory.py`)
- Inventory routes → Locations: uses locations (evidence: `backend/app/api/routes/inventory.py`)
- Traceability routes → Purchasing and production: delegates (evidence: `backend/app/api/routes/traceability.py`)
- Document routes → Controlled documents: delegates
- Authentication service → Audit trail: records events (evidence: `backend/app/services/auth.py`)
- Items and revisions → Inventory operations: uses inventory (evidence: `backend/app/services/items.py`)
- Items and revisions → Audit trail: records changes (evidence: `backend/app/services/items.py`)
- Inventory operations → Audit trail: records changes (evidence: `backend/app/services/inventory.py`)
- Inventory operations → Electronic signatures: uses signatures (evidence: `backend/app/services/inventory.py`)
- Items and revisions → Electronic signatures: uses signatures (evidence: `backend/app/services/items.py`)
- Item routes → Controlled file storage: uses file service (evidence: `backend/app/api/routes/items.py`)
- Inventory routes → Controlled file storage: uses file service (evidence: `backend/app/api/routes/inventory.py`)
- Items and revisions → Part data models: uses models (evidence: `backend/app/services/items.py`)
- Purchasing and production → Traceability models: uses models
- Controlled documents → PostgreSQL: persists records
- Item routes → PostgreSQL: reads and writes (evidence: `backend/app/api/routes/items.py`)
- Inventory routes → PostgreSQL: reads and writes (evidence: `backend/app/api/routes/inventory.py`)
- Controlled file storage → Content-addressed filestore: stores files
- FastAPI application → PostgreSQL: uses PostgreSQL (evidence: `README.md`)
- FastAPI application → Content-addressed filestore: uses filestore (evidence: `README.md`)
