# igoranjos/consultorio_m-dico architecture

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

- Interactive diagram: https://gitdiagram.com/igoranjos/consultorio_m-dico
- Repository: https://github.com/igoranjos/consultorio_m-dico

## Overview

Consultorio is a clinic-management system with both an MVC web interface and a REST API. The main workflow is a logged-in user managing appointments: the web controller delegates to an HTTP client service, which calls the API; application logic persists the consultation and triggers email and calendar actions. The tree also shows patient, doctor, service, specialty, user, and email capabilities, plus a background worker. Some wiring and unsampled endpoint behavior are unknown, so uncertain links are omitted or marked unverified.

Main entry points: [`Consultorio.Application/Services/ConsultService.cs`](https://github.com/igoranjos/consultorio_m-dico/blob/master/Consultorio.Application/Services/ConsultService.cs) (Appointment workflow), [`Consultorio.Web/Services`](https://github.com/igoranjos/consultorio_m-dico/tree/master/Consultorio.Web/Services) (API client services), [`Consultorio.WorkerService/Worker.cs`](https://github.com/igoranjos/consultorio_m-dico/blob/master/Consultorio.WorkerService/Worker.cs) (Email background worker), [`Consultorio.Application/Email/SeedEmail.cs`](https://github.com/igoranjos/consultorio_m-dico/blob/master/Consultorio.Application/Email/SeedEmail.cs) (Email delivery service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_webscreens["Clinic screens<br/>[Controllers]"]
  node_webclient["API client services<br/>[Services]"]
  node_session["User session<br/>[Helper]"]
end

subgraph group_api["API"]
  node_apiappointments["Appointment API"]
  node_apiusers["User and login API<br/>[UserController.cs]"]
  node_otherapi["Other CRUD APIs<br/>[Controllers]"]
end

subgraph group_application["Application services"]
  node_consult["Appointment workflow<br/>[ConsultService.cs]"]
  node_crudservices["Domain CRUD services<br/>[Services]"]
  node_calendar["Calendar integration"]
  node_emailseed["Email delivery service<br/>[SeedEmail.cs]"]
  node_token["JWT generation<br/>[TokenService.cs]"]
end

subgraph group_data["Persistence"]
  node_repositories["Data repositories<br/>[Repository]"]
  node_db[("Clinic database context")]
  node_emailstore["Email templates<br/>[EmailRepository.cs]"]
end

subgraph group_worker["Background email"]
  node_workerhost["Worker host<br/>[Program.cs]"]
  node_worker["Email background worker<br/>[Worker.cs]"]
end

node_user(("Clinic user"))
node_google["Google Calendar"]
node_mailprovider["Email provider"]

node_user -->|"uses"| node_webscreens
node_webscreens -->|"delegates to"| node_webclient
node_webclient -->|"reads token"| node_session
node_webclient -->|"HTTP requests"| node_apiappointments
node_apiappointments -.->|"dispatches CRUD"| node_consult
node_apiusers -->|"generates token"| node_token
node_apiusers -.->|"dispatches CRUD"| node_crudservices
node_otherapi -.->|"dispatches CRUD"| node_crudservices
node_consult -->|"reads and writes"| node_repositories
node_consult -->|"loads template"| node_emailstore
node_consult -->|"sends email"| node_emailseed
node_consult -->|"manages events"| node_calendar
node_repositories -->|"queries"| node_db
node_calendar -.->|"calendar API"| node_google
node_emailseed -.->|"delivers email"| node_mailprovider
node_workerhost -->|"hosts"| node_worker
node_worker -->|"uses"| node_emailseed
node_worker -.->|"accesses data"| node_db

click node_webscreens "https://github.com/igoranjos/consultorio_m-dico/tree/master/Consultorio.Web/Controllers"
click node_webclient "https://github.com/igoranjos/consultorio_m-dico/tree/master/Consultorio.Web/Services"
click node_session "https://github.com/igoranjos/consultorio_m-dico/tree/master/Consultorio.Web/Helper"
click node_apiappointments "https://github.com/igoranjos/consultorio_m-dico/blob/master/Consultorio.API/Controllers/ConsultController.cs"
click node_apiusers "https://github.com/igoranjos/consultorio_m-dico/blob/master/Consultorio.API/Controllers/UserController.cs"
click node_otherapi "https://github.com/igoranjos/consultorio_m-dico/tree/master/Consultorio.API/Controllers"
click node_consult "https://github.com/igoranjos/consultorio_m-dico/blob/master/Consultorio.Application/Services/ConsultService.cs"
click node_crudservices "https://github.com/igoranjos/consultorio_m-dico/tree/master/Consultorio.Application/Services"
click node_calendar "https://github.com/igoranjos/consultorio_m-dico/blob/master/Consultorio.Application/Calendar/GoogleCalendarService.cs"
click node_emailseed "https://github.com/igoranjos/consultorio_m-dico/blob/master/Consultorio.Application/Email/SeedEmail.cs"
click node_token "https://github.com/igoranjos/consultorio_m-dico/blob/master/Consultorio.Application/Services/Token/TokenService.cs"
click node_repositories "https://github.com/igoranjos/consultorio_m-dico/tree/master/Consultorio.Data/Repository"
click node_db "https://github.com/igoranjos/consultorio_m-dico/blob/master/Consultorio.Data/ConsultorioDbContext.cs"
click node_emailstore "https://github.com/igoranjos/consultorio_m-dico/blob/master/Consultorio.Data/Repository/EmailRepository.cs"
click node_workerhost "https://github.com/igoranjos/consultorio_m-dico/blob/master/Consultorio.WorkerService/Program.cs"
click node_worker "https://github.com/igoranjos/consultorio_m-dico/blob/master/Consultorio.WorkerService/Worker.cs"

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_webscreens,node_webclient,node_session,node_user toneBlue
class node_apiappointments,node_apiusers,node_otherapi toneAmber
class node_consult,node_crudservices,node_calendar,node_emailseed,node_token toneMint
class node_repositories,node_db,node_emailstore toneRose
class node_workerhost,node_worker,node_google,node_mailprovider toneIndigo
```

## Components

### Web interface

- [Clinic screens](https://github.com/igoranjos/consultorio_m-dico/tree/master/Consultorio.Web/Controllers): `Consultorio.Web/Controllers`
- [API client services](https://github.com/igoranjos/consultorio_m-dico/tree/master/Consultorio.Web/Services): `Consultorio.Web/Services`
- [User session](https://github.com/igoranjos/consultorio_m-dico/tree/master/Consultorio.Web/Helper): `Consultorio.Web/Helper`

### API

- [Appointment API](https://github.com/igoranjos/consultorio_m-dico/blob/master/Consultorio.API/Controllers/ConsultController.cs): `Consultorio.API/Controllers/ConsultController.cs`
- [User and login API](https://github.com/igoranjos/consultorio_m-dico/blob/master/Consultorio.API/Controllers/UserController.cs): `Consultorio.API/Controllers/UserController.cs`
- [Other CRUD APIs](https://github.com/igoranjos/consultorio_m-dico/tree/master/Consultorio.API/Controllers): `Consultorio.API/Controllers`

### Application services

- [Appointment workflow](https://github.com/igoranjos/consultorio_m-dico/blob/master/Consultorio.Application/Services/ConsultService.cs): `Consultorio.Application/Services/ConsultService.cs`
- [Domain CRUD services](https://github.com/igoranjos/consultorio_m-dico/tree/master/Consultorio.Application/Services): `Consultorio.Application/Services`
- [Calendar integration](https://github.com/igoranjos/consultorio_m-dico/blob/master/Consultorio.Application/Calendar/GoogleCalendarService.cs): `Consultorio.Application/Calendar/GoogleCalendarService.cs`
- [Email delivery service](https://github.com/igoranjos/consultorio_m-dico/blob/master/Consultorio.Application/Email/SeedEmail.cs): `Consultorio.Application/Email/SeedEmail.cs`
- [JWT generation](https://github.com/igoranjos/consultorio_m-dico/blob/master/Consultorio.Application/Services/Token/TokenService.cs): `Consultorio.Application/Services/Token/TokenService.cs`

### Persistence

- [Data repositories](https://github.com/igoranjos/consultorio_m-dico/tree/master/Consultorio.Data/Repository): `Consultorio.Data/Repository`
- [Clinic database context](https://github.com/igoranjos/consultorio_m-dico/blob/master/Consultorio.Data/ConsultorioDbContext.cs): `Consultorio.Data/ConsultorioDbContext.cs`
- [Email templates](https://github.com/igoranjos/consultorio_m-dico/blob/master/Consultorio.Data/Repository/EmailRepository.cs): `Consultorio.Data/Repository/EmailRepository.cs`

### Background email

- [Worker host](https://github.com/igoranjos/consultorio_m-dico/blob/master/Consultorio.WorkerService/Program.cs): `Consultorio.WorkerService/Program.cs`
- [Email background worker](https://github.com/igoranjos/consultorio_m-dico/blob/master/Consultorio.WorkerService/Worker.cs): `Consultorio.WorkerService/Worker.cs`

### Other components

- **Clinic user**
- **Google Calendar**
- **Email provider**

## Connections

- Clinic user → Clinic screens: uses (evidence: `Consultorio.Web/Controllers/AtendimentoController.cs`)
- Clinic screens → API client services: delegates to (evidence: `Consultorio.Web/Controllers/AtendimentoController.cs`)
- API client services → User session: reads token (evidence: `Consultorio.Web/Services/AtendimentoService.cs`)
- API client services → Appointment API: HTTP requests (evidence: `Consultorio.Web/Services/AtendimentoService.cs`)
- Appointment API → Appointment workflow: dispatches CRUD
- User and login API → JWT generation: generates token (evidence: `Consultorio.API/Controllers/UserController.cs`)
- User and login API → Domain CRUD services: dispatches CRUD (evidence: `Consultorio.API/Controllers/UserController.cs`)
- Other CRUD APIs → Domain CRUD services: dispatches CRUD (evidence: `Consultorio.API/Controllers/UserController.cs`)
- Appointment workflow → Data repositories: reads and writes (evidence: `Consultorio.Application/Services/ConsultService.cs`)
- Appointment workflow → Email templates: loads template (evidence: `Consultorio.Application/Services/ConsultService.cs`)
- Appointment workflow → Email delivery service: sends email (evidence: `Consultorio.Application/Services/ConsultService.cs`)
- Appointment workflow → Calendar integration: manages events (evidence: `Consultorio.Application/Services/ConsultService.cs`)
- Data repositories → Clinic database context: queries (evidence: `Consultorio.Data/Repository/ConsultRepository.cs`)
- Calendar integration → Google Calendar: calendar API
- Email delivery service → Email provider: delivers email
- Worker host → Email background worker: hosts (evidence: `Consultorio.WorkerService/Program.cs`)
- Email background worker → Email delivery service: uses
- Email background worker → Clinic database context: accesses data (evidence: `Consultorio.WorkerService/Worker.cs`)
