# matheus-castro-paula/trilha-backend-matheuscastro-2026-01 architecture

> Architecture diagram of the GitHub repository matheus-castro-paula/trilha-backend-matheuscastro-2026-01, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/matheus-castro-paula/trilha-backend-matheuscastro-2026-01
- Repository: https://github.com/matheus-castro-paula/trilha-backend-matheuscastro-2026-01

## Overview

This is an Express REST API for a product catalog. Users register or log in, then browse products and—when authenticated—create and manage reviews; admins manage products and users. Authentication also supports password recovery by email, and product writes can upload images to Cloudinary. The graph follows the documented route/controller structure and sampled controller calls; several capabilities are documented but their implementation files were not sampled, so links to those integrations reflect README evidence.

Main entry points: [`models/index.js`](https://github.com/matheus-castro-paula/trilha-backend-matheuscastro-2026-01/blob/main/models/index.js) (Sequelize models), [`index.js`](https://github.com/matheus-castro-paula/trilha-backend-matheuscastro-2026-01/blob/main/index.js) (Express server), [`routes/productRoutes.js`](https://github.com/matheus-castro-paula/trilha-backend-matheuscastro-2026-01/blob/main/routes/productRoutes.js) (Product routes), [`routes/userRoutes.js`](https://github.com/matheus-castro-paula/trilha-backend-matheuscastro-2026-01/blob/main/routes/userRoutes.js) (User routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API routing"]
  node_server["Express server<br/>[index.js]"]
  node_authroutes["Auth routes<br/>[authRoutes.js]"]
  node_userroutes["User routes<br/>[userRoutes.js]"]
  node_productroutes["Product routes<br/>[productRoutes.js]"]
  node_reviewroutes["Review routes<br/>[reviewRoutes.js]"]
end

subgraph group_identity["Identity and access"]
  node_authctl["Authentication<br/>[authController.js]"]
  node_userctl["User management<br/>[userController.js]"]
  node_authmw["JWT verification<br/>[authMiddleware.js]"]
  node_adminmw["Admin authorization<br/>[isAdmin.js]"]
end

subgraph group_catalog["Catalog and reviews"]
  node_productctl["Product catalog"]
  node_reviewctl["Review management"]
  node_uploadmw["Image upload"]
end

subgraph group_persistence["Persistence"]
  node_models["Sequelize models<br/>[index.js]"]
  node_user["User records<br/>[user.js]"]
  node_product["Product records<br/>[product.js]"]
  node_review["Review records<br/>[review.js]"]
end

node_client(("API client"))
node_mysql[("MySQL database")]
node_mail["Mailtrap SMTP"]
node_cloudinary["Cloudinary"]

node_client -->|"sends HTTP"| node_server
node_server -->|"dispatches"| node_authroutes
node_server -->|"dispatches"| node_userroutes
node_server -->|"dispatches"| node_productroutes
node_server -->|"dispatches"| node_reviewroutes
node_authroutes -->|"dispatches"| node_authctl
node_userroutes -->|"dispatches"| node_userctl
node_productroutes -->|"dispatches"| node_productctl
node_reviewroutes -->|"dispatches"| node_reviewctl
node_userroutes -->|"guards"| node_authmw
node_userroutes -->|"guards"| node_adminmw
node_productroutes -->|"guards"| node_authmw
node_productroutes -->|"guards"| node_adminmw
node_productroutes -->|"processes uploads"| node_uploadmw
node_reviewroutes -->|"guards"| node_authmw
node_authctl -->|"queries users"| node_models
node_userctl -->|"queries users"| node_models
node_productctl -->|"queries products"| node_models
node_reviewctl -->|"queries reviews"| node_models
node_models -->|"loads model"| node_user
node_models -->|"loads model"| node_product
node_models -->|"loads model"| node_review
node_models -->|"persists records"| node_mysql
node_authctl -.->|"sends recovery email"| node_mail
node_uploadmw -.->|"uploads images"| node_cloudinary

click node_server "https://github.com/matheus-castro-paula/trilha-backend-matheuscastro-2026-01/blob/main/index.js"
click node_authroutes "https://github.com/matheus-castro-paula/trilha-backend-matheuscastro-2026-01/blob/main/routes/authRoutes.js"
click node_userroutes "https://github.com/matheus-castro-paula/trilha-backend-matheuscastro-2026-01/blob/main/routes/userRoutes.js"
click node_productroutes "https://github.com/matheus-castro-paula/trilha-backend-matheuscastro-2026-01/blob/main/routes/productRoutes.js"
click node_reviewroutes "https://github.com/matheus-castro-paula/trilha-backend-matheuscastro-2026-01/blob/main/routes/reviewRoutes.js"
click node_authctl "https://github.com/matheus-castro-paula/trilha-backend-matheuscastro-2026-01/blob/main/controllers/authController.js"
click node_userctl "https://github.com/matheus-castro-paula/trilha-backend-matheuscastro-2026-01/blob/main/controllers/userController.js"
click node_authmw "https://github.com/matheus-castro-paula/trilha-backend-matheuscastro-2026-01/blob/main/middlewares/authMiddleware.js"
click node_adminmw "https://github.com/matheus-castro-paula/trilha-backend-matheuscastro-2026-01/blob/main/middlewares/isAdmin.js"
click node_productctl "https://github.com/matheus-castro-paula/trilha-backend-matheuscastro-2026-01/blob/main/controllers/productController.js"
click node_reviewctl "https://github.com/matheus-castro-paula/trilha-backend-matheuscastro-2026-01/blob/main/controllers/reviewController.js"
click node_uploadmw "https://github.com/matheus-castro-paula/trilha-backend-matheuscastro-2026-01/blob/main/middlewares/uploadMiddleware.js"
click node_models "https://github.com/matheus-castro-paula/trilha-backend-matheuscastro-2026-01/blob/main/models/index.js"
click node_user "https://github.com/matheus-castro-paula/trilha-backend-matheuscastro-2026-01/blob/main/models/user.js"
click node_product "https://github.com/matheus-castro-paula/trilha-backend-matheuscastro-2026-01/blob/main/models/product.js"
click node_review "https://github.com/matheus-castro-paula/trilha-backend-matheuscastro-2026-01/blob/main/models/review.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_server,node_authroutes,node_userroutes,node_productroutes,node_reviewroutes,node_client toneBlue
class node_authctl,node_userctl,node_authmw,node_adminmw,node_mysql toneAmber
class node_productctl,node_reviewctl,node_uploadmw toneMint
class node_models,node_user,node_product,node_review toneRose
class node_mail,node_cloudinary toneIndigo
```

## Components

### API routing

- [Express server](https://github.com/matheus-castro-paula/trilha-backend-matheuscastro-2026-01/blob/main/index.js): `index.js`
- [Auth routes](https://github.com/matheus-castro-paula/trilha-backend-matheuscastro-2026-01/blob/main/routes/authRoutes.js): `routes/authRoutes.js`
- [User routes](https://github.com/matheus-castro-paula/trilha-backend-matheuscastro-2026-01/blob/main/routes/userRoutes.js): `routes/userRoutes.js`
- [Product routes](https://github.com/matheus-castro-paula/trilha-backend-matheuscastro-2026-01/blob/main/routes/productRoutes.js): `routes/productRoutes.js`
- [Review routes](https://github.com/matheus-castro-paula/trilha-backend-matheuscastro-2026-01/blob/main/routes/reviewRoutes.js): `routes/reviewRoutes.js`

### Identity and access

- [Authentication](https://github.com/matheus-castro-paula/trilha-backend-matheuscastro-2026-01/blob/main/controllers/authController.js): `controllers/authController.js`
- [User management](https://github.com/matheus-castro-paula/trilha-backend-matheuscastro-2026-01/blob/main/controllers/userController.js): `controllers/userController.js`
- [JWT verification](https://github.com/matheus-castro-paula/trilha-backend-matheuscastro-2026-01/blob/main/middlewares/authMiddleware.js): `middlewares/authMiddleware.js`
- [Admin authorization](https://github.com/matheus-castro-paula/trilha-backend-matheuscastro-2026-01/blob/main/middlewares/isAdmin.js): `middlewares/isAdmin.js`

### Catalog and reviews

- [Product catalog](https://github.com/matheus-castro-paula/trilha-backend-matheuscastro-2026-01/blob/main/controllers/productController.js): `controllers/productController.js`
- [Review management](https://github.com/matheus-castro-paula/trilha-backend-matheuscastro-2026-01/blob/main/controllers/reviewController.js): `controllers/reviewController.js`
- [Image upload](https://github.com/matheus-castro-paula/trilha-backend-matheuscastro-2026-01/blob/main/middlewares/uploadMiddleware.js): `middlewares/uploadMiddleware.js`

### Persistence

- [Sequelize models](https://github.com/matheus-castro-paula/trilha-backend-matheuscastro-2026-01/blob/main/models/index.js): `models/index.js`
- [User records](https://github.com/matheus-castro-paula/trilha-backend-matheuscastro-2026-01/blob/main/models/user.js): `models/user.js`
- [Product records](https://github.com/matheus-castro-paula/trilha-backend-matheuscastro-2026-01/blob/main/models/product.js): `models/product.js`
- [Review records](https://github.com/matheus-castro-paula/trilha-backend-matheuscastro-2026-01/blob/main/models/review.js): `models/review.js`

### Other components

- **API client**
- **MySQL database**
- **Mailtrap SMTP**
- **Cloudinary**

## Connections

- API client → Express server: sends HTTP
- Express server → Auth routes: dispatches
- Express server → User routes: dispatches
- Express server → Product routes: dispatches
- Express server → Review routes: dispatches
- Auth routes → Authentication: dispatches
- User routes → User management: dispatches
- Product routes → Product catalog: dispatches
- Review routes → Review management: dispatches
- User routes → JWT verification: guards
- User routes → Admin authorization: guards
- Product routes → JWT verification: guards
- Product routes → Admin authorization: guards
- Product routes → Image upload: processes uploads
- Review routes → JWT verification: guards
- Authentication → Sequelize models: queries users
- User management → Sequelize models: queries users
- Product catalog → Sequelize models: queries products
- Review management → Sequelize models: queries reviews
- Sequelize models → User records: loads model
- Sequelize models → Product records: loads model
- Sequelize models → Review records: loads model
- Sequelize models → MySQL database: persists records
- Authentication → Mailtrap SMTP: sends recovery email
- Image upload → Cloudinary: uploads images
