# gabriel-oliveira27/fs-escala architecture

> Architecture diagram of the GitHub repository gabriel-oliveira27/fs-escala, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gabriel-oliveira27/fs-escala
- Repository: https://github.com/gabriel-oliveira27/fs-escala

## Overview

FS Escala Operacional is a multi-branch workforce scheduling and HR application. A branch manager configures staffing and schedules, maintains employee data, and reviews coverage, time banks, leave, and resolutions; regional staff compare branches, while employees use self-service for timekeeping and requests. The Next.js application separates user-facing features, pure scheduling and HR rules, server-side access and actions, and persistence/integrations. The README documents the product capabilities; sampled excerpts show selected auth, API, and repository links, so other connections are omitted or marked unverified rather than inferred as calls.

Main entry points: [`src/app/f/[filialId]`](https://github.com/gabriel-oliveira27/fs-escala/tree/master/src/app/f/%5BfilialId%5D) (Branch operations), [`src/app`](https://github.com/gabriel-oliveira27/fs-escala/tree/master/src/app) (Next.js application), [`src/server/acoes.ts`](https://github.com/gabriel-oliveira27/fs-escala/blob/master/src/server/acoes.ts) (Server actions), [`src/domain/mapa-mensal.ts`](https://github.com/gabriel-oliveira27/fs-escala/blob/master/src/domain/mapa-mensal.ts) (Monthly schedule map)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_features["User workflows"]
  node_app["Next.js application"]
  node_branch["Branch operations"]
  node_regional["Regional oversight"]
  node_selfservice["Employee self-service"]
  node_admin["Administration"]
  node_mobile["Mobile app<br/>[App.tsx]"]
end

subgraph group_domain["Scheduling and HR rules"]
  node_schedule["Schedule rules"]
  node_sunday["Sunday planning<br/>[domingos.ts]"]
  node_timebank["Time bank<br/>[banco-horas.ts]"]
  node_continuity["Continuity planning<br/>[continuidade.ts]"]
  node_monthly["Monthly schedule map<br/>[mapa-mensal.ts]"]
  node_absences["Absences and leave<br/>[afastamentos.ts]"]
  node_types["Schedule model<br/>[tipos.ts]"]
  node_authlogic["Access rules<br/>[acesso.ts]"]
end

subgraph group_backend["Server services"]
  node_serveractions["Server actions<br/>[acoes.ts]"]
  node_access["Session and permissions<br/>[dal.ts]"]
  node_session["Session lifecycle<br/>[sessao.ts]"]
  node_google["Google sign-in<br/>[route.ts]"]
  node_callback["Google callback<br/>[route.ts]"]
  node_dataapi["Data API client<br/>[cliente.ts]"]
end

subgraph group_storage["Persistence and integrations"]
  node_repo["Operational repository<br/>[repo.ts]"]
  node_accessrepo["Access repository<br/>[repo-acessos.ts]"]
  node_database[("PostgreSQL<br/>[schema.ts]")]
  node_cloud["Cloud migration<br/>[migracao.ts]"]
  node_erp["ERP integration<br/>[servico.ts]"]
  node_files["File storage<br/>[index.ts]"]
end

node_staff(("Branch workforce"))

node_staff -->|"uses"| node_app
node_app -->|"opens branch"| node_branch
node_app -->|"opens regional view"| node_regional
node_app -->|"opens self-service"| node_selfservice
node_app -->|"opens administration"| node_admin
node_staff -->|"uses"| node_mobile
node_branch -.->|"submits changes"| node_serveractions
node_regional -.->|"requests reports"| node_serveractions
node_selfservice -.->|"submits requests"| node_serveractions
node_branch -->|"manages schedules"| node_schedule
node_branch -->|"plans Sundays"| node_sunday
node_branch -->|"manages balances"| node_timebank
node_branch -->|"plans substitutes"| node_continuity
node_branch -->|"views month"| node_monthly
node_branch -->|"records absences"| node_absences
node_schedule -->|"uses model"| node_types
node_monthly -->|"uses leave data"| node_absences
node_monthly -->|"uses Sunday rules"| node_sunday
node_sunday -->|"uses model"| node_types
node_serveractions -.->|"checks access"| node_access
node_google -->|"checks current user"| node_access
node_google -.->|"redirects callback"| node_callback
node_callback -->|"reads and records access"| node_accessrepo
node_callback -->|"uses session helpers"| node_session
node_access -->|"reads session"| node_session
node_session -->|"manages sessions"| node_accessrepo
node_repo -->|"queries and writes"| node_database
node_accessrepo -->|"dispatches data calls"| node_dataapi
node_serveractions -.->|"persists operations"| node_repo
node_app -->|"imports legacy data"| node_cloud
node_branch -.->|"uses ERP integration"| node_erp
node_branch -.->|"serves attachments"| node_files

click node_app "https://github.com/gabriel-oliveira27/fs-escala/tree/master/src/app"
click node_branch "https://github.com/gabriel-oliveira27/fs-escala/tree/master/src/app/f/%5BfilialId%5D"
click node_regional "https://github.com/gabriel-oliveira27/fs-escala/tree/master/src/app/regional"
click node_selfservice "https://github.com/gabriel-oliveira27/fs-escala/tree/master/src/app/meu-ponto"
click node_admin "https://github.com/gabriel-oliveira27/fs-escala/tree/master/src/app/desenvolvimento"
click node_mobile "https://github.com/gabriel-oliveira27/fs-escala/blob/master/celular/App.tsx"
click node_schedule "https://github.com/gabriel-oliveira27/fs-escala/blob/master/src/domain/escalas-especificas.ts"
click node_sunday "https://github.com/gabriel-oliveira27/fs-escala/blob/master/src/domain/domingos.ts"
click node_timebank "https://github.com/gabriel-oliveira27/fs-escala/blob/master/src/domain/banco-horas.ts"
click node_continuity "https://github.com/gabriel-oliveira27/fs-escala/blob/master/src/domain/continuidade.ts"
click node_monthly "https://github.com/gabriel-oliveira27/fs-escala/blob/master/src/domain/mapa-mensal.ts"
click node_absences "https://github.com/gabriel-oliveira27/fs-escala/blob/master/src/domain/afastamentos.ts"
click node_types "https://github.com/gabriel-oliveira27/fs-escala/blob/master/src/domain/tipos.ts"
click node_authlogic "https://github.com/gabriel-oliveira27/fs-escala/blob/master/src/domain/acesso.ts"
click node_serveractions "https://github.com/gabriel-oliveira27/fs-escala/blob/master/src/server/acoes.ts"
click node_access "https://github.com/gabriel-oliveira27/fs-escala/blob/master/src/server/acesso/dal.ts"
click node_session "https://github.com/gabriel-oliveira27/fs-escala/blob/master/src/server/acesso/sessao.ts"
click node_google "https://github.com/gabriel-oliveira27/fs-escala/blob/master/src/app/auth/google/route.ts"
click node_callback "https://github.com/gabriel-oliveira27/fs-escala/blob/master/src/app/auth/google/callback/route.ts"
click node_dataapi "https://github.com/gabriel-oliveira27/fs-escala/blob/master/src/server/api-dados/cliente.ts"
click node_repo "https://github.com/gabriel-oliveira27/fs-escala/blob/master/src/server/dados/repo.ts"
click node_accessrepo "https://github.com/gabriel-oliveira27/fs-escala/blob/master/src/server/dados/repo-acessos.ts"
click node_database "https://github.com/gabriel-oliveira27/fs-escala/blob/master/src/server/db/schema.ts"
click node_cloud "https://github.com/gabriel-oliveira27/fs-escala/blob/master/src/server/nuvem/migracao.ts"
click node_erp "https://github.com/gabriel-oliveira27/fs-escala/blob/master/src/server/erp/servico.ts"
click node_files "https://github.com/gabriel-oliveira27/fs-escala/blob/master/src/server/arquivos/index.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_app,node_branch,node_regional,node_selfservice,node_admin,node_mobile toneBlue
class node_schedule,node_sunday,node_timebank,node_continuity,node_monthly,node_absences,node_types,node_authlogic toneAmber
class node_serveractions,node_access,node_session,node_google,node_callback,node_dataapi toneMint
class node_repo,node_accessrepo,node_database,node_cloud,node_erp,node_files toneRose
class node_staff toneIndigo
```

## Components

### User workflows

- [Next.js application](https://github.com/gabriel-oliveira27/fs-escala/tree/master/src/app): `src/app`
- [Branch operations](https://github.com/gabriel-oliveira27/fs-escala/tree/master/src/app/f/%5BfilialId%5D): `src/app/f/[filialId]`
- [Regional oversight](https://github.com/gabriel-oliveira27/fs-escala/tree/master/src/app/regional): `src/app/regional`
- [Employee self-service](https://github.com/gabriel-oliveira27/fs-escala/tree/master/src/app/meu-ponto): `src/app/meu-ponto`
- [Administration](https://github.com/gabriel-oliveira27/fs-escala/tree/master/src/app/desenvolvimento): `src/app/desenvolvimento`
- [Mobile app](https://github.com/gabriel-oliveira27/fs-escala/blob/master/celular/App.tsx): `celular/App.tsx`

### Scheduling and HR rules

- [Schedule rules](https://github.com/gabriel-oliveira27/fs-escala/blob/master/src/domain/escalas-especificas.ts): `src/domain/escalas-especificas.ts`
- [Sunday planning](https://github.com/gabriel-oliveira27/fs-escala/blob/master/src/domain/domingos.ts): `src/domain/domingos.ts`
- [Time bank](https://github.com/gabriel-oliveira27/fs-escala/blob/master/src/domain/banco-horas.ts): `src/domain/banco-horas.ts`
- [Continuity planning](https://github.com/gabriel-oliveira27/fs-escala/blob/master/src/domain/continuidade.ts): `src/domain/continuidade.ts`
- [Monthly schedule map](https://github.com/gabriel-oliveira27/fs-escala/blob/master/src/domain/mapa-mensal.ts): `src/domain/mapa-mensal.ts`
- [Absences and leave](https://github.com/gabriel-oliveira27/fs-escala/blob/master/src/domain/afastamentos.ts): `src/domain/afastamentos.ts`
- [Schedule model](https://github.com/gabriel-oliveira27/fs-escala/blob/master/src/domain/tipos.ts): `src/domain/tipos.ts`
- [Access rules](https://github.com/gabriel-oliveira27/fs-escala/blob/master/src/domain/acesso.ts): `src/domain/acesso.ts`

### Server services

- [Server actions](https://github.com/gabriel-oliveira27/fs-escala/blob/master/src/server/acoes.ts): `src/server/acoes.ts`
- [Session and permissions](https://github.com/gabriel-oliveira27/fs-escala/blob/master/src/server/acesso/dal.ts): `src/server/acesso/dal.ts`
- [Session lifecycle](https://github.com/gabriel-oliveira27/fs-escala/blob/master/src/server/acesso/sessao.ts): `src/server/acesso/sessao.ts`
- [Google sign-in](https://github.com/gabriel-oliveira27/fs-escala/blob/master/src/app/auth/google/route.ts): `src/app/auth/google/route.ts`
- [Google callback](https://github.com/gabriel-oliveira27/fs-escala/blob/master/src/app/auth/google/callback/route.ts): `src/app/auth/google/callback/route.ts`
- [Data API client](https://github.com/gabriel-oliveira27/fs-escala/blob/master/src/server/api-dados/cliente.ts): `src/server/api-dados/cliente.ts`

### Persistence and integrations

- [Operational repository](https://github.com/gabriel-oliveira27/fs-escala/blob/master/src/server/dados/repo.ts): `src/server/dados/repo.ts`
- [Access repository](https://github.com/gabriel-oliveira27/fs-escala/blob/master/src/server/dados/repo-acessos.ts): `src/server/dados/repo-acessos.ts`
- [PostgreSQL](https://github.com/gabriel-oliveira27/fs-escala/blob/master/src/server/db/schema.ts): `src/server/db/schema.ts`
- [Cloud migration](https://github.com/gabriel-oliveira27/fs-escala/blob/master/src/server/nuvem/migracao.ts): `src/server/nuvem/migracao.ts`
- [ERP integration](https://github.com/gabriel-oliveira27/fs-escala/blob/master/src/server/erp/servico.ts): `src/server/erp/servico.ts`
- [File storage](https://github.com/gabriel-oliveira27/fs-escala/blob/master/src/server/arquivos/index.ts): `src/server/arquivos/index.ts`

### Other components

- **Branch workforce**

## Connections

- Branch workforce → Next.js application: uses (evidence: `README.md`)
- Next.js application → Branch operations: opens branch (evidence: `README.md`)
- Next.js application → Regional oversight: opens regional view (evidence: `README.md`)
- Next.js application → Employee self-service: opens self-service (evidence: `README.md`)
- Next.js application → Administration: opens administration (evidence: `README.md`)
- Branch workforce → Mobile app: uses (evidence: `README.md`)
- Branch operations → Server actions: submits changes
- Regional oversight → Server actions: requests reports
- Employee self-service → Server actions: submits requests
- Branch operations → Schedule rules: manages schedules (evidence: `README.md`)
- Branch operations → Sunday planning: plans Sundays (evidence: `README.md`)
- Branch operations → Time bank: manages balances (evidence: `README.md`)
- Branch operations → Continuity planning: plans substitutes (evidence: `README.md`)
- Branch operations → Monthly schedule map: views month (evidence: `README.md`)
- Branch operations → Absences and leave: records absences (evidence: `README.md`)
- Schedule rules → Schedule model: uses model (evidence: `src/domain/escalas-especificas.ts`)
- Monthly schedule map → Absences and leave: uses leave data (evidence: `src/domain/mapa-mensal.ts`)
- Monthly schedule map → Sunday planning: uses Sunday rules (evidence: `src/domain/mapa-mensal.ts`)
- Sunday planning → Schedule model: uses model (evidence: `src/domain/domingos.ts`)
- Server actions → Session and permissions: checks access
- Google sign-in → Session and permissions: checks current user (evidence: `src/app/auth/google/route.ts`)
- Google sign-in → Google callback: redirects callback
- Google callback → Access repository: reads and records access (evidence: `src/app/auth/google/callback/route.ts`)
- Google callback → Session lifecycle: uses session helpers (evidence: `src/app/auth/google/callback/route.ts`)
- Session and permissions → Session lifecycle: reads session (evidence: `src/server/acesso/dal.ts`)
- Session lifecycle → Access repository: manages sessions (evidence: `src/server/acesso/sessao.ts`)
- Operational repository → PostgreSQL: queries and writes (evidence: `src/server/dados/repo.ts`)
- Access repository → Data API client: dispatches data calls (evidence: `src/server/repo-acessos.ts`)
- Server actions → Operational repository: persists operations
- Next.js application → Cloud migration: imports legacy data (evidence: `src/app/api/v1/migracao/route.ts`)
- Branch operations → ERP integration: uses ERP integration
- Branch operations → File storage: serves attachments
