# regianleopoldo/agenda-facil-backend architecture

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

- Interactive diagram: https://gitdiagram.com/regianleopoldo/agenda-facil-backend
- Repository: https://github.com/regianleopoldo/agenda-facil-backend

## Overview

Agenda Fácil is an Express API for user authentication, appointments, notifications, and email reminders. The main workflow is frontend requests entering through the server, then reaching authenticated domain routes and PostgreSQL-backed operations; a server-started scheduler separately checks pending appointments and sends reminders. The excerpts show route-to-middleware and service dependencies, but not the Prisma schema or the internals of the Google-auth helper. Relationships for database access and the documented frontend integration are therefore grounded in the README where applicable.

Main entry points: [`src/server.ts`](https://github.com/regianleopoldo/agenda-facil-backend/blob/main/src/server.ts) (Express server), [`src/lib/prisma.ts`](https://github.com/regianleopoldo/agenda-facil-backend/blob/main/src/lib/prisma.ts) (Prisma client), [`src/routes/auth.ts`](https://github.com/regianleopoldo/agenda-facil-backend/blob/main/src/routes/auth.ts) (Google sign-in route), [`src/routes/compromissos.ts`](https://github.com/regianleopoldo/agenda-facil-backend/blob/main/src/routes/compromissos.ts) (Appointment routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and routing"]
  node_server["Express server<br/>[server.ts]"]
end

subgraph group_identity["Authentication"]
  node_auth_route["Google sign-in route<br/>[auth.ts]"]
  node_auth_middleware["JWT middleware<br/>[auth.ts]"]
end

subgraph group_domain["Appointment data"]
  node_appointments["Appointment routes<br/>[compromissos.ts]"]
  node_notifications["Notification routes<br/>[notificacoes.ts]"]
  node_prisma_client["Prisma client<br/>[prisma.ts]"]
  node_schema["Data model<br/>[schema.prisma]"]
  node_postgres[("PostgreSQL")]
end

subgraph group_reminders["Reminder delivery"]
  node_scheduler["Reminder scheduler"]
  node_reminder_check["Reminder checks<br/>[lembrete.ts]"]
  node_email_service["Email sender<br/>[email.ts]"]
end

node_frontend(("Frontend client"))
node_resend["Resend email service"]
node_google["Google identity"]

node_frontend -->|"calls API"| node_server
node_server -->|"mounts"| node_auth_route
node_server -->|"mounts"| node_appointments
node_server -->|"mounts"| node_notifications
node_server -->|"starts"| node_scheduler
node_auth_route -->|"verifies token"| node_google
node_auth_route -->|"reads and creates user"| node_prisma_client
node_appointments -->|"requires authentication"| node_auth_middleware
node_notifications -->|"requires authentication"| node_auth_middleware
node_appointments -->|"reads and writes"| node_prisma_client
node_notifications -->|"reads and writes"| node_prisma_client
node_scheduler -->|"runs checks"| node_reminder_check
node_reminder_check -->|"queries and updates"| node_prisma_client
node_reminder_check -->|"sends reminder"| node_email_service
node_email_service -->|"sends email"| node_resend
node_prisma_client -.->|"accesses database"| node_postgres
node_schema -.->|"models database"| node_postgres

click node_server "https://github.com/regianleopoldo/agenda-facil-backend/blob/main/src/server.ts"
click node_auth_route "https://github.com/regianleopoldo/agenda-facil-backend/blob/main/src/routes/auth.ts"
click node_auth_middleware "https://github.com/regianleopoldo/agenda-facil-backend/blob/main/src/middleware/auth.ts"
click node_appointments "https://github.com/regianleopoldo/agenda-facil-backend/blob/main/src/routes/compromissos.ts"
click node_notifications "https://github.com/regianleopoldo/agenda-facil-backend/blob/main/src/routes/notificacoes.ts"
click node_prisma_client "https://github.com/regianleopoldo/agenda-facil-backend/blob/main/src/lib/prisma.ts"
click node_schema "https://github.com/regianleopoldo/agenda-facil-backend/blob/main/prisma/schema.prisma"
click node_scheduler "https://github.com/regianleopoldo/agenda-facil-backend/blob/main/src/services/lembreteScheduler.ts"
click node_reminder_check "https://github.com/regianleopoldo/agenda-facil-backend/blob/main/src/services/lembrete.ts"
click node_email_service "https://github.com/regianleopoldo/agenda-facil-backend/blob/main/src/services/email.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_server,node_frontend toneBlue
class node_auth_route,node_auth_middleware toneAmber
class node_appointments,node_notifications,node_prisma_client,node_schema,node_postgres toneMint
class node_scheduler,node_reminder_check,node_email_service toneRose
class node_resend,node_google toneIndigo
```

## Components

### API and routing

- [Express server](https://github.com/regianleopoldo/agenda-facil-backend/blob/main/src/server.ts): `src/server.ts`

### Authentication

- [Google sign-in route](https://github.com/regianleopoldo/agenda-facil-backend/blob/main/src/routes/auth.ts): `src/routes/auth.ts`
- [JWT middleware](https://github.com/regianleopoldo/agenda-facil-backend/blob/main/src/middleware/auth.ts): `src/middleware/auth.ts`

### Appointment data

- [Appointment routes](https://github.com/regianleopoldo/agenda-facil-backend/blob/main/src/routes/compromissos.ts): `src/routes/compromissos.ts`
- [Notification routes](https://github.com/regianleopoldo/agenda-facil-backend/blob/main/src/routes/notificacoes.ts): `src/routes/notificacoes.ts`
- [Prisma client](https://github.com/regianleopoldo/agenda-facil-backend/blob/main/src/lib/prisma.ts): `src/lib/prisma.ts`
- [Data model](https://github.com/regianleopoldo/agenda-facil-backend/blob/main/prisma/schema.prisma): `prisma/schema.prisma`
- **PostgreSQL**

### Reminder delivery

- [Reminder scheduler](https://github.com/regianleopoldo/agenda-facil-backend/blob/main/src/services/lembreteScheduler.ts): `src/services/lembreteScheduler.ts`
- [Reminder checks](https://github.com/regianleopoldo/agenda-facil-backend/blob/main/src/services/lembrete.ts): `src/services/lembrete.ts`
- [Email sender](https://github.com/regianleopoldo/agenda-facil-backend/blob/main/src/services/email.ts): `src/services/email.ts`

### Other components

- **Frontend client**
- **Resend email service**
- **Google identity**

## Connections

- Frontend client → Express server: calls API (evidence: `README.md`)
- Express server → Google sign-in route: mounts (evidence: `src/server.ts`)
- Express server → Appointment routes: mounts (evidence: `src/server.ts`)
- Express server → Notification routes: mounts (evidence: `src/server.ts`)
- Express server → Reminder scheduler: starts (evidence: `src/server.ts`)
- Google sign-in route → Google identity: verifies token (evidence: `src/routes/auth.ts`)
- Google sign-in route → Prisma client: reads and creates user (evidence: `src/routes/auth.ts`)
- Appointment routes → JWT middleware: requires authentication (evidence: `src/routes/compromissos.ts`)
- Notification routes → JWT middleware: requires authentication (evidence: `src/routes/notificacoes.ts`)
- Appointment routes → Prisma client: reads and writes (evidence: `src/routes/compromissos.ts`)
- Notification routes → Prisma client: reads and writes (evidence: `src/routes/notificacoes.ts`)
- Reminder scheduler → Reminder checks: runs checks (evidence: `src/services/lembreteScheduler.ts`)
- Reminder checks → Prisma client: queries and updates (evidence: `src/services/lembrete.ts`)
- Reminder checks → Email sender: sends reminder (evidence: `src/services/lembrete.ts`)
- Email sender → Resend email service: sends email (evidence: `src/services/email.ts`)
- Prisma client → PostgreSQL: accesses database (evidence: `README.md`)
- Data model → PostgreSQL: models database (evidence: `README.md`)
