# escritoriojnsistema/escritoriojn architecture

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

- Interactive diagram: https://gitdiagram.com/escritoriojnsistema/escritoriojn
- Repository: https://github.com/escritoriojnsistema/escritoriojn

## Overview

Escritório JN is an office-management application for team and client access, customer records and relationships, versioned services, service requests, and governance. Users enter through public or authenticated pages; the app verifies identity and current access before exposing operational areas. Staff can manage customers, services, requests, team, audit, and archives, while clients have a separate request path. The Express API routes domain operations and verifies Bearer identities; documented authorization and persistence rely on Supabase Auth/RLS and RPCs. Some frontend-to-API wiring is not shown in the excerpts, so those links are marked unverified.

Main entry points: [`src/App.tsx`](https://github.com/escritoriojnsistema/escritoriojn/blob/main/src/App.tsx) (Route application), [`server/app.ts`](https://github.com/escritoriojnsistema/escritoriojn/blob/main/server/app.ts) (Express API), [`server/modules/team`](https://github.com/escritoriojnsistema/escritoriojn/tree/main/server/modules/team) (Team API), [`server/modules/requests`](https://github.com/escritoriojnsistema/escritoriojn/tree/main/server/modules/requests) (Requests API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Web experience"]
  node_app["Route application<br/>[App.tsx]"]
  node_routes["Route definitions<br/>[routes.ts]"]
  node_home["Public home and status"]
end

subgraph group_identity["Identity and access"]
  node_auth_ui["Session and access<br/>[AuthProvider.tsx]"]
  node_auth_api["Identity verification<br/>[client.ts]"]
end

subgraph group_operations["Office operations"]
  node_team_ui["Team and invitations"]
  node_customers_ui["Customer records"]
  node_relations_ui["Customer relationships"]
  node_services_ui["Service catalog"]
  node_requests_ui["Service requests"]
  node_governance_ui["Audit and archives"]
end

subgraph group_api["API services"]
  node_shared_contracts["Domain contracts"]
  node_server["Express API<br/>[app.ts]"]
  node_team_api["Team API"]
  node_governance_api["Governance API"]
  node_customers_api["Customer API"]
  node_relations_api["Relationship API"]
  node_services_api["Services API"]
  node_requests_api["Requests API"]
end

node_visitor(("Staff or client"))
node_supabase[("Supabase Auth and data")]

node_visitor -->|"opens"| node_app
node_app -->|"uses paths"| node_routes
node_app -->|"provides session"| node_auth_ui
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_team_ui
node_app -->|"routes to"| node_customers_ui
node_app -->|"routes to"| node_services_ui
node_app -->|"routes to"| node_requests_ui
node_app -->|"routes to"| node_governance_ui
node_customers_ui -->|"renders"| node_relations_ui
node_auth_ui -->|"validates access"| node_shared_contracts
node_services_ui -->|"uses service types"| node_shared_contracts
node_server -->|"mounts"| node_auth_api
node_server -->|"mounts"| node_team_api
node_server -->|"mounts"| node_governance_api
node_server -->|"mounts"| node_customers_api
node_server -->|"mounts"| node_relations_api
node_server -->|"mounts"| node_services_api
node_server -->|"mounts"| node_requests_api
node_team_api -->|"verifies identity"| node_auth_api
node_requests_api -->|"verifies identity"| node_auth_api
node_auth_api -->|"verifies user"| node_supabase
node_team_api -->|"calls RPCs"| node_supabase
node_requests_api -->|"calls RPCs"| node_supabase
node_customers_ui -.->|"requests data"| node_customers_api
node_relations_ui -.->|"requests data"| node_relations_api
node_team_ui -.->|"requests data"| node_team_api
node_services_ui -.->|"requests data"| node_services_api
node_requests_ui -.->|"requests data"| node_requests_api
node_governance_ui -.->|"requests data"| node_governance_api

click node_app "https://github.com/escritoriojnsistema/escritoriojn/blob/main/src/App.tsx"
click node_routes "https://github.com/escritoriojnsistema/escritoriojn/blob/main/src/app/routes.ts"
click node_auth_ui "https://github.com/escritoriojnsistema/escritoriojn/blob/main/src/features/auth/AuthProvider.tsx"
click node_home "https://github.com/escritoriojnsistema/escritoriojn/tree/main/src/features/home"
click node_team_ui "https://github.com/escritoriojnsistema/escritoriojn/tree/main/src/features/team"
click node_customers_ui "https://github.com/escritoriojnsistema/escritoriojn/tree/main/src/features/customers"
click node_relations_ui "https://github.com/escritoriojnsistema/escritoriojn/tree/main/src/features/customer-relations"
click node_services_ui "https://github.com/escritoriojnsistema/escritoriojn/tree/main/src/features/services"
click node_requests_ui "https://github.com/escritoriojnsistema/escritoriojn/tree/main/src/features/requests"
click node_governance_ui "https://github.com/escritoriojnsistema/escritoriojn/tree/main/src/features/governance"
click node_shared_contracts "https://github.com/escritoriojnsistema/escritoriojn/tree/main/shared"
click node_server "https://github.com/escritoriojnsistema/escritoriojn/blob/main/server/app.ts"
click node_auth_api "https://github.com/escritoriojnsistema/escritoriojn/blob/main/server/modules/auth/client.ts"
click node_team_api "https://github.com/escritoriojnsistema/escritoriojn/tree/main/server/modules/team"
click node_governance_api "https://github.com/escritoriojnsistema/escritoriojn/tree/main/server/modules/governance"
click node_customers_api "https://github.com/escritoriojnsistema/escritoriojn/tree/main/server/modules/customers"
click node_relations_api "https://github.com/escritoriojnsistema/escritoriojn/tree/main/server/modules/customer-relations"
click node_services_api "https://github.com/escritoriojnsistema/escritoriojn/tree/main/server/modules/services"
click node_requests_api "https://github.com/escritoriojnsistema/escritoriojn/tree/main/server/modules/requests"

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_app,node_routes,node_home,node_visitor toneBlue
class node_auth_ui,node_auth_api,node_supabase toneAmber
class node_team_ui,node_customers_ui,node_relations_ui,node_services_ui,node_requests_ui,node_governance_ui toneMint
class node_shared_contracts,node_server,node_team_api,node_governance_api,node_customers_api,node_relations_api,node_services_api,node_requests_api toneRose
```

## Components

### Web experience

- [Route application](https://github.com/escritoriojnsistema/escritoriojn/blob/main/src/App.tsx): `src/App.tsx`
- [Route definitions](https://github.com/escritoriojnsistema/escritoriojn/blob/main/src/app/routes.ts): `src/app/routes.ts`
- [Public home and status](https://github.com/escritoriojnsistema/escritoriojn/tree/main/src/features/home): `src/features/home`

### Identity and access

- [Session and access](https://github.com/escritoriojnsistema/escritoriojn/blob/main/src/features/auth/AuthProvider.tsx): `src/features/auth/AuthProvider.tsx`
- [Identity verification](https://github.com/escritoriojnsistema/escritoriojn/blob/main/server/modules/auth/client.ts): `server/modules/auth/client.ts`

### Office operations

- [Team and invitations](https://github.com/escritoriojnsistema/escritoriojn/tree/main/src/features/team): `src/features/team`
- [Customer records](https://github.com/escritoriojnsistema/escritoriojn/tree/main/src/features/customers): `src/features/customers`
- [Customer relationships](https://github.com/escritoriojnsistema/escritoriojn/tree/main/src/features/customer-relations): `src/features/customer-relations`
- [Service catalog](https://github.com/escritoriojnsistema/escritoriojn/tree/main/src/features/services): `src/features/services`
- [Service requests](https://github.com/escritoriojnsistema/escritoriojn/tree/main/src/features/requests): `src/features/requests`
- [Audit and archives](https://github.com/escritoriojnsistema/escritoriojn/tree/main/src/features/governance): `src/features/governance`

### API services

- [Domain contracts](https://github.com/escritoriojnsistema/escritoriojn/tree/main/shared): `shared`
- [Express API](https://github.com/escritoriojnsistema/escritoriojn/blob/main/server/app.ts): `server/app.ts`
- [Team API](https://github.com/escritoriojnsistema/escritoriojn/tree/main/server/modules/team): `server/modules/team`
- [Governance API](https://github.com/escritoriojnsistema/escritoriojn/tree/main/server/modules/governance): `server/modules/governance`
- [Customer API](https://github.com/escritoriojnsistema/escritoriojn/tree/main/server/modules/customers): `server/modules/customers`
- [Relationship API](https://github.com/escritoriojnsistema/escritoriojn/tree/main/server/modules/customer-relations): `server/modules/customer-relations`
- [Services API](https://github.com/escritoriojnsistema/escritoriojn/tree/main/server/modules/services): `server/modules/services`
- [Requests API](https://github.com/escritoriojnsistema/escritoriojn/tree/main/server/modules/requests): `server/modules/requests`

### Other components

- **Staff or client**
- **Supabase Auth and data**

## Connections

- Staff or client → Route application: opens (evidence: `src/App.tsx`)
- Route application → Route definitions: uses paths (evidence: `src/App.tsx`)
- Route application → Session and access: provides session (evidence: `src/App.tsx`)
- Route application → Public home and status: routes to (evidence: `src/App.tsx`)
- Route application → Team and invitations: routes to (evidence: `src/App.tsx`)
- Route application → Customer records: routes to (evidence: `src/App.tsx`)
- Route application → Service catalog: routes to (evidence: `src/App.tsx`)
- Route application → Service requests: routes to (evidence: `src/App.tsx`)
- Route application → Audit and archives: routes to (evidence: `src/App.tsx`)
- Customer records → Customer relationships: renders (evidence: `src/features/customers/CustomersPage.tsx`)
- Session and access → Domain contracts: validates access (evidence: `src/features/auth/AuthProvider.tsx`)
- Service catalog → Domain contracts: uses service types (evidence: `src/features/services/ServicesPage.tsx`)
- Express API → Identity verification: mounts (evidence: `server/app.ts`)
- Express API → Team API: mounts (evidence: `server/app.ts`)
- Express API → Governance API: mounts (evidence: `server/app.ts`)
- Express API → Customer API: mounts (evidence: `server/app.ts`)
- Express API → Relationship API: mounts (evidence: `server/app.ts`)
- Express API → Services API: mounts (evidence: `server/app.ts`)
- Express API → Requests API: mounts (evidence: `server/app.ts`)
- Team API → Identity verification: verifies identity (evidence: `server/modules/team/router.ts`)
- Requests API → Identity verification: verifies identity (evidence: `server/modules/requests/router.ts`)
- Identity verification → Supabase Auth and data: verifies user (evidence: `server/modules/auth/client.ts`)
- Team API → Supabase Auth and data: calls RPCs (evidence: `server/modules/team/router.ts`)
- Requests API → Supabase Auth and data: calls RPCs (evidence: `server/modules/requests/router.ts`)
- Customer records → Customer API: requests data
- Customer relationships → Relationship API: requests data
- Team and invitations → Team API: requests data
- Service catalog → Services API: requests data
- Service requests → Requests API: requests data
- Audit and archives → Governance API: requests data
