# hurtadosandy21-ops/proyectom2_sandyhurtado architecture

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

- Interactive diagram: https://gitdiagram.com/hurtadosandy21-ops/proyectom2_sandyhurtado
- Repository: https://github.com/hurtadosandy21-ops/proyectom2_sandyhurtado

## Overview

MiniBlog is an Express REST API for managing authors and their posts in PostgreSQL. Its main workflow routes HTTP requests through controllers for validation and response handling, then services for parameterized SQL; controller errors are forwarded to a global handler. The README also documents interactive Swagger/OpenAPI support and the authors-to-posts relationship. The graph follows the shown imports and calls; schema relationships and Swagger capabilities are included where explicitly documented, while unsampled setup behavior is omitted.

Main entry points: [`app.js`](https://github.com/hurtadosandy21-ops/proyectom2_sandyhurtado/blob/main/app.js) (Express App), [`src/controllers/postController.js`](https://github.com/hurtadosandy21-ops/proyectom2_sandyhurtado/blob/main/src/controllers/postController.js) (Post Controller), [`src/controllers/authorController.js`](https://github.com/hurtadosandy21-ops/proyectom2_sandyhurtado/blob/main/src/controllers/authorController.js) (Author Controller), [`src/services/authorService.js`](https://github.com/hurtadosandy21-ops/proyectom2_sandyhurtado/blob/main/src/services/authorService.js) (Author Service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_server["HTTP Server<br/>[server.js]"]
  node_app["Express App<br/>[app.js]"]
  node_author_routes["Author Routes<br/>[authorRoutes.js]"]
  node_post_routes["Post Routes<br/>[postRoutes.js]"]
  node_error_handler["Error Handler<br/>[errorHandler.js]"]
end

subgraph group_domain["Author and Post Logic"]
  node_author_controller["Author Controller"]
  node_post_controller["Post Controller<br/>[postController.js]"]
  node_author_service["Author Service<br/>[authorService.js]"]
  node_post_service["Post Service<br/>[postService.js]"]
end

subgraph group_data["Persistence"]
  node_db_pool["PostgreSQL Pool<br/>[db.js]"]
  node_postgres[("PostgreSQL")]
  node_schema["Blog Schema<br/>[schema.sql]"]
end

subgraph group_docs["API Documentation"]
  node_swagger_config["Swagger Config<br/>[swagger.js]"]
  node_swagger_components["API Schemas"]
end

node_client(("API Client"))

node_client -->|"sends requests"| node_server
node_server -->|"starts"| node_app
node_app -->|"mounts authors"| node_author_routes
node_app -->|"mounts posts"| node_post_routes
node_app -->|"registers errors"| node_error_handler
node_app -->|"serves docs"| node_swagger_config
node_author_routes -->|"dispatches"| node_author_controller
node_post_routes -->|"dispatches"| node_post_controller
node_author_controller -->|"calls"| node_author_service
node_post_controller -->|"calls"| node_post_service
node_post_controller -->|"checks author"| node_author_service
node_author_controller -->|"forwards errors"| node_error_handler
node_post_controller -->|"forwards errors"| node_error_handler
node_author_service -->|"queries"| node_db_pool
node_post_service -->|"queries"| node_db_pool
node_db_pool -->|"connects"| node_postgres
node_schema -->|"defines tables"| node_postgres
node_swagger_config -->|"uses schemas"| node_swagger_components

click node_server "https://github.com/hurtadosandy21-ops/proyectom2_sandyhurtado/blob/main/server.js"
click node_app "https://github.com/hurtadosandy21-ops/proyectom2_sandyhurtado/blob/main/app.js"
click node_author_routes "https://github.com/hurtadosandy21-ops/proyectom2_sandyhurtado/blob/main/src/routes/authorRoutes.js"
click node_post_routes "https://github.com/hurtadosandy21-ops/proyectom2_sandyhurtado/blob/main/src/routes/postRoutes.js"
click node_error_handler "https://github.com/hurtadosandy21-ops/proyectom2_sandyhurtado/blob/main/src/middlewares/errorHandler.js"
click node_author_controller "https://github.com/hurtadosandy21-ops/proyectom2_sandyhurtado/blob/main/src/controllers/authorController.js"
click node_post_controller "https://github.com/hurtadosandy21-ops/proyectom2_sandyhurtado/blob/main/src/controllers/postController.js"
click node_author_service "https://github.com/hurtadosandy21-ops/proyectom2_sandyhurtado/blob/main/src/services/authorService.js"
click node_post_service "https://github.com/hurtadosandy21-ops/proyectom2_sandyhurtado/blob/main/src/services/postService.js"
click node_db_pool "https://github.com/hurtadosandy21-ops/proyectom2_sandyhurtado/blob/main/src/config/db.js"
click node_schema "https://github.com/hurtadosandy21-ops/proyectom2_sandyhurtado/blob/main/db/schema.sql"
click node_swagger_config "https://github.com/hurtadosandy21-ops/proyectom2_sandyhurtado/blob/main/src/config/swagger.js"
click node_swagger_components "https://github.com/hurtadosandy21-ops/proyectom2_sandyhurtado/blob/main/src/config/swaggerComponents.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_app,node_author_routes,node_post_routes,node_error_handler,node_client toneBlue
class node_author_controller,node_post_controller,node_author_service,node_post_service toneAmber
class node_db_pool,node_postgres,node_schema toneMint
class node_swagger_config,node_swagger_components toneRose
```

## Components

### HTTP API

- [HTTP Server](https://github.com/hurtadosandy21-ops/proyectom2_sandyhurtado/blob/main/server.js): `server.js`
- [Express App](https://github.com/hurtadosandy21-ops/proyectom2_sandyhurtado/blob/main/app.js): `app.js`
- [Author Routes](https://github.com/hurtadosandy21-ops/proyectom2_sandyhurtado/blob/main/src/routes/authorRoutes.js): `src/routes/authorRoutes.js`
- [Post Routes](https://github.com/hurtadosandy21-ops/proyectom2_sandyhurtado/blob/main/src/routes/postRoutes.js): `src/routes/postRoutes.js`
- [Error Handler](https://github.com/hurtadosandy21-ops/proyectom2_sandyhurtado/blob/main/src/middlewares/errorHandler.js): `src/middlewares/errorHandler.js`

### Author and Post Logic

- [Author Controller](https://github.com/hurtadosandy21-ops/proyectom2_sandyhurtado/blob/main/src/controllers/authorController.js): `src/controllers/authorController.js`
- [Post Controller](https://github.com/hurtadosandy21-ops/proyectom2_sandyhurtado/blob/main/src/controllers/postController.js): `src/controllers/postController.js`
- [Author Service](https://github.com/hurtadosandy21-ops/proyectom2_sandyhurtado/blob/main/src/services/authorService.js): `src/services/authorService.js`
- [Post Service](https://github.com/hurtadosandy21-ops/proyectom2_sandyhurtado/blob/main/src/services/postService.js): `src/services/postService.js`

### Persistence

- [PostgreSQL Pool](https://github.com/hurtadosandy21-ops/proyectom2_sandyhurtado/blob/main/src/config/db.js): `src/config/db.js`
- **PostgreSQL**
- [Blog Schema](https://github.com/hurtadosandy21-ops/proyectom2_sandyhurtado/blob/main/db/schema.sql): `db/schema.sql`

### API Documentation

- [Swagger Config](https://github.com/hurtadosandy21-ops/proyectom2_sandyhurtado/blob/main/src/config/swagger.js): `src/config/swagger.js`
- [API Schemas](https://github.com/hurtadosandy21-ops/proyectom2_sandyhurtado/blob/main/src/config/swaggerComponents.js): `src/config/swaggerComponents.js`

### Other components

- **API Client**

## Connections

- API Client → HTTP Server: sends requests (evidence: `README.md`)
- HTTP Server → Express App: starts (evidence: `server.js`)
- Express App → Author Routes: mounts authors (evidence: `app.js`)
- Express App → Post Routes: mounts posts (evidence: `app.js`)
- Express App → Error Handler: registers errors (evidence: `app.js`)
- Express App → Swagger Config: serves docs (evidence: `app.js`)
- Author Routes → Author Controller: dispatches (evidence: `src/routes/authorRoutes.js`)
- Post Routes → Post Controller: dispatches (evidence: `src/routes/postRoutes.js`)
- Author Controller → Author Service: calls (evidence: `src/controllers/authorController.js`)
- Post Controller → Post Service: calls (evidence: `src/controllers/postController.js`)
- Post Controller → Author Service: checks author (evidence: `src/controllers/postController.js`)
- Author Controller → Error Handler: forwards errors (evidence: `src/controllers/authorController.js`)
- Post Controller → Error Handler: forwards errors (evidence: `src/controllers/postController.js`)
- Author Service → PostgreSQL Pool: queries (evidence: `src/services/authorService.js`)
- Post Service → PostgreSQL Pool: queries (evidence: `src/services/postService.js`)
- PostgreSQL Pool → PostgreSQL: connects (evidence: `src/config/db.js`)
- Blog Schema → PostgreSQL: defines tables (evidence: `README.md`)
- Swagger Config → API Schemas: uses schemas (evidence: `src/config/swagger.js`)
