# santiago-sanchez01/pi2_-sanchez_santiago-mini-blog-api architecture

> Architecture diagram of the GitHub repository santiago-sanchez01/pi2_-sanchez_santiago-mini-blog-api, 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/santiago-sanchez01/pi2_-sanchez_santiago-mini-blog-api
- Repository: https://github.com/santiago-sanchez01/pi2_-sanchez_santiago-mini-blog-api

## Overview

MiniBlog API is an Express/PostgreSQL service for CRUD management of authors and posts, with posts linked to authors. Requests enter through the server and app router, then reach the relevant resource routes; those handlers validate inputs and query PostgreSQL. The app also serves interactive Swagger documentation. The graph reflects excerpted calls and README capabilities; database schema details and OpenAPI specification content were not sampled, so their internal behavior is not expanded.

Main entry points: [`src/app.js`](https://github.com/santiago-sanchez01/pi2_-sanchez_santiago-mini-blog-api/blob/main/src/app.js) (Express app), [`src/routes/authors.routes.js`](https://github.com/santiago-sanchez01/pi2_-sanchez_santiago-mini-blog-api/blob/main/src/routes/authors.routes.js) (Author CRUD), [`src/routes/posts.routes.js`](https://github.com/santiago-sanchez01/pi2_-sanchez_santiago-mini-blog-api/blob/main/src/routes/posts.routes.js) (Post CRUD), [`src/db/index.js`](https://github.com/santiago-sanchez01/pi2_-sanchez_santiago-mini-blog-api/blob/main/src/db/index.js) (PostgreSQL pool)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["HTTP entry"]
  node_server["HTTP server<br/>[server.js]"]
  node_app["Express app<br/>[app.js]"]
end

subgraph group_resources["Resource operations"]
  node_authors["Author CRUD<br/>[authors.routes.js]"]
  node_posts["Post CRUD<br/>[posts.routes.js]"]
  node_idcheck["ID validation<br/>[validateId.js]"]
end

subgraph group_persistence["Persistence and docs"]
  node_pgpool["PostgreSQL pool<br/>[index.js]"]
  node_database[("PostgreSQL database")]
  node_swagger["Swagger UI<br/>[app.js]"]
  node_openapi["OpenAPI specification<br/>[openapi.yaml]"]
end

node_client(("API client"))

node_client -->|"sends requests"| node_server
node_server -->|"starts"| node_app
node_app -->|"mounts /authors"| node_authors
node_app -->|"mounts /posts"| node_posts
node_authors -->|"validates IDs"| node_idcheck
node_posts -->|"validates IDs"| node_idcheck
node_authors -->|"queries"| node_pgpool
node_posts -->|"queries"| node_pgpool
node_pgpool -.->|"connects to"| node_database
node_app -->|"serves docs"| node_swagger
node_app -->|"loads spec"| node_openapi

click node_server "https://github.com/santiago-sanchez01/pi2_-sanchez_santiago-mini-blog-api/blob/main/src/server.js"
click node_app "https://github.com/santiago-sanchez01/pi2_-sanchez_santiago-mini-blog-api/blob/main/src/app.js"
click node_authors "https://github.com/santiago-sanchez01/pi2_-sanchez_santiago-mini-blog-api/blob/main/src/routes/authors.routes.js"
click node_posts "https://github.com/santiago-sanchez01/pi2_-sanchez_santiago-mini-blog-api/blob/main/src/routes/posts.routes.js"
click node_idcheck "https://github.com/santiago-sanchez01/pi2_-sanchez_santiago-mini-blog-api/blob/main/src/middlewares/validateId.js"
click node_pgpool "https://github.com/santiago-sanchez01/pi2_-sanchez_santiago-mini-blog-api/blob/main/src/db/index.js"
click node_swagger "https://github.com/santiago-sanchez01/pi2_-sanchez_santiago-mini-blog-api/blob/main/src/app.js"
click node_openapi "https://github.com/santiago-sanchez01/pi2_-sanchez_santiago-mini-blog-api/blob/main/docs/openapi.yaml"

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_client toneBlue
class node_authors,node_posts,node_idcheck toneAmber
class node_pgpool,node_database,node_swagger,node_openapi toneMint
```

## Components

### HTTP entry

- [HTTP server](https://github.com/santiago-sanchez01/pi2_-sanchez_santiago-mini-blog-api/blob/main/src/server.js): `src/server.js`
- [Express app](https://github.com/santiago-sanchez01/pi2_-sanchez_santiago-mini-blog-api/blob/main/src/app.js): `src/app.js`

### Resource operations

- [Author CRUD](https://github.com/santiago-sanchez01/pi2_-sanchez_santiago-mini-blog-api/blob/main/src/routes/authors.routes.js): `src/routes/authors.routes.js`
- [Post CRUD](https://github.com/santiago-sanchez01/pi2_-sanchez_santiago-mini-blog-api/blob/main/src/routes/posts.routes.js): `src/routes/posts.routes.js`
- [ID validation](https://github.com/santiago-sanchez01/pi2_-sanchez_santiago-mini-blog-api/blob/main/src/middlewares/validateId.js): `src/middlewares/validateId.js`

### Persistence and docs

- [PostgreSQL pool](https://github.com/santiago-sanchez01/pi2_-sanchez_santiago-mini-blog-api/blob/main/src/db/index.js): `src/db/index.js`
- **PostgreSQL database**
- [Swagger UI](https://github.com/santiago-sanchez01/pi2_-sanchez_santiago-mini-blog-api/blob/main/src/app.js): `src/app.js`
- [OpenAPI specification](https://github.com/santiago-sanchez01/pi2_-sanchez_santiago-mini-blog-api/blob/main/docs/openapi.yaml): `docs/openapi.yaml`

### Other components

- **API client**

## Connections

- API client → HTTP server: sends requests (evidence: `README.md`)
- HTTP server → Express app: starts (evidence: `src/server.js`)
- Express app → Author CRUD: mounts /authors (evidence: `src/app.js`)
- Express app → Post CRUD: mounts /posts (evidence: `src/app.js`)
- Author CRUD → ID validation: validates IDs (evidence: `src/routes/authors.routes.js`)
- Post CRUD → ID validation: validates IDs (evidence: `src/routes/posts.routes.js`)
- Author CRUD → PostgreSQL pool: queries (evidence: `src/routes/authors.routes.js`)
- Post CRUD → PostgreSQL pool: queries (evidence: `src/routes/posts.routes.js`)
- PostgreSQL pool → PostgreSQL database: connects to
- Express app → Swagger UI: serves docs (evidence: `src/app.js`)
- Express app → OpenAPI specification: loads spec (evidence: `src/app.js`)
