# arthurpc03/newgobarber architecture

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

- Interactive diagram: https://gitdiagram.com/arthurpc03/newgobarber
- Repository: https://github.com/arthurpc03/newgobarber

## Overview

GoBarber is an appointment-scheduling API for customers and service providers. Its HTTP server exposes user registration, authentication, profile/avatar management, provider discovery, appointment booking, and provider appointment/availability views. Appointment services depend on repositories and TypeORM-backed entities; user authentication also uses a hash provider. The README documents provider appointment management and cancellation visibility, though the available tree shows no cancellation-specific component. Several implementation links are omitted because source excerpts do not establish their callers.

Main entry points: [`src/modules/users/infra/http/routes/users.routes.ts`](https://github.com/arthurpc03/newgobarber/blob/master/src/modules/users/infra/http/routes/users.routes.ts) (User routes), [`src/shared/infra/http/routes/index.ts`](https://github.com/arthurpc03/newgobarber/blob/master/src/shared/infra/http/routes/index.ts) (Route registry), [`src/modules/appointments/infra/http/routes/providers.routes.ts`](https://github.com/arthurpc03/newgobarber/blob/master/src/modules/appointments/infra/http/routes/providers.routes.ts) (Provider routes), [`src/modules/appointments/services`](https://github.com/arthurpc03/newgobarber/tree/master/src/modules/appointments/services) (Appointment services)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_http["HTTP API"]
  node_server["Express server<br/>[server.ts]"]
  node_routes["Route registry<br/>[index.ts]"]
  node_appointment_routes["Appointment routes"]
  node_provider_routes["Provider routes"]
  node_user_routes["User routes<br/>[users.routes.ts]"]
  node_profile_routes["Profile routes<br/>[profile.routes.ts]"]
end

subgraph group_appointments["Scheduling"]
  node_booking["Book appointment"]
  node_provider_appts["Provider appointments"]
  node_availability["Availability lookup"]
  node_month_availability["Monthly availability"]
  node_provider_list["Provider discovery"]
  node_appointment_service["Appointment services"]
end

subgraph group_users["Accounts"]
  node_user_controller["User registration<br/>[UsersController.ts]"]
  node_sessions["Authentication"]
  node_profile["Profile management"]
  node_avatar["Avatar management"]
  node_auth_middleware["Authentication guard"]
  node_user_services["Account services"]
end

subgraph group_infra["Persistence and providers"]
  node_appointment_repo["Appointment repository"]
  node_appointment_entity[("Appointment records<br/>[Appointment.ts]")]
  node_user_repo["User repository<br/>[UsersRepository.ts]"]
  node_user_entity[("User records<br/>[User.ts]")]
  node_hash_provider["Password hashing"]
  node_storage["File storage"]
  node_notification["Notifications"]
  node_notification_record[("Notification records<br/>[Notification.ts]")]
end

node_customer(("Customer"))
node_provider(("Service provider"))

node_server -->|"mounts routes"| node_routes
node_routes -.->|"registers"| node_appointment_routes
node_routes -.->|"registers"| node_provider_routes
node_routes -.->|"registers"| node_user_routes
node_routes -.->|"registers"| node_profile_routes
node_customer -.->|"requests booking"| node_appointment_routes
node_appointment_routes -->|"routes to"| node_booking
node_provider -->|"requests schedules"| node_provider_routes
node_provider_routes -->|"routes to"| node_provider_list
node_provider_routes -->|"routes to"| node_availability
node_provider_routes -->|"routes to"| node_month_availability
node_appointment_routes -->|"routes to"| node_provider_appts
node_booking -.->|"invokes"| node_appointment_service
node_provider_appts -->|"invokes"| node_appointment_service
node_availability -->|"invokes"| node_appointment_service
node_appointment_service -.->|"uses"| node_appointment_repo
node_appointment_repo -.->|"persists"| node_appointment_entity
node_customer -->|"registers account"| node_user_routes
node_user_routes -->|"routes to"| node_user_controller
node_profile_routes -->|"routes to"| node_profile
node_profile_routes -->|"guards access"| node_auth_middleware
node_user_routes -->|"routes to"| node_avatar
node_user_routes -->|"guards avatar"| node_auth_middleware
node_user_routes -.->|"routes to"| node_sessions
node_user_controller -.->|"invokes"| node_user_services
node_profile -->|"resolves services"| node_user_services
node_sessions -.->|"invokes"| node_user_services
node_user_services -.->|"uses"| node_user_repo
node_user_repo -.->|"reads and writes"| node_user_entity
node_user_services -->|"checks passwords"| node_hash_provider
node_avatar -.->|"stores avatar"| node_storage
node_appointment_service -.->|"notifies"| node_notification
node_notification -.->|"stores"| node_notification_record

click node_server "https://github.com/arthurpc03/newgobarber/blob/master/src/shared/infra/http/server.ts"
click node_routes "https://github.com/arthurpc03/newgobarber/blob/master/src/shared/infra/http/routes/index.ts"
click node_appointment_routes "https://github.com/arthurpc03/newgobarber/blob/master/src/modules/appointments/infra/http/routes/appointments.routes.ts"
click node_provider_routes "https://github.com/arthurpc03/newgobarber/blob/master/src/modules/appointments/infra/http/routes/providers.routes.ts"
click node_user_routes "https://github.com/arthurpc03/newgobarber/blob/master/src/modules/users/infra/http/routes/users.routes.ts"
click node_profile_routes "https://github.com/arthurpc03/newgobarber/blob/master/src/modules/users/infra/http/routes/profile.routes.ts"
click node_booking "https://github.com/arthurpc03/newgobarber/blob/master/src/modules/appointments/infra/http/controllers/AppointmentsController.ts"
click node_provider_appts "https://github.com/arthurpc03/newgobarber/blob/master/src/modules/appointments/infra/http/controllers/ProviderAppointmentsController.ts"
click node_availability "https://github.com/arthurpc03/newgobarber/blob/master/src/modules/appointments/infra/http/controllers/ProviderDayAvailabilityController.ts"
click node_month_availability "https://github.com/arthurpc03/newgobarber/blob/master/src/modules/appointments/infra/http/controllers/ProviderMonthAvailabilityController.ts"
click node_provider_list "https://github.com/arthurpc03/newgobarber/blob/master/src/modules/appointments/infra/http/controllers/ProvidersController.ts"
click node_appointment_service "https://github.com/arthurpc03/newgobarber/tree/master/src/modules/appointments/services"
click node_appointment_repo "https://github.com/arthurpc03/newgobarber/blob/master/src/modules/appointments/infra/typeorm/repositories/AppoitmentsRepository.ts"
click node_appointment_entity "https://github.com/arthurpc03/newgobarber/blob/master/src/modules/appointments/infra/typeorm/entities/Appointment.ts"
click node_user_controller "https://github.com/arthurpc03/newgobarber/blob/master/src/modules/users/infra/http/controllers/UsersController.ts"
click node_sessions "https://github.com/arthurpc03/newgobarber/blob/master/src/modules/users/infra/http/controllers/SessionsController.ts"
click node_profile "https://github.com/arthurpc03/newgobarber/blob/master/src/modules/users/infra/http/controllers/ProfileController.ts"
click node_avatar "https://github.com/arthurpc03/newgobarber/blob/master/src/modules/users/infra/http/controllers/UserAvatarController.ts"
click node_auth_middleware "https://github.com/arthurpc03/newgobarber/blob/master/src/modules/users/infra/http/middlewares/ensureAuthenticated.ts"
click node_user_services "https://github.com/arthurpc03/newgobarber/tree/master/src/modules/users/services"
click node_user_repo "https://github.com/arthurpc03/newgobarber/blob/master/src/modules/users/infra/typeorm/repositories/UsersRepository.ts"
click node_user_entity "https://github.com/arthurpc03/newgobarber/blob/master/src/modules/users/infra/typeorm/entities/User.ts"
click node_hash_provider "https://github.com/arthurpc03/newgobarber/blob/master/src/modules/users/providers/HashProvider/implementations/BCryptHashProvider.ts"
click node_storage "https://github.com/arthurpc03/newgobarber/tree/master/src/shared/container/providers/StorageProvider"
click node_notification "https://github.com/arthurpc03/newgobarber/blob/master/src/modules/notifications/infra/typeorm/repositories/NotificationsRepository.ts"
click node_notification_record "https://github.com/arthurpc03/newgobarber/blob/master/src/modules/notifications/infra/typeorm/schemas/Notification.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_routes,node_appointment_routes,node_provider_routes,node_user_routes,node_profile_routes toneBlue
class node_booking,node_provider_appts,node_availability,node_month_availability,node_provider_list,node_appointment_service toneAmber
class node_user_controller,node_sessions,node_profile,node_avatar,node_auth_middleware,node_user_services toneMint
class node_appointment_repo,node_appointment_entity,node_user_repo,node_user_entity,node_hash_provider,node_storage,node_notification,node_notification_record toneRose
class node_customer,node_provider toneIndigo
```

## Components

### HTTP API

- [Express server](https://github.com/arthurpc03/newgobarber/blob/master/src/shared/infra/http/server.ts): `src/shared/infra/http/server.ts`
- [Route registry](https://github.com/arthurpc03/newgobarber/blob/master/src/shared/infra/http/routes/index.ts): `src/shared/infra/http/routes/index.ts`
- [Appointment routes](https://github.com/arthurpc03/newgobarber/blob/master/src/modules/appointments/infra/http/routes/appointments.routes.ts): `src/modules/appointments/infra/http/routes/appointments.routes.ts`
- [Provider routes](https://github.com/arthurpc03/newgobarber/blob/master/src/modules/appointments/infra/http/routes/providers.routes.ts): `src/modules/appointments/infra/http/routes/providers.routes.ts`
- [User routes](https://github.com/arthurpc03/newgobarber/blob/master/src/modules/users/infra/http/routes/users.routes.ts): `src/modules/users/infra/http/routes/users.routes.ts`
- [Profile routes](https://github.com/arthurpc03/newgobarber/blob/master/src/modules/users/infra/http/routes/profile.routes.ts): `src/modules/users/infra/http/routes/profile.routes.ts`

### Scheduling

- [Book appointment](https://github.com/arthurpc03/newgobarber/blob/master/src/modules/appointments/infra/http/controllers/AppointmentsController.ts): `src/modules/appointments/infra/http/controllers/AppointmentsController.ts`
- [Provider appointments](https://github.com/arthurpc03/newgobarber/blob/master/src/modules/appointments/infra/http/controllers/ProviderAppointmentsController.ts): `src/modules/appointments/infra/http/controllers/ProviderAppointmentsController.ts`
- [Availability lookup](https://github.com/arthurpc03/newgobarber/blob/master/src/modules/appointments/infra/http/controllers/ProviderDayAvailabilityController.ts): `src/modules/appointments/infra/http/controllers/ProviderDayAvailabilityController.ts`
- [Monthly availability](https://github.com/arthurpc03/newgobarber/blob/master/src/modules/appointments/infra/http/controllers/ProviderMonthAvailabilityController.ts): `src/modules/appointments/infra/http/controllers/ProviderMonthAvailabilityController.ts`
- [Provider discovery](https://github.com/arthurpc03/newgobarber/blob/master/src/modules/appointments/infra/http/controllers/ProvidersController.ts): `src/modules/appointments/infra/http/controllers/ProvidersController.ts`
- [Appointment services](https://github.com/arthurpc03/newgobarber/tree/master/src/modules/appointments/services): `src/modules/appointments/services`

### Accounts

- [User registration](https://github.com/arthurpc03/newgobarber/blob/master/src/modules/users/infra/http/controllers/UsersController.ts): `src/modules/users/infra/http/controllers/UsersController.ts`
- [Authentication](https://github.com/arthurpc03/newgobarber/blob/master/src/modules/users/infra/http/controllers/SessionsController.ts): `src/modules/users/infra/http/controllers/SessionsController.ts`
- [Profile management](https://github.com/arthurpc03/newgobarber/blob/master/src/modules/users/infra/http/controllers/ProfileController.ts): `src/modules/users/infra/http/controllers/ProfileController.ts`
- [Avatar management](https://github.com/arthurpc03/newgobarber/blob/master/src/modules/users/infra/http/controllers/UserAvatarController.ts): `src/modules/users/infra/http/controllers/UserAvatarController.ts`
- [Authentication guard](https://github.com/arthurpc03/newgobarber/blob/master/src/modules/users/infra/http/middlewares/ensureAuthenticated.ts): `src/modules/users/infra/http/middlewares/ensureAuthenticated.ts`
- [Account services](https://github.com/arthurpc03/newgobarber/tree/master/src/modules/users/services): `src/modules/users/services`

### Persistence and providers

- [Appointment repository](https://github.com/arthurpc03/newgobarber/blob/master/src/modules/appointments/infra/typeorm/repositories/AppoitmentsRepository.ts): `src/modules/appointments/infra/typeorm/repositories/AppoitmentsRepository.ts`
- [Appointment records](https://github.com/arthurpc03/newgobarber/blob/master/src/modules/appointments/infra/typeorm/entities/Appointment.ts): `src/modules/appointments/infra/typeorm/entities/Appointment.ts`
- [User repository](https://github.com/arthurpc03/newgobarber/blob/master/src/modules/users/infra/typeorm/repositories/UsersRepository.ts): `src/modules/users/infra/typeorm/repositories/UsersRepository.ts`
- [User records](https://github.com/arthurpc03/newgobarber/blob/master/src/modules/users/infra/typeorm/entities/User.ts): `src/modules/users/infra/typeorm/entities/User.ts`
- [Password hashing](https://github.com/arthurpc03/newgobarber/blob/master/src/modules/users/providers/HashProvider/implementations/BCryptHashProvider.ts): `src/modules/users/providers/HashProvider/implementations/BCryptHashProvider.ts`
- [File storage](https://github.com/arthurpc03/newgobarber/tree/master/src/shared/container/providers/StorageProvider): `src/shared/container/providers/StorageProvider`
- [Notifications](https://github.com/arthurpc03/newgobarber/blob/master/src/modules/notifications/infra/typeorm/repositories/NotificationsRepository.ts): `src/modules/notifications/infra/typeorm/repositories/NotificationsRepository.ts`
- [Notification records](https://github.com/arthurpc03/newgobarber/blob/master/src/modules/notifications/infra/typeorm/schemas/Notification.ts): `src/modules/notifications/infra/typeorm/schemas/Notification.ts`

### Other components

- **Customer**
- **Service provider**

## Connections

- Express server → Route registry: mounts routes (evidence: `src/shared/infra/http/server.ts`)
- Route registry → Appointment routes: registers
- Route registry → Provider routes: registers
- Route registry → User routes: registers
- Route registry → Profile routes: registers
- Customer → Appointment routes: requests booking
- Appointment routes → Book appointment: routes to (evidence: `src/modules/appointments/infra/http/routes/appointments.routes.ts`)
- Service provider → Provider routes: requests schedules (evidence: `src/modules/appointments/infra/http/routes/providers.routes.ts`)
- Provider routes → Provider discovery: routes to (evidence: `src/modules/appointments/infra/http/routes/providers.routes.ts`)
- Provider routes → Availability lookup: routes to (evidence: `src/modules/appointments/infra/http/routes/providers.routes.ts`)
- Provider routes → Monthly availability: routes to (evidence: `src/modules/appointments/infra/http/routes/providers.routes.ts`)
- Appointment routes → Provider appointments: routes to (evidence: `src/modules/appointments/infra/http/routes/appointments.routes.ts`)
- Book appointment → Appointment services: invokes
- Provider appointments → Appointment services: invokes (evidence: `src/modules/appointments/infra/http/controllers/ProviderAppointmentsController.ts`)
- Availability lookup → Appointment services: invokes (evidence: `src/modules/appointments/infra/http/controllers/ProviderDayAvailabilityController.ts`)
- Appointment services → Appointment repository: uses
- Appointment repository → Appointment records: persists
- Customer → User routes: registers account (evidence: `src/modules/users/infra/http/routes/users.routes.ts`)
- User routes → User registration: routes to (evidence: `src/modules/users/infra/http/routes/users.routes.ts`)
- Profile routes → Profile management: routes to (evidence: `src/modules/users/infra/http/routes/profile.routes.ts`)
- Profile routes → Authentication guard: guards access (evidence: `src/modules/users/infra/http/routes/profile.routes.ts`)
- User routes → Avatar management: routes to (evidence: `src/modules/users/infra/http/routes/users.routes.ts`)
- User routes → Authentication guard: guards avatar (evidence: `src/modules/users/infra/http/routes/users.routes.ts`)
- User routes → Authentication: routes to
- User registration → Account services: invokes
- Profile management → Account services: resolves services (evidence: `src/modules/users/infra/http/controllers/ProfileController.ts`)
- Authentication → Account services: invokes
- Account services → User repository: uses
- User repository → User records: reads and writes
- Account services → Password hashing: checks passwords (evidence: `src/modules/users/services/AuthenticateUserService.ts`)
- Avatar management → File storage: stores avatar
- Appointment services → Notifications: notifies
- Notifications → Notification records: stores
