# samuellopess03/distributed-medical-system architecture

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

- Interactive diagram: https://gitdiagram.com/samuellopess03/distributed-medical-system
- Repository: https://github.com/samuellopess03/distributed-medical-system

## Overview

Consulta-Medica-SD is a distributed clinic-appointment system with separate user, scheduling, payment, and notification services. The main workflow is a client request to schedule a consultation, handled by the scheduling API and gRPC service; it persists the appointment, requests payment, and sends notifications. Payment updates the appointment status and publishes further notifications. The README also describes user CRUD/authentication and insurance validation; no distinct insurance implementation is identifiable in the supplied tree. Some service wiring is unsampled, so uncertain links are omitted or marked dashed.

Main entry points: [`servico-agendamento/src/main/java/com/sd/servico_agendamento/service/AgendamentoService.java`](https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-agendamento/src/main/java/com/sd/servico_agendamento/service/AgendamentoService.java) (Appointment service), [`servico-usuario/user_service.py`](https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-usuario/user_service.py) (User service), [`servico-pagamentos/app/Http/Controllers/PayloadController.php`](https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-pagamentos/app/Http/Controllers/PayloadController.php) (Payment API), [`servico-agendamento/src/main/java/com/sd/servico_agendamento/controller/AgendamentoController.java`](https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-agendamento/src/main/java/com/sd/servico_agendamento/controller/AgendamentoController.java) (Scheduling API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_users["User management"]
  node_user_interface["User interface<br/>[user_interface.py]"]
  node_user_client["User client<br/>[user_client.py]"]
  node_user_service["User service<br/>[user_service.py]"]
  node_user_db_access["User database access<br/>[database.py]"]
  node_user_models["User models<br/>[models.py]"]
  node_user_store[("User store")]
  node_user_publisher["User event publisher"]
end

subgraph group_scheduling["Scheduling"]
  node_scheduler_api["Scheduling API"]
  node_grpc_client["gRPC client"]
  node_grpc_service["gRPC service"]
  node_appointment_service["Appointment service"]
  node_appointment_mapper["Appointment mapper"]
  node_appointment_entities["Consultation and slots<br/>[Consulta.java]"]
  node_appointment_status["Appointment status"]
  node_appointment_repo["Consultation repository"]
  node_slot_repo["Slot repository"]
  node_appointment_store[("Scheduling database")]
end

subgraph group_payments["Payments"]
  node_payment_client["Payment client"]
  node_payment_api["Payment API"]
  node_payment_model["Payment payload<br/>[Payload.php]"]
  node_payment_store[("Payment database")]
  node_payment_mq["Payment event publisher"]
end

subgraph group_notifications["Notifications"]
  node_notification_producer["Scheduling notifier"]
  node_notification_app["Notification consumer<br/>[index.js]"]
  node_notification_rabbit["RabbitMQ consumer<br/>[rabbitmq.js]"]
  node_email_service["Email service<br/>[emailService.js]"]
  node_email_config["Email configuration<br/>[config.js]"]
end

node_client(("Client"))
node_broker["RabbitMQ"]
node_smtp["SMTP server"]

node_client -.->|"uses"| node_user_interface
node_user_interface -.->|"calls"| node_user_client
node_user_client -.->|"sends requests"| node_user_service
node_user_service -->|"queries"| node_user_db_access
node_user_service -->|"uses"| node_user_models
node_user_db_access -->|"uses"| node_user_models
node_user_db_access -.->|"reads and writes"| node_user_store
node_user_service -->|"publishes events"| node_user_publisher
node_user_publisher -.->|"publishes"| node_broker
node_client -->|"requests"| node_scheduler_api
node_scheduler_api -->|"calls"| node_grpc_client
node_grpc_client -.->|"invokes"| node_grpc_service
node_grpc_service -->|"delegates"| node_appointment_service
node_grpc_service -->|"maps responses"| node_appointment_mapper
node_scheduler_api -->|"maps DTOs"| node_appointment_mapper
node_appointment_service -->|"queries and saves"| node_appointment_repo
node_appointment_service -->|"queries and saves"| node_slot_repo
node_appointment_repo -.->|"persists"| node_appointment_store
node_slot_repo -.->|"persists"| node_appointment_store
node_appointment_service -->|"creates and updates"| node_appointment_entities
node_appointment_service -->|"sets status"| node_appointment_status
node_appointment_service -->|"requests payment"| node_payment_client
node_payment_client -.->|"submits payment"| node_payment_api
node_payment_api -->|"creates and updates"| node_payment_model
node_payment_model -.->|"persists"| node_payment_store
node_payment_api -->|"publishes notices"| node_payment_mq
node_payment_mq -->|"publishes"| node_broker
node_payment_api -->|"updates status"| node_scheduler_api
node_appointment_service -->|"sends notices"| node_notification_producer
node_notification_producer -.->|"publishes"| node_broker
node_broker -.->|"delivers messages"| node_notification_rabbit
node_notification_app -->|"uses"| node_notification_rabbit
node_notification_app -->|"sends email"| node_email_service
node_notification_rabbit -->|"dispatches email"| node_email_service
node_email_service -->|"reads settings"| node_email_config
node_email_service -->|"sends mail"| node_smtp

click node_user_interface "https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-usuario/user_interface.py"
click node_user_client "https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-usuario/user_client.py"
click node_user_service "https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-usuario/user_service.py"
click node_user_db_access "https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-usuario/database.py"
click node_user_models "https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-usuario/models.py"
click node_user_publisher "https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-usuario/rabbitmq_publisher.py"
click node_scheduler_api "https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-agendamento/src/main/java/com/sd/servico_agendamento/controller/AgendamentoController.java"
click node_grpc_client "https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-agendamento/src/main/java/com/sd/servico_agendamento/grpc/AgendamentoGrpcClient.java"
click node_grpc_service "https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-agendamento/src/main/java/com/sd/servico_agendamento/grpc/AgendamentoGrpcService.java"
click node_appointment_service "https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-agendamento/src/main/java/com/sd/servico_agendamento/service/AgendamentoService.java"
click node_appointment_mapper "https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-agendamento/src/main/java/com/sd/servico_agendamento/mapper/AgendamentoMapper.java"
click node_appointment_entities "https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-agendamento/src/main/java/com/sd/servico_agendamento/model/Consulta.java"
click node_appointment_status "https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-agendamento/src/main/java/com/sd/servico_agendamento/model/StatusConsulta.java"
click node_appointment_repo "https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-agendamento/src/main/java/com/sd/servico_agendamento/repository/ConsultaRepository.java"
click node_slot_repo "https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-agendamento/src/main/java/com/sd/servico_agendamento/repository/HorarioRepository.java"
click node_payment_client "https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-agendamento/src/main/java/com/sd/servico_agendamento/client/PagamentoClient.java"
click node_payment_api "https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-pagamentos/app/Http/Controllers/PayloadController.php"
click node_payment_model "https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-pagamentos/app/Models/Payload.php"
click node_payment_mq "https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-pagamentos/app/Services/RabbitMQService.php"
click node_notification_producer "https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-agendamento/src/main/java/com/sd/servico_agendamento/messaging/NotificationProducer.java"
click node_notification_app "https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-notificacoes/src/index.js"
click node_notification_rabbit "https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-notificacoes/src/rabbitmq.js"
click node_email_service "https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-notificacoes/src/emailService.js"
click node_email_config "https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-notificacoes/src/config.js"

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_user_interface,node_user_client,node_user_service,node_user_db_access,node_user_models,node_user_store,node_user_publisher,node_client toneBlue
class node_scheduler_api,node_grpc_client,node_grpc_service,node_appointment_service,node_appointment_mapper,node_appointment_entities,node_appointment_status,node_appointment_repo,node_slot_repo,node_appointment_store toneAmber
class node_payment_client,node_payment_api,node_payment_model,node_payment_store,node_payment_mq,node_smtp toneMint
class node_notification_producer,node_notification_app,node_notification_rabbit,node_email_service,node_email_config toneRose
class node_broker toneIndigo
```

## Components

### User management

- [User interface](https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-usuario/user_interface.py): `servico-usuario/user_interface.py`
- [User client](https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-usuario/user_client.py): `servico-usuario/user_client.py`
- [User service](https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-usuario/user_service.py): `servico-usuario/user_service.py`
- [User database access](https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-usuario/database.py): `servico-usuario/database.py`
- [User models](https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-usuario/models.py): `servico-usuario/models.py`
- **User store**
- [User event publisher](https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-usuario/rabbitmq_publisher.py): `servico-usuario/rabbitmq_publisher.py`

### Scheduling

- [Scheduling API](https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-agendamento/src/main/java/com/sd/servico_agendamento/controller/AgendamentoController.java): `servico-agendamento/src/main/java/com/sd/servico_agendamento/controller/AgendamentoController.java`
- [gRPC client](https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-agendamento/src/main/java/com/sd/servico_agendamento/grpc/AgendamentoGrpcClient.java): `servico-agendamento/src/main/java/com/sd/servico_agendamento/grpc/AgendamentoGrpcClient.java`
- [gRPC service](https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-agendamento/src/main/java/com/sd/servico_agendamento/grpc/AgendamentoGrpcService.java): `servico-agendamento/src/main/java/com/sd/servico_agendamento/grpc/AgendamentoGrpcService.java`
- [Appointment service](https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-agendamento/src/main/java/com/sd/servico_agendamento/service/AgendamentoService.java): `servico-agendamento/src/main/java/com/sd/servico_agendamento/service/AgendamentoService.java`
- [Appointment mapper](https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-agendamento/src/main/java/com/sd/servico_agendamento/mapper/AgendamentoMapper.java): `servico-agendamento/src/main/java/com/sd/servico_agendamento/mapper/AgendamentoMapper.java`
- [Consultation and slots](https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-agendamento/src/main/java/com/sd/servico_agendamento/model/Consulta.java): `servico-agendamento/src/main/java/com/sd/servico_agendamento/model/Consulta.java`
- [Appointment status](https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-agendamento/src/main/java/com/sd/servico_agendamento/model/StatusConsulta.java): `servico-agendamento/src/main/java/com/sd/servico_agendamento/model/StatusConsulta.java`
- [Consultation repository](https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-agendamento/src/main/java/com/sd/servico_agendamento/repository/ConsultaRepository.java): `servico-agendamento/src/main/java/com/sd/servico_agendamento/repository/ConsultaRepository.java`
- [Slot repository](https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-agendamento/src/main/java/com/sd/servico_agendamento/repository/HorarioRepository.java): `servico-agendamento/src/main/java/com/sd/servico_agendamento/repository/HorarioRepository.java`
- **Scheduling database**

### Payments

- [Payment client](https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-agendamento/src/main/java/com/sd/servico_agendamento/client/PagamentoClient.java): `servico-agendamento/src/main/java/com/sd/servico_agendamento/client/PagamentoClient.java`
- [Payment API](https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-pagamentos/app/Http/Controllers/PayloadController.php): `servico-pagamentos/app/Http/Controllers/PayloadController.php`
- [Payment payload](https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-pagamentos/app/Models/Payload.php): `servico-pagamentos/app/Models/Payload.php`
- **Payment database**
- [Payment event publisher](https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-pagamentos/app/Services/RabbitMQService.php): `servico-pagamentos/app/Services/RabbitMQService.php`

### Notifications

- [Scheduling notifier](https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-agendamento/src/main/java/com/sd/servico_agendamento/messaging/NotificationProducer.java): `servico-agendamento/src/main/java/com/sd/servico_agendamento/messaging/NotificationProducer.java`
- [Notification consumer](https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-notificacoes/src/index.js): `servico-notificacoes/src/index.js`
- [RabbitMQ consumer](https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-notificacoes/src/rabbitmq.js): `servico-notificacoes/src/rabbitmq.js`
- [Email service](https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-notificacoes/src/emailService.js): `servico-notificacoes/src/emailService.js`
- [Email configuration](https://github.com/samuellopess03/distributed-medical-system/blob/main/servico-notificacoes/src/config.js): `servico-notificacoes/src/config.js`

### Other components

- **Client**
- **RabbitMQ**
- **SMTP server**

## Connections

- Client → User interface: uses
- User interface → User client: calls
- User client → User service: sends requests
- User service → User database access: queries (evidence: `servico-usuario/user_service.py`)
- User service → User models: uses (evidence: `servico-usuario/user_service.py`)
- User database access → User models: uses (evidence: `servico-usuario/database.py`)
- User database access → User store: reads and writes
- User service → User event publisher: publishes events (evidence: `servico-usuario/user_service.py`)
- User event publisher → RabbitMQ: publishes (evidence: `README.md`)
- Client → Scheduling API: requests (evidence: `servico-agendamento/src/main/java/com/sd/servico_agendamento/controller/AgendamentoController.java`)
- Scheduling API → gRPC client: calls (evidence: `servico-agendamento/src/main/java/com/sd/servico_agendamento/controller/AgendamentoController.java`)
- gRPC client → gRPC service: invokes
- gRPC service → Appointment service: delegates (evidence: `servico-agendamento/src/main/java/com/sd/servico_agendamento/grpc/AgendamentoGrpcService.java`)
- gRPC service → Appointment mapper: maps responses (evidence: `servico-agendamento/src/main/java/com/sd/servico_agendamento/grpc/AgendamentoGrpcService.java`)
- Scheduling API → Appointment mapper: maps DTOs (evidence: `servico-agendamento/src/main/java/com/sd/servico_agendamento/controller/AgendamentoController.java`)
- Appointment service → Consultation repository: queries and saves (evidence: `servico-agendamento/src/main/java/com/sd/servico_agendamento/service/AgendamentoService.java`)
- Appointment service → Slot repository: queries and saves (evidence: `servico-agendamento/src/main/java/com/sd/servico_agendamento/service/AgendamentoService.java`)
- Consultation repository → Scheduling database: persists
- Slot repository → Scheduling database: persists
- Appointment service → Consultation and slots: creates and updates (evidence: `servico-agendamento/src/main/java/com/sd/servico_agendamento/service/AgendamentoService.java`)
- Appointment service → Appointment status: sets status (evidence: `servico-agendamento/src/main/java/com/sd/servico_agendamento/service/AgendamentoService.java`)
- Appointment service → Payment client: requests payment (evidence: `servico-agendamento/src/main/java/com/sd/servico_agendamento/service/AgendamentoService.java`)
- Payment client → Payment API: submits payment
- Payment API → Payment payload: creates and updates (evidence: `servico-pagamentos/app/Http/Controllers/PayloadController.php`)
- Payment payload → Payment database: persists
- Payment API → Payment event publisher: publishes notices (evidence: `servico-pagamentos/app/Http/Controllers/PayloadController.php`)
- Payment event publisher → RabbitMQ: publishes
- Payment API → Scheduling API: updates status (evidence: `servico-pagamentos/app/Http/Controllers/PayloadController.php`)
- Appointment service → Scheduling notifier: sends notices (evidence: `servico-agendamento/src/main/java/com/sd/servico_agendamento/service/AgendamentoService.java`)
- Scheduling notifier → RabbitMQ: publishes
- RabbitMQ → RabbitMQ consumer: delivers messages (evidence: `README.md`)
- Notification consumer → RabbitMQ consumer: uses (evidence: `servico-notificacoes/src/index.js`)
- Notification consumer → Email service: sends email (evidence: `servico-notificacoes/src/index.js`)
- RabbitMQ consumer → Email service: dispatches email (evidence: `servico-notificacoes/src/rabbitmq.js`)
- Email service → Email configuration: reads settings (evidence: `servico-notificacoes/src/emailService.js`)
- Email service → SMTP server: sends mail (evidence: `servico-notificacoes/src/emailService.js`)
