# guino12/backend-tp-web architecture

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

- Interactive diagram: https://gitdiagram.com/guino12/backend-tp-web
- Repository: https://github.com/guino12/backend-tp-web

## Overview

This is a Node/Express backend for the GoodNews social network. Clients register or log in, manage profiles, and create or retrieve posts with comments and reactions; protected routes validate JWTs. Route handlers use Mongoose models for persistence, and registration sends a welcome email through configured SMTP. The README gives no further product detail, so the feature map follows the sampled routes and models; external service links reflect only the integrations shown in source.

Main entry points: [`routes/UsuarioRouter.js`](https://github.com/guino12/backend-tp-web/blob/main/routes/UsuarioRouter.js) (User routes), [`routes/PostagemRouter.js`](https://github.com/guino12/backend-tp-web/blob/main/routes/PostagemRouter.js) (Post routes), [`index.js`](https://github.com/guino12/backend-tp-web/blob/main/index.js) (Express server), [`routes/LoginRouter.js`](https://github.com/guino12/backend-tp-web/blob/main/routes/LoginRouter.js) (Login route)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_server["Express server<br/>[index.js]"]
end

subgraph group_identity["Accounts &amp; Identity"]
  node_login["Login route<br/>[LoginRouter.js]"]
  node_users["User routes<br/>[UsuarioRouter.js]"]
  node_jwt["JWT verification<br/>[verificaJWT.js]"]
  node_user_model["User model<br/>[Usuario.js]"]
end

subgraph group_social["Social Content"]
  node_posts["Post routes<br/>[PostagemRouter.js]"]
  node_post_model["Post model<br/>[Postagem.js]"]
  node_photo_enrichment["Author photo enrichment"]
end

subgraph group_integrations["Persistence &amp; Integrations"]
  node_mongo[("MongoDB")]
  node_mail_sender["Welcome email sender<br/>[envioEmail.js]"]
  node_smtp_config["SMTP configuration<br/>[smtp.js]"]
end

node_client(("API client"))
node_smtp["SMTP service"]

node_client -->|"sends requests"| node_server
node_server -->|"mounts routes"| node_users
node_server -->|"mounts routes"| node_posts
node_server -->|"mounts routes"| node_login
node_login -->|"looks up user"| node_user_model
node_login -->|"queries users"| node_mongo
node_users -->|"guards routes"| node_jwt
node_posts -->|"guards routes"| node_jwt
node_users -->|"reads and saves"| node_user_model
node_users -->|"queries and saves"| node_mongo
node_posts -->|"queries and saves"| node_post_model
node_posts -->|"queries and saves"| node_mongo
node_posts -->|"enriches results"| node_photo_enrichment
node_photo_enrichment -->|"loads user photos"| node_user_model
node_photo_enrichment -->|"queries users"| node_mongo
node_users -->|"sends welcome email"| node_mail_sender
node_mail_sender -->|"loads settings"| node_smtp_config
node_mail_sender -->|"sends email"| node_smtp

click node_server "https://github.com/guino12/backend-tp-web/blob/main/index.js"
click node_login "https://github.com/guino12/backend-tp-web/blob/main/routes/LoginRouter.js"
click node_users "https://github.com/guino12/backend-tp-web/blob/main/routes/UsuarioRouter.js"
click node_jwt "https://github.com/guino12/backend-tp-web/blob/main/middleware/verificaJWT.js"
click node_user_model "https://github.com/guino12/backend-tp-web/blob/main/models/Usuario.js"
click node_posts "https://github.com/guino12/backend-tp-web/blob/main/routes/PostagemRouter.js"
click node_post_model "https://github.com/guino12/backend-tp-web/blob/main/models/Postagem.js"
click node_photo_enrichment "https://github.com/guino12/backend-tp-web/blob/main/models/adicionaFotoUsuario.js"
click node_mail_sender "https://github.com/guino12/backend-tp-web/blob/main/email/envioEmail.js"
click node_smtp_config "https://github.com/guino12/backend-tp-web/blob/main/email/config/smtp.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_client toneBlue
class node_login,node_users,node_jwt,node_user_model toneAmber
class node_posts,node_post_model,node_photo_enrichment toneMint
class node_mongo,node_mail_sender,node_smtp_config toneRose
class node_smtp toneIndigo
```

## Components

### HTTP API

- [Express server](https://github.com/guino12/backend-tp-web/blob/main/index.js): `index.js`

### Accounts & Identity

- [Login route](https://github.com/guino12/backend-tp-web/blob/main/routes/LoginRouter.js): `routes/LoginRouter.js`
- [User routes](https://github.com/guino12/backend-tp-web/blob/main/routes/UsuarioRouter.js): `routes/UsuarioRouter.js`
- [JWT verification](https://github.com/guino12/backend-tp-web/blob/main/middleware/verificaJWT.js): `middleware/verificaJWT.js`
- [User model](https://github.com/guino12/backend-tp-web/blob/main/models/Usuario.js): `models/Usuario.js`

### Social Content

- [Post routes](https://github.com/guino12/backend-tp-web/blob/main/routes/PostagemRouter.js): `routes/PostagemRouter.js`
- [Post model](https://github.com/guino12/backend-tp-web/blob/main/models/Postagem.js): `models/Postagem.js`
- [Author photo enrichment](https://github.com/guino12/backend-tp-web/blob/main/models/adicionaFotoUsuario.js): `models/adicionaFotoUsuario.js`

### Persistence & Integrations

- **MongoDB**
- [Welcome email sender](https://github.com/guino12/backend-tp-web/blob/main/email/envioEmail.js): `email/envioEmail.js`
- [SMTP configuration](https://github.com/guino12/backend-tp-web/blob/main/email/config/smtp.js): `email/config/smtp.js`

### Other components

- **API client**
- **SMTP service**

## Connections

- API client → Express server: sends requests
- Express server → User routes: mounts routes (evidence: `index.js`)
- Express server → Post routes: mounts routes (evidence: `index.js`)
- Express server → Login route: mounts routes (evidence: `index.js`)
- Login route → User model: looks up user (evidence: `routes/LoginRouter.js`)
- Login route → MongoDB: queries users (evidence: `routes/LoginRouter.js`)
- User routes → JWT verification: guards routes (evidence: `routes/UsuarioRouter.js`)
- Post routes → JWT verification: guards routes (evidence: `routes/PostagemRouter.js`)
- User routes → User model: reads and saves (evidence: `routes/UsuarioRouter.js`)
- User routes → MongoDB: queries and saves (evidence: `routes/UsuarioRouter.js`)
- Post routes → Post model: queries and saves (evidence: `routes/PostagemRouter.js`)
- Post routes → MongoDB: queries and saves (evidence: `routes/PostagemRouter.js`)
- Post routes → Author photo enrichment: enriches results (evidence: `routes/PostagemRouter.js`)
- Author photo enrichment → User model: loads user photos (evidence: `models/adicionaFotoUsuario.js`)
- Author photo enrichment → MongoDB: queries users (evidence: `models/adicionaFotoUsuario.js`)
- User routes → Welcome email sender: sends welcome email (evidence: `routes/UsuarioRouter.js`)
- Welcome email sender → SMTP configuration: loads settings (evidence: `email/envioEmail.js`)
- Welcome email sender → SMTP service: sends email (evidence: `email/envioEmail.js`)
