How erikvictorino/barbearia-node.js works
This is a Node.js/Express barbershop booking application. Customers register or sign in, browse services, request appointments, and view their bookings; administrators can review appointments and manage services. Password recovery is a separate email-and-token workflow. The source excerpts show the main route, controller, middleware, and model responsibilities; some feature details are documented only by the source index, so uncertain links are omitted.
Main entry points: app.js Express app · agendamentoController.js Booking controller · database.js MySQL connection · servicoRoutes.js Service routes
Components 27
Web application
- Express app
app.js - Booking routes
app/routes/homeRoutes.js - Authentication routes
app/routes/authRoutes.js - Service routes
app/routes/servicoRoutes.js - User routes
app/routes/userRoutes.js
Identity and access
- Authentication controller
app/controllers/authController.js - Client controller
app/controllers/clienteController.js - Token verification
app/middlewares/checkToken.js - User context
app/middlewares/checkUser.js - Role authorization
app/middlewares/checkFuncao.js - Login rate limit
app/middlewares/rateLimit.js
Booking
- Booking controller
app/controllers/agendamentoController.js - Booking and admin views
app/views
Service catalog
- Service controller
app/controllers/servicoController.js - Image upload
app/middlewares/upload.js
Persistence and integrations
- Client records
app/models/Cliente.js - Appointment records
app/models/Agendamento.js - Service records
app/models/Servicos.js - Appointment services
app/models/ServicoAgendamento.js - Barber records
app/models/Barbeiro.js - Reset tokens
app/models/resetPassToken.js - MySQL connection
config/database.js - Email sender
config/mailer.js - Cloudinary configuration
config/cloudinary.js
Other components
- Customer
- Administrator
- Email service
Connections 39
- Customer → Express app: sends requests
- Administrator → Express app: sends requests
- Express app → Booking routes: mounts routes
app.js - Express app → Authentication routes: mounts routes
app.js - Express app → Service routes: mounts routes
app.js - Express app → User routes: mounts routes
app.js - Express app → User context: runs middleware
app.js - Booking routes → Booking controller: dispatches to
app/routes/homeRoutes.js - Authentication routes → Authentication controller: dispatches to
app/routes/authRoutes.js - Authentication routes → Login rate limit: limits login
app/routes/authRoutes.js - Service routes → Service controller: dispatches to
app/routes/servicoRoutes.js - User routes → Client controller: dispatches to
app/routes/userRoutes.js - Booking routes → Token verification: checks identity
app/routes/homeRoutes.js - Booking routes → Role authorization: checks role
app/routes/homeRoutes.js - Service routes → Token verification: checks identity
app/routes/servicoRoutes.js - Service routes → Role authorization: checks role
app/routes/servicoRoutes.js - Service routes → Image upload: uploads image
app/routes/servicoRoutes.js - Booking controller → Appointment records: reads and creates
app/controllers/agendamentoController.js - Booking controller → Client records: reads clients
app/controllers/agendamentoController.js - Booking controller → Service records: reads services
app/controllers/agendamentoController.js - Booking controller → Appointment services: creates links
app/controllers/agendamentoController.js - Booking controller → Booking and admin views: renders pages
app/controllers/agendamentoController.js - Authentication controller → Client records: reads and updates
app/controllers/authController.js - Authentication controller → Reset tokens: creates and validates
app/controllers/authController.js - Authentication controller → Email sender: sends reset email
app/controllers/authController.js - Authentication controller → Booking and admin views: renders pages
app/controllers/authController.js - Token verification → Client records: looks up user
app/middlewares/checkToken.js - User context → Client records: uses client model
app/middlewares/checkUser.js - Service controller → Service records: manages services
app/controllers/servicoController.js - Service controller → Image upload: uses upload
app/controllers/servicoController.js - Image upload → Cloudinary configuration: configures storage
app/middlewares/upload.js - Appointment records → MySQL connection: uses connection
app/models/Agendamento.js - Client records → MySQL connection: uses connection
app/models/Cliente.js - Service records → MySQL connection: uses connection
app/models/Servicos.js - Appointment services → MySQL connection: uses connection
app/models/ServicoAgendamento.js - Barber records → MySQL connection: uses connection
app/models/Barbeiro.js - Reset tokens → MySQL connection: uses connection
app/models/resetPassToken.js - Express app → MySQL connection: authenticates connection
app.js - Email sender → Email service: sends email