# rodrigotjf1-boop/regem architecture

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

- Interactive diagram: https://gitdiagram.com/rodrigotjf1-boop/regem
- Repository: https://github.com/rodrigotjf1-boop/regem

## Overview

Regem is a modular, multi-tenant restaurant operations and management platform. Store staff use operational screens for day-to-day work, while executives use cloud reporting and administration; the cloud API and each unit’s local node divide configuration and operational ownership. The graph preserves the documented offline-first sync model and major product areas visible in the repository. Edges are limited to relationships stated in the README or shown in excerpts; unsampled modules are represented by their existing directories, without inferred call chains.

Main entry points: [`backend/src/main.ts`](https://github.com/rodrigotjf1-boop/regem/blob/main/backend/src/main.ts) (Versioned API), [`backend/src/modules/atendimento/atendimento.controller.ts`](https://github.com/rodrigotjf1-boop/regem/blob/main/backend/src/modules/atendimento/atendimento.controller.ts) (Case endpoints), [`backend/src/auth/auth-user.ts`](https://github.com/rodrigotjf1-boop/regem/blob/main/backend/src/auth/auth-user.ts) (Request user context), [`backend/src/db/schema.ts`](https://github.com/rodrigotjf1-boop/regem/blob/main/backend/src/db/schema.ts) (PostgreSQL)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["User surfaces"]
  node_web["Web app<br/>[page.tsx]"]
  node_attend_app["Atendimento app<br/>[MainActivity.kt]"]
  node_delivery_app["Entregador app<br/>[MainActivity.kt]"]
end

subgraph group_platform["Platform foundation"]
  node_auth["Identity and RBAC<br/>[auth.service.ts]"]
  node_auth_context["Request user context<br/>[auth-user.ts]"]
  node_jwt_guard["JWT validation<br/>[jwt-auth.guard.ts]"]
  node_role_guard["Role authorization<br/>[roles.guard.ts]"]
  node_permission_guard["Permission authorization"]
  node_database[("PostgreSQL<br/>[schema.ts]")]
  node_audit["Audit trail"]
end

subgraph group_operations["Store operations"]
  node_menu["Menu and ordering"]
  node_delivery["Delivery operations"]
  node_service_cases["Customer service cases"]
  node_production["Kitchen production"]
  node_inventory["Inventory and waste<br/>[estoque.service.ts]"]
  node_people["Schedules and checklists<br/>[escala.service.ts]"]
  node_finance["Finance and fiscal"]
  node_attendance_controller["Case endpoints"]
  node_attendance_service["Case workflows"]
  node_arrival_service["Customer arrival<br/>[chegada.service.ts]"]
  node_production_service["Order production"]
end

subgraph group_cloud["Cloud and sync"]
  node_service_api["Versioned API<br/>[main.ts]"]
  node_local_node["Unit local node<br/>[sync-daemon.mjs]"]
  node_sync["Offline synchronization<br/>[sync-daemon.mjs]"]
  node_dashboard["Executive dashboard"]
  node_integrations["External API integrations"]
end

node_staff(("Store staff"))
node_executives(("President / C&amp;O"))

node_staff -->|"use operations"| node_web
node_executives -->|"view analytics"| node_dashboard
node_staff -->|"use support"| node_attend_app
node_staff -.->|"use delivery"| node_delivery_app
node_service_api -->|"uses PostgreSQL"| node_database
node_local_node -->|"stores unit data"| node_database
node_local_node -->|"runs sync"| node_sync
node_sync -->|"syncs with cloud"| node_service_api
node_service_api -->|"serves reporting"| node_dashboard
node_service_api -->|"hosts cloud API"| node_integrations
node_auth -->|"reads and writes"| node_database
node_jwt_guard -->|"populates request"| node_auth_context
node_role_guard -->|"checks role"| node_auth_context
node_permission_guard -->|"checks permissions"| node_auth_context
node_attendance_controller -->|"resolves cases"| node_attendance_service
node_attendance_controller -->|"queries arrival"| node_arrival_service
node_attendance_controller -->|"uses production"| node_production_service

click node_web "https://github.com/rodrigotjf1-boop/regem/blob/main/frontend/src/app/page.tsx"
click node_attend_app "https://github.com/rodrigotjf1-boop/regem/blob/main/app-atendimento/android/app/src/main/kotlin/com/dmsregem/regem_atendimento/MainActivity.kt"
click node_delivery_app "https://github.com/rodrigotjf1-boop/regem/blob/main/app-entregador/android/app/src/main/kotlin/com/dmsregem/regem_entregador/MainActivity.kt"
click node_auth "https://github.com/rodrigotjf1-boop/regem/blob/main/backend/src/auth/auth.service.ts"
click node_auth_context "https://github.com/rodrigotjf1-boop/regem/blob/main/backend/src/auth/auth-user.ts"
click node_jwt_guard "https://github.com/rodrigotjf1-boop/regem/blob/main/backend/src/auth/jwt-auth.guard.ts"
click node_role_guard "https://github.com/rodrigotjf1-boop/regem/blob/main/backend/src/auth/roles.guard.ts"
click node_permission_guard "https://github.com/rodrigotjf1-boop/regem/blob/main/backend/src/auth/permissoes.guard.ts"
click node_database "https://github.com/rodrigotjf1-boop/regem/blob/main/backend/src/db/schema.ts"
click node_audit "https://github.com/rodrigotjf1-boop/regem/blob/main/backend/src/modules/auditoria/auditoria.service.ts"
click node_service_api "https://github.com/rodrigotjf1-boop/regem/blob/main/backend/src/main.ts"
click node_local_node "https://github.com/rodrigotjf1-boop/regem/blob/main/backend/edge/sync-daemon.mjs"
click node_sync "https://github.com/rodrigotjf1-boop/regem/blob/main/backend/edge/sync-daemon.mjs"
click node_dashboard "https://github.com/rodrigotjf1-boop/regem/blob/main/backend/src/modules/dashboard/dashboard.service.ts"
click node_integrations "https://github.com/rodrigotjf1-boop/regem/blob/main/backend/src/modules/integracao-api/integracao-api.controller.ts"
click node_menu "https://github.com/rodrigotjf1-boop/regem/blob/main/backend/src/modules/cardapio/cardapio.controller.ts"
click node_delivery "https://github.com/rodrigotjf1-boop/regem/blob/main/backend/src/modules/delivery/delivery.controller.ts"
click node_service_cases "https://github.com/rodrigotjf1-boop/regem/blob/main/backend/src/modules/atendimento/atendimento.controller.ts"
click node_production "https://github.com/rodrigotjf1-boop/regem/blob/main/backend/src/modules/producao-pedido/producao-pedido.controller.ts"
click node_inventory "https://github.com/rodrigotjf1-boop/regem/blob/main/backend/src/modules/estoque/estoque.service.ts"
click node_people "https://github.com/rodrigotjf1-boop/regem/blob/main/backend/src/modules/escala/escala.service.ts"
click node_finance "https://github.com/rodrigotjf1-boop/regem/blob/main/backend/src/modules/financeiro/financeiro.service.ts"
click node_attendance_controller "https://github.com/rodrigotjf1-boop/regem/blob/main/backend/src/modules/atendimento/atendimento.controller.ts"
click node_attendance_service "https://github.com/rodrigotjf1-boop/regem/blob/main/backend/src/modules/atendimento/atendimento.service.ts"
click node_arrival_service "https://github.com/rodrigotjf1-boop/regem/blob/main/backend/src/modules/chegada/chegada.service.ts"
click node_production_service "https://github.com/rodrigotjf1-boop/regem/blob/main/backend/src/modules/producao-pedido/producao-pedido.service.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_web,node_attend_app,node_delivery_app toneBlue
class node_auth,node_auth_context,node_jwt_guard,node_role_guard,node_permission_guard,node_database,node_audit toneAmber
class node_menu,node_delivery,node_service_cases,node_production,node_inventory,node_people,node_finance,node_attendance_controller,node_attendance_service,node_arrival_service,node_production_service toneMint
class node_service_api,node_local_node,node_sync,node_dashboard,node_integrations toneRose
class node_staff,node_executives toneIndigo
```

## Components

### User surfaces

- [Web app](https://github.com/rodrigotjf1-boop/regem/blob/main/frontend/src/app/page.tsx): `frontend/src/app/page.tsx`
- [Atendimento app](https://github.com/rodrigotjf1-boop/regem/blob/main/app-atendimento/android/app/src/main/kotlin/com/dmsregem/regem_atendimento/MainActivity.kt): `app-atendimento/android/app/src/main/kotlin/com/dmsregem/regem_atendimento/MainActivity.kt`
- [Entregador app](https://github.com/rodrigotjf1-boop/regem/blob/main/app-entregador/android/app/src/main/kotlin/com/dmsregem/regem_entregador/MainActivity.kt): `app-entregador/android/app/src/main/kotlin/com/dmsregem/regem_entregador/MainActivity.kt`

### Platform foundation

- [Identity and RBAC](https://github.com/rodrigotjf1-boop/regem/blob/main/backend/src/auth/auth.service.ts): `backend/src/auth/auth.service.ts`
- [Request user context](https://github.com/rodrigotjf1-boop/regem/blob/main/backend/src/auth/auth-user.ts): `backend/src/auth/auth-user.ts`
- [JWT validation](https://github.com/rodrigotjf1-boop/regem/blob/main/backend/src/auth/jwt-auth.guard.ts): `backend/src/auth/jwt-auth.guard.ts`
- [Role authorization](https://github.com/rodrigotjf1-boop/regem/blob/main/backend/src/auth/roles.guard.ts): `backend/src/auth/roles.guard.ts`
- [Permission authorization](https://github.com/rodrigotjf1-boop/regem/blob/main/backend/src/auth/permissoes.guard.ts): `backend/src/auth/permissoes.guard.ts`
- [PostgreSQL](https://github.com/rodrigotjf1-boop/regem/blob/main/backend/src/db/schema.ts): `backend/src/db/schema.ts`
- [Audit trail](https://github.com/rodrigotjf1-boop/regem/blob/main/backend/src/modules/auditoria/auditoria.service.ts): `backend/src/modules/auditoria/auditoria.service.ts`

### Store operations

- [Menu and ordering](https://github.com/rodrigotjf1-boop/regem/blob/main/backend/src/modules/cardapio/cardapio.controller.ts): `backend/src/modules/cardapio/cardapio.controller.ts`
- [Delivery operations](https://github.com/rodrigotjf1-boop/regem/blob/main/backend/src/modules/delivery/delivery.controller.ts): `backend/src/modules/delivery/delivery.controller.ts`
- [Customer service cases](https://github.com/rodrigotjf1-boop/regem/blob/main/backend/src/modules/atendimento/atendimento.controller.ts): `backend/src/modules/atendimento/atendimento.controller.ts`
- [Kitchen production](https://github.com/rodrigotjf1-boop/regem/blob/main/backend/src/modules/producao-pedido/producao-pedido.controller.ts): `backend/src/modules/producao-pedido/producao-pedido.controller.ts`
- [Inventory and waste](https://github.com/rodrigotjf1-boop/regem/blob/main/backend/src/modules/estoque/estoque.service.ts): `backend/src/modules/estoque/estoque.service.ts`
- [Schedules and checklists](https://github.com/rodrigotjf1-boop/regem/blob/main/backend/src/modules/escala/escala.service.ts): `backend/src/modules/escala/escala.service.ts`
- [Finance and fiscal](https://github.com/rodrigotjf1-boop/regem/blob/main/backend/src/modules/financeiro/financeiro.service.ts): `backend/src/modules/financeiro/financeiro.service.ts`
- [Case endpoints](https://github.com/rodrigotjf1-boop/regem/blob/main/backend/src/modules/atendimento/atendimento.controller.ts): `backend/src/modules/atendimento/atendimento.controller.ts`
- [Case workflows](https://github.com/rodrigotjf1-boop/regem/blob/main/backend/src/modules/atendimento/atendimento.service.ts): `backend/src/modules/atendimento/atendimento.service.ts`
- [Customer arrival](https://github.com/rodrigotjf1-boop/regem/blob/main/backend/src/modules/chegada/chegada.service.ts): `backend/src/modules/chegada/chegada.service.ts`
- [Order production](https://github.com/rodrigotjf1-boop/regem/blob/main/backend/src/modules/producao-pedido/producao-pedido.service.ts): `backend/src/modules/producao-pedido/producao-pedido.service.ts`

### Cloud and sync

- [Versioned API](https://github.com/rodrigotjf1-boop/regem/blob/main/backend/src/main.ts): `backend/src/main.ts`
- [Unit local node](https://github.com/rodrigotjf1-boop/regem/blob/main/backend/edge/sync-daemon.mjs): `backend/edge/sync-daemon.mjs`
- [Offline synchronization](https://github.com/rodrigotjf1-boop/regem/blob/main/backend/edge/sync-daemon.mjs): `backend/edge/sync-daemon.mjs`
- [Executive dashboard](https://github.com/rodrigotjf1-boop/regem/blob/main/backend/src/modules/dashboard/dashboard.service.ts): `backend/src/modules/dashboard/dashboard.service.ts`
- [External API integrations](https://github.com/rodrigotjf1-boop/regem/blob/main/backend/src/modules/integracao-api/integracao-api.controller.ts): `backend/src/modules/integracao-api/integracao-api.controller.ts`

### Other components

- **Store staff**
- **President / C&O**

## Connections

- Store staff → Web app: use operations (evidence: `README.md`)
- President / C&O → Executive dashboard: view analytics (evidence: `README.md`)
- Store staff → Atendimento app: use support (evidence: `README.md`)
- Store staff → Entregador app: use delivery
- Versioned API → PostgreSQL: uses PostgreSQL (evidence: `README.md`)
- Unit local node → PostgreSQL: stores unit data (evidence: `README.md`)
- Unit local node → Offline synchronization: runs sync (evidence: `backend/edge/sync-daemon.mjs`)
- Offline synchronization → Versioned API: syncs with cloud (evidence: `README.md`)
- Versioned API → Executive dashboard: serves reporting (evidence: `README.md`)
- Versioned API → External API integrations: hosts cloud API (evidence: `README.md`)
- Identity and RBAC → PostgreSQL: reads and writes (evidence: `backend/src/auth/auth.service.ts`)
- JWT validation → Request user context: populates request (evidence: `backend/src/auth/jwt-auth.guard.ts`)
- Role authorization → Request user context: checks role (evidence: `backend/src/auth/roles.guard.ts`)
- Permission authorization → Request user context: checks permissions (evidence: `backend/src/auth/permissoes.guard.ts`)
- Case endpoints → Case workflows: resolves cases (evidence: `backend/src/modules/atendimento/atendimento.controller.ts`)
- Case endpoints → Customer arrival: queries arrival (evidence: `backend/src/modules/atendimento/atendimento.controller.ts`)
- Case endpoints → Order production: uses production (evidence: `backend/src/modules/atendimento/atendimento.controller.ts`)
