# diogobrazil/gestao-consulta-medica-api architecture

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

- Interactive diagram: https://gitdiagram.com/diogobrazil/gestao-consulta-medica-api
- Repository: https://github.com/diogobrazil/gestao-consulta-medica-api

## Overview

This repository is a REST API for medical-consultation management, but the visible runtime implements patient-user registration rather than consultation scheduling. The main flow is an HTTP POST route through the Express adapter and patient controller to a use case, which checks for an existing CPF and creates a patient record through Prisma. The tree also contains operator-creation modules and JWT/password providers, but their runtime wiring is not established by the excerpts. The graph reflects those modules without inventing connections; the Prisma schema is the available evidence for the persistence model.

Main entry points: [`src/app.ts`](https://github.com/diogobrazil/gestao-consulta-medica-api/blob/main/src/app.ts) (Application wiring), [`src/controllers/user-patient/CreateUserPatientController.ts`](https://github.com/diogobrazil/gestao-consulta-medica-api/blob/main/src/controllers/user-patient/CreateUserPatientController.ts) (Patient controller), [`src/adapters/server/ServerRouteAdapter.ts`](https://github.com/diogobrazil/gestao-consulta-medica-api/blob/main/src/adapters/server/ServerRouteAdapter.ts) (Express route adapter), [`src/routes/user-patient/UserPatientRoutes.ts`](https://github.com/diogobrazil/gestao-consulta-medica-api/blob/main/src/routes/user-patient/UserPatientRoutes.ts) (Patient routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_http["HTTP interface"]
  node_patient_routes["Patient routes"]
  node_route_adapter["Express route adapter"]
  node_http_contracts["HTTP contracts<br/>[IRoute.ts]"]
  node_app["Application wiring<br/>[app.ts]"]
end

subgraph group_patient["Patient registration"]
  node_patient_controller["Patient controller"]
  node_patient_dto["Patient DTO"]
  node_patient_usecase["Patient creation use case"]
end

subgraph group_operator["Operator accounts"]
  node_operator_routes["Operator routes"]
  node_operator_controller["Operator controller"]
  node_operator_dto["Operator DTO"]
  node_operator_usecase["Operator creation use case"]
end

subgraph group_infra["Persistence and providers"]
  node_patient_repository["Patient repository"]
  node_repository_contract["Patient repository contract"]
  node_prisma_client["Prisma client<br/>[index.ts]"]
  node_patient_database[("Patient database model<br/>[schema.prisma]")]
  node_password_provider["Password provider"]
  node_jwt_provider["JWT provider<br/>[JWTProvider.ts]"]
end

node_client(("API client"))

node_client -->|"POST patient"| node_patient_routes
node_patient_routes -->|"registers route"| node_route_adapter
node_patient_routes -->|"resolves controller"| node_patient_controller
node_app -->|"configures routes"| node_patient_routes
node_app -->|"creates adapter"| node_route_adapter
node_app -->|"registers dependency"| node_patient_controller
node_app -->|"registers dependency"| node_patient_usecase
node_app -->|"registers dependency"| node_patient_repository
node_app -->|"registers provider"| node_password_provider
node_app -->|"registers provider"| node_jwt_provider
node_route_adapter -->|"dispatches route"| node_http_contracts
node_route_adapter -->|"invokes handler"| node_patient_controller
node_patient_controller -->|"executes creation"| node_patient_usecase
node_patient_controller -->|"types request"| node_patient_dto
node_patient_usecase -->|"checks and creates"| node_patient_repository
node_patient_repository -->|"queries"| node_prisma_client
node_patient_repository -->|"implements"| node_repository_contract
node_prisma_client -.->|"persists records"| node_patient_database
node_operator_routes -->|"registers route"| node_route_adapter
node_operator_routes -->|"resolves controller"| node_patient_controller
node_operator_controller -->|"uses patient use case"| node_operator_usecase
node_operator_controller -->|"validates patient DTO"| node_operator_dto

click node_patient_routes "https://github.com/diogobrazil/gestao-consulta-medica-api/blob/main/src/routes/user-patient/UserPatientRoutes.ts"
click node_route_adapter "https://github.com/diogobrazil/gestao-consulta-medica-api/blob/main/src/adapters/server/ServerRouteAdapter.ts"
click node_http_contracts "https://github.com/diogobrazil/gestao-consulta-medica-api/blob/main/src/adapters/interfaces/server/IRoute.ts"
click node_app "https://github.com/diogobrazil/gestao-consulta-medica-api/blob/main/src/app.ts"
click node_patient_controller "https://github.com/diogobrazil/gestao-consulta-medica-api/blob/main/src/controllers/user-patient/CreateUserPatientController.ts"
click node_patient_dto "https://github.com/diogobrazil/gestao-consulta-medica-api/blob/main/src/dtos/users-patients/CreateUserPatientDTO.ts"
click node_patient_usecase "https://github.com/diogobrazil/gestao-consulta-medica-api/blob/main/src/usecases/user-patient/CreateUserPatientUseCase.ts"
click node_patient_repository "https://github.com/diogobrazil/gestao-consulta-medica-api/blob/main/src/repositories/user-patient/UserPatientRepository.ts"
click node_repository_contract "https://github.com/diogobrazil/gestao-consulta-medica-api/blob/main/src/repositories/user-patient/IUserPatientRepository.ts"
click node_prisma_client "https://github.com/diogobrazil/gestao-consulta-medica-api/blob/main/src/prisma/index.ts"
click node_patient_database "https://github.com/diogobrazil/gestao-consulta-medica-api/blob/main/prisma/schema.prisma"
click node_password_provider "https://github.com/diogobrazil/gestao-consulta-medica-api/blob/main/src/providers/PasswordProvider.ts"
click node_jwt_provider "https://github.com/diogobrazil/gestao-consulta-medica-api/blob/main/src/providers/JWTProvider.ts"
click node_operator_routes "https://github.com/diogobrazil/gestao-consulta-medica-api/blob/main/src/routes/user-operator/UserOperatorRoutes.ts"
click node_operator_controller "https://github.com/diogobrazil/gestao-consulta-medica-api/blob/main/src/controllers/user-operator/CreateUserOperatorController.ts"
click node_operator_dto "https://github.com/diogobrazil/gestao-consulta-medica-api/blob/main/src/dtos/users-operators/CreateUserOperatorDTO.ts"
click node_operator_usecase "https://github.com/diogobrazil/gestao-consulta-medica-api/blob/main/src/usecases/users-operator/CreateUserOperatorUseCase.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_patient_routes,node_route_adapter,node_http_contracts,node_app,node_client toneBlue
class node_patient_controller,node_patient_dto,node_patient_usecase toneAmber
class node_operator_routes,node_operator_controller,node_operator_dto,node_operator_usecase toneMint
class node_patient_repository,node_repository_contract,node_prisma_client,node_patient_database,node_password_provider,node_jwt_provider toneRose
```

## Components

### HTTP interface

- [Patient routes](https://github.com/diogobrazil/gestao-consulta-medica-api/blob/main/src/routes/user-patient/UserPatientRoutes.ts): `src/routes/user-patient/UserPatientRoutes.ts`
- [Express route adapter](https://github.com/diogobrazil/gestao-consulta-medica-api/blob/main/src/adapters/server/ServerRouteAdapter.ts): `src/adapters/server/ServerRouteAdapter.ts`
- [HTTP contracts](https://github.com/diogobrazil/gestao-consulta-medica-api/blob/main/src/adapters/interfaces/server/IRoute.ts): `src/adapters/interfaces/server/IRoute.ts`
- [Application wiring](https://github.com/diogobrazil/gestao-consulta-medica-api/blob/main/src/app.ts): `src/app.ts`

### Patient registration

- [Patient controller](https://github.com/diogobrazil/gestao-consulta-medica-api/blob/main/src/controllers/user-patient/CreateUserPatientController.ts): `src/controllers/user-patient/CreateUserPatientController.ts`
- [Patient DTO](https://github.com/diogobrazil/gestao-consulta-medica-api/blob/main/src/dtos/users-patients/CreateUserPatientDTO.ts): `src/dtos/users-patients/CreateUserPatientDTO.ts`
- [Patient creation use case](https://github.com/diogobrazil/gestao-consulta-medica-api/blob/main/src/usecases/user-patient/CreateUserPatientUseCase.ts): `src/usecases/user-patient/CreateUserPatientUseCase.ts`

### Operator accounts

- [Operator routes](https://github.com/diogobrazil/gestao-consulta-medica-api/blob/main/src/routes/user-operator/UserOperatorRoutes.ts): `src/routes/user-operator/UserOperatorRoutes.ts`
- [Operator controller](https://github.com/diogobrazil/gestao-consulta-medica-api/blob/main/src/controllers/user-operator/CreateUserOperatorController.ts): `src/controllers/user-operator/CreateUserOperatorController.ts`
- [Operator DTO](https://github.com/diogobrazil/gestao-consulta-medica-api/blob/main/src/dtos/users-operators/CreateUserOperatorDTO.ts): `src/dtos/users-operators/CreateUserOperatorDTO.ts`
- [Operator creation use case](https://github.com/diogobrazil/gestao-consulta-medica-api/blob/main/src/usecases/users-operator/CreateUserOperatorUseCase.ts): `src/usecases/users-operator/CreateUserOperatorUseCase.ts`

### Persistence and providers

- [Patient repository](https://github.com/diogobrazil/gestao-consulta-medica-api/blob/main/src/repositories/user-patient/UserPatientRepository.ts): `src/repositories/user-patient/UserPatientRepository.ts`
- [Patient repository contract](https://github.com/diogobrazil/gestao-consulta-medica-api/blob/main/src/repositories/user-patient/IUserPatientRepository.ts): `src/repositories/user-patient/IUserPatientRepository.ts`
- [Prisma client](https://github.com/diogobrazil/gestao-consulta-medica-api/blob/main/src/prisma/index.ts): `src/prisma/index.ts`
- [Patient database model](https://github.com/diogobrazil/gestao-consulta-medica-api/blob/main/prisma/schema.prisma): `prisma/schema.prisma`
- [Password provider](https://github.com/diogobrazil/gestao-consulta-medica-api/blob/main/src/providers/PasswordProvider.ts): `src/providers/PasswordProvider.ts`
- [JWT provider](https://github.com/diogobrazil/gestao-consulta-medica-api/blob/main/src/providers/JWTProvider.ts): `src/providers/JWTProvider.ts`

### Other components

- **API client**

## Connections

- API client → Patient routes: POST patient (evidence: `src/routes/user-patient/UserPatientRoutes.ts`)
- Patient routes → Express route adapter: registers route (evidence: `src/routes/user-patient/UserPatientRoutes.ts`)
- Patient routes → Patient controller: resolves controller (evidence: `src/routes/user-patient/UserPatientRoutes.ts`)
- Application wiring → Patient routes: configures routes (evidence: `src/app.ts`)
- Application wiring → Express route adapter: creates adapter (evidence: `src/app.ts`)
- Application wiring → Patient controller: registers dependency (evidence: `src/app.ts`)
- Application wiring → Patient creation use case: registers dependency (evidence: `src/app.ts`)
- Application wiring → Patient repository: registers dependency (evidence: `src/app.ts`)
- Application wiring → Password provider: registers provider (evidence: `src/app.ts`)
- Application wiring → JWT provider: registers provider (evidence: `src/app.ts`)
- Express route adapter → HTTP contracts: dispatches route (evidence: `src/adapters/server/ServerRouteAdapter.ts`)
- Express route adapter → Patient controller: invokes handler (evidence: `src/adapters/server/ServerRouteAdapter.ts`)
- Patient controller → Patient creation use case: executes creation (evidence: `src/controllers/user-patient/CreateUserPatientController.ts`)
- Patient controller → Patient DTO: types request (evidence: `src/controllers/user-patient/CreateUserPatientController.ts`)
- Patient creation use case → Patient repository: checks and creates (evidence: `src/usecases/user-patient/CreateUserPatientUseCase.ts`)
- Patient repository → Prisma client: queries (evidence: `src/repositories/user-patient/UserPatientRepository.ts`)
- Patient repository → Patient repository contract: implements (evidence: `src/repositories/user-patient/UserPatientRepository.ts`)
- Prisma client → Patient database model: persists records
- Operator routes → Express route adapter: registers route (evidence: `src/routes/user-operator/UserOperatorRoutes.ts`)
- Operator routes → Patient controller: resolves controller (evidence: `src/routes/user-operator/UserOperatorRoutes.ts`)
- Operator controller → Operator creation use case: uses patient use case (evidence: `src/controllers/user-operator/CreateUserOperatorController.ts`)
- Operator controller → Operator DTO: validates patient DTO (evidence: `src/controllers/user-operator/CreateUserOperatorController.ts`)
