# msant1972/propostas architecture

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

- Interactive diagram: https://gitdiagram.com/msant1972/propostas
- Repository: https://github.com/msant1972/propostas

## Overview

Propostas is a proposal-server repository with a web client, NestJS API, and background worker. The visible user journey is login and authentication, then browsing the product catalog through protected API routes; the API resolves users and authorization before serving catalog data. Separately, the worker relays outbox events into a queue and dispatches registered handlers. The README gives no further business-domain detail, and the worker handlers shown are only system examples, so richer proposal lifecycle stages cannot be established from the available evidence.

Main entry points: [`apps/web/src/App.tsx`](https://github.com/msant1972/propostas/blob/main/apps/web/src/App.tsx) (Routes and shell), [`apps/worker/src/main.ts`](https://github.com/msant1972/propostas/blob/main/apps/worker/src/main.ts) (Worker runtime), [`apps/web/src/auth/RequireAuth.tsx`](https://github.com/msant1972/propostas/blob/main/apps/web/src/auth/RequireAuth.tsx) (Auth gate), [`apps/api/src/authz/authz.ts`](https://github.com/msant1972/propostas/blob/main/apps/api/src/authz/authz.ts) (Authorization guard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web client"]
  node_app["Routes and shell<br/>[App.tsx]"]
  node_authgate["Auth gate<br/>[RequireAuth.tsx]"]
  node_login["Login page<br/>[LoginPage.tsx]"]
  node_websession["Web session<br/>[store.ts]"]
  node_msal["Entra sign-in<br/>[msal.ts]"]
  node_catalogpage["Catalog page<br/>[CatalogPage.tsx]"]
  node_productpage["Product detail<br/>[ProductPage.tsx]"]
end

subgraph group_api["API and access"]
  node_api["API application<br/>[app.module.ts]"]
  node_authguard["Authentication guard<br/>[auth.guard.ts]"]
  node_tokenverify["Token verification<br/>[token-verifier.ts]"]
  node_devtoken["Dev token endpoint"]
  node_authz["Authorization guard<br/>[authz.ts]"]
  node_users["User resolution<br/>[users.service.ts]"]
  node_ability["Permission rules<br/>[ability.ts]"]
  node_catalogcontroller["Catalog routes"]
  node_catalogservice["Catalog service<br/>[catalog.service.ts]"]
  node_outboxservice["Outbox service<br/>[outbox.service.ts]"]
end

subgraph group_worker["Background processing"]
  node_workerentry["Worker runtime<br/>[main.ts]"]
  node_relay["Outbox relay<br/>[relay.service.ts]"]
  node_handlers["Event dispatch<br/>[handlers.ts]"]
  node_queue["Redis job queue"]
end

subgraph group_data["Persistence"]
  node_prisma["Prisma access<br/>[prisma.module.ts]"]
  node_database[("Database")]
end

node_user(("User"))

node_user -->|"uses"| node_app
node_app -->|"protects routes"| node_authgate
node_app -->|"routes to"| node_login
node_app -->|"routes to"| node_catalogpage
node_app -->|"routes to"| node_productpage
node_authgate -->|"reads session"| node_websession
node_authgate -->|"acquires token"| node_msal
node_login -->|"sets session"| node_websession
node_catalogpage -->|"requests catalog"| node_catalogcontroller
node_api -->|"registers guard"| node_authguard
node_api -->|"registers guard"| node_authz
node_authguard -->|"verifies token"| node_tokenverify
node_devtoken -->|"issues token"| node_tokenverify
node_authz -->|"resolves actor"| node_users
node_authz -->|"checks permission"| node_ability
node_catalogcontroller -->|"calls"| node_catalogservice
node_catalogservice -->|"uses persistence"| node_prisma
node_users -->|"upserts user"| node_prisma
node_prisma -.->|"accesses"| node_database
node_workerentry -->|"starts relay"| node_relay
node_workerentry -->|"dispatches jobs"| node_handlers
node_workerentry -->|"creates worker and queue"| node_queue
node_relay -->|"publishes jobs"| node_queue
node_relay -->|"claims outbox events"| node_database
node_outboxservice -.->|"writes events"| node_database

click node_app "https://github.com/msant1972/propostas/blob/main/apps/web/src/App.tsx"
click node_authgate "https://github.com/msant1972/propostas/blob/main/apps/web/src/auth/RequireAuth.tsx"
click node_login "https://github.com/msant1972/propostas/blob/main/apps/web/src/pages/LoginPage.tsx"
click node_websession "https://github.com/msant1972/propostas/blob/main/apps/web/src/auth/store.ts"
click node_msal "https://github.com/msant1972/propostas/blob/main/apps/web/src/auth/msal.ts"
click node_catalogpage "https://github.com/msant1972/propostas/blob/main/apps/web/src/pages/CatalogPage.tsx"
click node_productpage "https://github.com/msant1972/propostas/blob/main/apps/web/src/pages/ProductPage.tsx"
click node_api "https://github.com/msant1972/propostas/blob/main/apps/api/src/app.module.ts"
click node_authguard "https://github.com/msant1972/propostas/blob/main/apps/api/src/auth/auth.guard.ts"
click node_tokenverify "https://github.com/msant1972/propostas/blob/main/apps/api/src/auth/token-verifier.ts"
click node_devtoken "https://github.com/msant1972/propostas/blob/main/apps/api/src/auth/dev-auth.controller.ts"
click node_authz "https://github.com/msant1972/propostas/blob/main/apps/api/src/authz/authz.ts"
click node_users "https://github.com/msant1972/propostas/blob/main/apps/api/src/users/users.service.ts"
click node_ability "https://github.com/msant1972/propostas/blob/main/apps/api/src/authz/ability.ts"
click node_catalogcontroller "https://github.com/msant1972/propostas/blob/main/apps/api/src/catalog/catalog.controller.ts"
click node_catalogservice "https://github.com/msant1972/propostas/blob/main/apps/api/src/catalog/catalog.service.ts"
click node_outboxservice "https://github.com/msant1972/propostas/blob/main/apps/api/src/outbox/outbox.service.ts"
click node_prisma "https://github.com/msant1972/propostas/blob/main/apps/api/src/prisma/prisma.module.ts"
click node_workerentry "https://github.com/msant1972/propostas/blob/main/apps/worker/src/main.ts"
click node_relay "https://github.com/msant1972/propostas/blob/main/apps/worker/src/relay/relay.service.ts"
click node_handlers "https://github.com/msant1972/propostas/blob/main/apps/worker/src/queues/handlers.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_authgate,node_login,node_websession,node_msal,node_catalogpage,node_productpage,node_user toneBlue
class node_api,node_authguard,node_tokenverify,node_devtoken,node_authz,node_users,node_ability,node_catalogcontroller,node_catalogservice,node_outboxservice toneAmber
class node_workerentry,node_relay,node_handlers,node_queue toneMint
class node_prisma,node_database toneRose
```

## Components

### Web client

- [Routes and shell](https://github.com/msant1972/propostas/blob/main/apps/web/src/App.tsx): `apps/web/src/App.tsx`
- [Auth gate](https://github.com/msant1972/propostas/blob/main/apps/web/src/auth/RequireAuth.tsx): `apps/web/src/auth/RequireAuth.tsx`
- [Login page](https://github.com/msant1972/propostas/blob/main/apps/web/src/pages/LoginPage.tsx): `apps/web/src/pages/LoginPage.tsx`
- [Web session](https://github.com/msant1972/propostas/blob/main/apps/web/src/auth/store.ts): `apps/web/src/auth/store.ts`
- [Entra sign-in](https://github.com/msant1972/propostas/blob/main/apps/web/src/auth/msal.ts): `apps/web/src/auth/msal.ts`
- [Catalog page](https://github.com/msant1972/propostas/blob/main/apps/web/src/pages/CatalogPage.tsx): `apps/web/src/pages/CatalogPage.tsx`
- [Product detail](https://github.com/msant1972/propostas/blob/main/apps/web/src/pages/ProductPage.tsx): `apps/web/src/pages/ProductPage.tsx`

### API and access

- [API application](https://github.com/msant1972/propostas/blob/main/apps/api/src/app.module.ts): `apps/api/src/app.module.ts`
- [Authentication guard](https://github.com/msant1972/propostas/blob/main/apps/api/src/auth/auth.guard.ts): `apps/api/src/auth/auth.guard.ts`
- [Token verification](https://github.com/msant1972/propostas/blob/main/apps/api/src/auth/token-verifier.ts): `apps/api/src/auth/token-verifier.ts`
- [Dev token endpoint](https://github.com/msant1972/propostas/blob/main/apps/api/src/auth/dev-auth.controller.ts): `apps/api/src/auth/dev-auth.controller.ts`
- [Authorization guard](https://github.com/msant1972/propostas/blob/main/apps/api/src/authz/authz.ts): `apps/api/src/authz/authz.ts`
- [User resolution](https://github.com/msant1972/propostas/blob/main/apps/api/src/users/users.service.ts): `apps/api/src/users/users.service.ts`
- [Permission rules](https://github.com/msant1972/propostas/blob/main/apps/api/src/authz/ability.ts): `apps/api/src/authz/ability.ts`
- [Catalog routes](https://github.com/msant1972/propostas/blob/main/apps/api/src/catalog/catalog.controller.ts): `apps/api/src/catalog/catalog.controller.ts`
- [Catalog service](https://github.com/msant1972/propostas/blob/main/apps/api/src/catalog/catalog.service.ts): `apps/api/src/catalog/catalog.service.ts`
- [Outbox service](https://github.com/msant1972/propostas/blob/main/apps/api/src/outbox/outbox.service.ts): `apps/api/src/outbox/outbox.service.ts`

### Background processing

- [Worker runtime](https://github.com/msant1972/propostas/blob/main/apps/worker/src/main.ts): `apps/worker/src/main.ts`
- [Outbox relay](https://github.com/msant1972/propostas/blob/main/apps/worker/src/relay/relay.service.ts): `apps/worker/src/relay/relay.service.ts`
- [Event dispatch](https://github.com/msant1972/propostas/blob/main/apps/worker/src/queues/handlers.ts): `apps/worker/src/queues/handlers.ts`
- **Redis job queue**

### Persistence

- [Prisma access](https://github.com/msant1972/propostas/blob/main/apps/api/src/prisma/prisma.module.ts): `apps/api/src/prisma/prisma.module.ts`
- **Database**

### Other components

- **User**

## Connections

- User → Routes and shell: uses (evidence: `apps/web/src/App.tsx`)
- Routes and shell → Auth gate: protects routes (evidence: `apps/web/src/App.tsx`)
- Routes and shell → Login page: routes to (evidence: `apps/web/src/App.tsx`)
- Routes and shell → Catalog page: routes to (evidence: `apps/web/src/App.tsx`)
- Routes and shell → Product detail: routes to (evidence: `apps/web/src/App.tsx`)
- Auth gate → Web session: reads session (evidence: `apps/web/src/auth/RequireAuth.tsx`)
- Auth gate → Entra sign-in: acquires token (evidence: `apps/web/src/auth/RequireAuth.tsx`)
- Login page → Web session: sets session (evidence: `apps/web/src/pages/LoginPage.tsx`)
- Catalog page → Catalog routes: requests catalog (evidence: `apps/web/src/pages/CatalogPage.tsx`)
- API application → Authentication guard: registers guard (evidence: `apps/api/src/app.module.ts`)
- API application → Authorization guard: registers guard (evidence: `apps/api/src/app.module.ts`)
- Authentication guard → Token verification: verifies token (evidence: `apps/api/src/auth/auth.guard.ts`)
- Dev token endpoint → Token verification: issues token (evidence: `apps/api/src/auth/dev-auth.controller.ts`)
- Authorization guard → User resolution: resolves actor (evidence: `apps/api/src/authz/authz.ts`)
- Authorization guard → Permission rules: checks permission (evidence: `apps/api/src/authz/authz.ts`)
- Catalog routes → Catalog service: calls (evidence: `apps/api/src/catalog/catalog.controller.ts`)
- Catalog service → Prisma access: uses persistence (evidence: `apps/api/src/catalog/catalog.service.ts`)
- User resolution → Prisma access: upserts user (evidence: `apps/api/src/users/users.service.ts`)
- Prisma access → Database: accesses
- Worker runtime → Outbox relay: starts relay (evidence: `apps/worker/src/main.ts`)
- Worker runtime → Event dispatch: dispatches jobs (evidence: `apps/worker/src/main.ts`)
- Worker runtime → Redis job queue: creates worker and queue (evidence: `apps/worker/src/main.ts`)
- Outbox relay → Redis job queue: publishes jobs (evidence: `apps/worker/src/relay/relay.service.ts`)
- Outbox relay → Database: claims outbox events (evidence: `apps/worker/src/relay/relay.service.ts`)
- Outbox service → Database: writes events
