# cesarmanzano1/proyectom2_manzano-cesar-luis- architecture

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

- Interactive diagram: https://gitdiagram.com/cesarmanzano1/proyectom2_manzano-cesar-luis-
- Repository: https://github.com/cesarmanzano1/proyectom2_manzano-cesar-luis-

## Overview

This is an Express REST API for managing authors and posts. Clients call the server’s health, author, and post endpoints; routes apply validation where configured, controllers shape responses and call services, and services issue PostgreSQL queries. Startup checks the database connection, creates the authors/posts tables, then listens for requests. The README also documents interactive Swagger/OpenAPI, which is served by the server. Relationships are limited to those shown in the excerpts or explicitly documented; no controller, router, or middleware behavior beyond the excerpts is inferred.

Main entry points: [`src/config/dbConnect.js`](https://github.com/cesarmanzano1/proyectom2_manzano-cesar-luis-/blob/main/src/config/dbConnect.js) (Database connection), [`src/router/router.js`](https://github.com/cesarmanzano1/proyectom2_manzano-cesar-luis-/blob/main/src/router/router.js) (API routes), [`src/server.js`](https://github.com/cesarmanzano1/proyectom2_manzano-cesar-luis-/blob/main/src/server.js) (Express server), [`index.js`](https://github.com/cesarmanzano1/proyectom2_manzano-cesar-luis-/blob/main/index.js) (Startup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["API entry"]
  node_bootstrap["Startup<br/>[index.js]"]
  node_server["Express server<br/>[server.js]"]
  node_routes["API routes<br/>[router.js]"]
  node_middleware["Validation middleware<br/>[middleware.js]"]
  node_swagger["OpenAPI docs<br/>[swagger.js]"]
end

subgraph group_domain["Author and post APIs"]
  node_health["Health check"]
  node_author_controller["Author controller"]
  node_post_controller["Post controller<br/>[post.Controller.js]"]
  node_author_service["Author service<br/>[authors.service.js]"]
  node_post_service["Post service<br/>[post.service.js]"]
end

subgraph group_persistence["Persistence"]
  node_db_config["Database connection<br/>[dbConnect.js]"]
  node_db_settings["DB settings<br/>[constsConfig.js]"]
  node_schema_init["Schema initialization<br/>[initDB.js]"]
  node_postgres[("PostgreSQL")]
end

node_clients(("API clients"))

node_clients -->|"send requests"| node_server
node_server -->|"dispatches requests"| node_routes
node_routes -->|"routes health"| node_health
node_routes -->|"routes authors"| node_author_controller
node_routes -->|"routes posts"| node_post_controller
node_routes -->|"applies validation"| node_middleware
node_author_controller -->|"calls"| node_author_service
node_post_controller -->|"calls"| node_post_service
node_post_controller -->|"checks author"| node_author_service
node_author_service -->|"queries"| node_db_config
node_post_service -->|"queries"| node_db_config
node_db_config -->|"loads settings"| node_db_settings
node_db_config -->|"connects"| node_postgres
node_bootstrap -->|"checks connection"| node_db_config
node_bootstrap -->|"initializes schema"| node_schema_init
node_schema_init -->|"creates tables"| node_db_config
node_bootstrap -->|"starts listener"| node_server
node_server -->|"serves docs"| node_swagger
node_server -->|"uses logger"| node_middleware

click node_bootstrap "https://github.com/cesarmanzano1/proyectom2_manzano-cesar-luis-/blob/main/index.js"
click node_server "https://github.com/cesarmanzano1/proyectom2_manzano-cesar-luis-/blob/main/src/server.js"
click node_routes "https://github.com/cesarmanzano1/proyectom2_manzano-cesar-luis-/blob/main/src/router/router.js"
click node_middleware "https://github.com/cesarmanzano1/proyectom2_manzano-cesar-luis-/blob/main/src/middleware/middleware.js"
click node_health "https://github.com/cesarmanzano1/proyectom2_manzano-cesar-luis-/blob/main/src/controllers/health.controller.js"
click node_author_controller "https://github.com/cesarmanzano1/proyectom2_manzano-cesar-luis-/blob/main/src/controllers/authors.Controller.js"
click node_post_controller "https://github.com/cesarmanzano1/proyectom2_manzano-cesar-luis-/blob/main/src/controllers/post.Controller.js"
click node_author_service "https://github.com/cesarmanzano1/proyectom2_manzano-cesar-luis-/blob/main/src/services/authors.service.js"
click node_post_service "https://github.com/cesarmanzano1/proyectom2_manzano-cesar-luis-/blob/main/src/services/post.service.js"
click node_swagger "https://github.com/cesarmanzano1/proyectom2_manzano-cesar-luis-/blob/main/src/swagger.js"
click node_db_config "https://github.com/cesarmanzano1/proyectom2_manzano-cesar-luis-/blob/main/src/config/dbConnect.js"
click node_db_settings "https://github.com/cesarmanzano1/proyectom2_manzano-cesar-luis-/blob/main/src/config/constsConfig.js"
click node_schema_init "https://github.com/cesarmanzano1/proyectom2_manzano-cesar-luis-/blob/main/src/config/initDB.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_bootstrap,node_server,node_routes,node_middleware,node_swagger,node_clients toneBlue
class node_health,node_author_controller,node_post_controller,node_author_service,node_post_service toneAmber
class node_db_config,node_db_settings,node_schema_init,node_postgres toneMint
```

## Components

### API entry

- [Startup](https://github.com/cesarmanzano1/proyectom2_manzano-cesar-luis-/blob/main/index.js): `index.js`
- [Express server](https://github.com/cesarmanzano1/proyectom2_manzano-cesar-luis-/blob/main/src/server.js): `src/server.js`
- [API routes](https://github.com/cesarmanzano1/proyectom2_manzano-cesar-luis-/blob/main/src/router/router.js): `src/router/router.js`
- [Validation middleware](https://github.com/cesarmanzano1/proyectom2_manzano-cesar-luis-/blob/main/src/middleware/middleware.js): `src/middleware/middleware.js`
- [OpenAPI docs](https://github.com/cesarmanzano1/proyectom2_manzano-cesar-luis-/blob/main/src/swagger.js): `src/swagger.js`

### Author and post APIs

- [Health check](https://github.com/cesarmanzano1/proyectom2_manzano-cesar-luis-/blob/main/src/controllers/health.controller.js): `src/controllers/health.controller.js`
- [Author controller](https://github.com/cesarmanzano1/proyectom2_manzano-cesar-luis-/blob/main/src/controllers/authors.Controller.js): `src/controllers/authors.Controller.js`
- [Post controller](https://github.com/cesarmanzano1/proyectom2_manzano-cesar-luis-/blob/main/src/controllers/post.Controller.js): `src/controllers/post.Controller.js`
- [Author service](https://github.com/cesarmanzano1/proyectom2_manzano-cesar-luis-/blob/main/src/services/authors.service.js): `src/services/authors.service.js`
- [Post service](https://github.com/cesarmanzano1/proyectom2_manzano-cesar-luis-/blob/main/src/services/post.service.js): `src/services/post.service.js`

### Persistence

- [Database connection](https://github.com/cesarmanzano1/proyectom2_manzano-cesar-luis-/blob/main/src/config/dbConnect.js): `src/config/dbConnect.js`
- [DB settings](https://github.com/cesarmanzano1/proyectom2_manzano-cesar-luis-/blob/main/src/config/constsConfig.js): `src/config/constsConfig.js`
- [Schema initialization](https://github.com/cesarmanzano1/proyectom2_manzano-cesar-luis-/blob/main/src/config/initDB.js): `src/config/initDB.js`
- **PostgreSQL**

### Other components

- **API clients**

## Connections

- API clients → Express server: send requests (evidence: `README.md`)
- Express server → API routes: dispatches requests (evidence: `src/server.js`)
- API routes → Health check: routes health (evidence: `src/router/router.js`)
- API routes → Author controller: routes authors (evidence: `src/router/router.js`)
- API routes → Post controller: routes posts (evidence: `src/router/router.js`)
- API routes → Validation middleware: applies validation (evidence: `src/router/router.js`)
- Author controller → Author service: calls (evidence: `src/controllers/authors.Controller.js`)
- Post controller → Post service: calls (evidence: `src/controllers/post.Controller.js`)
- Post controller → Author service: checks author (evidence: `src/controllers/post.Controller.js`)
- Author service → Database connection: queries (evidence: `src/services/authors.service.js`)
- Post service → Database connection: queries (evidence: `src/services/post.service.js`)
- Database connection → DB settings: loads settings (evidence: `src/config/dbConnect.js`)
- Database connection → PostgreSQL: connects (evidence: `src/config/dbConnect.js`)
- Startup → Database connection: checks connection (evidence: `index.js`)
- Startup → Schema initialization: initializes schema (evidence: `index.js`)
- Schema initialization → Database connection: creates tables (evidence: `src/config/initDB.js`)
- Startup → Express server: starts listener (evidence: `index.js`)
- Express server → OpenAPI docs: serves docs (evidence: `src/server.js`)
- Express server → Validation middleware: uses logger (evidence: `src/server.js`)
