# rizky-iqbal36/testgooglepubsubwithnodejs architecture

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

- Interactive diagram: https://gitdiagram.com/rizky-iqbal36/testgooglepubsubwithnodejs
- Repository: https://github.com/rizky-iqbal36/testgooglepubsubwithnodejs

## Overview

This small Node.js service accepts birthday-related payloads over HTTP, publishes them to Google Pub/Sub, and runs separate age and year subscribers. The shared subscriber handler derives an age or birth year, then delegates persistence to Sequelize models. The excerpts establish the main calls and message handling; database configuration and migration details were not sampled, so the database link is shown as unverified.

Main entry points: [`src/repositories/pubSub-repo.js`](https://github.com/rizky-iqbal36/testgooglepubsubwithnodejs/blob/master/src/repositories/pubSub-repo.js) (Pub/Sub handler), [`src/services/birthDayService.js`](https://github.com/rizky-iqbal36/testgooglepubsubwithnodejs/blob/master/src/services/birthDayService.js) (Birth data service), [`server.js`](https://github.com/rizky-iqbal36/testgooglepubsubwithnodejs/blob/master/server.js) (HTTP server), [`src/routes/router.js`](https://github.com/rizky-iqbal36/testgooglepubsubwithnodejs/blob/master/src/routes/router.js) (Create route)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_http["HTTP API"]
  node_server["HTTP server<br/>[server.js]"]
  node_router["Create route<br/>[router.js]"]
  node_controller["Publish controller"]
end

subgraph group_messaging["Pub/Sub Messaging"]
  node_repo["Pub/Sub handler<br/>[pubSub-repo.js]"]
  node_google["Google Pub/Sub"]
  node_age["Age subscriber<br/>[ageSub.js]"]
  node_year["Year subscriber<br/>[yearSub.js]"]
end

subgraph group_processing["Message Processing"]
  node_birthservice["Birth data service<br/>[birthDayService.js]"]
end

subgraph group_persistence["Persistence"]
  node_models["Model loader<br/>[index.js]"]
  node_agetable["Age model<br/>[agetable.js]"]
  node_birthtable["Birth model<br/>[birthtable.js]"]
  node_database[("SQL database")]
end

node_caller(("API caller"))

node_caller -->|"sends request"| node_server
node_server -->|"mounts routes"| node_router
node_router -->|"routes create"| node_controller
node_controller -->|"publishes payload"| node_repo
node_repo -->|"publishes message"| node_google
node_age -->|"starts listener"| node_repo
node_year -->|"starts listener"| node_repo
node_google -->|"delivers messages"| node_repo
node_repo -->|"stores parsed message"| node_birthservice
node_birthservice -->|"loads models"| node_models
node_birthservice -->|"creates age record"| node_agetable
node_birthservice -->|"creates year record"| node_birthtable
node_agetable -.->|"persists records"| node_database
node_birthtable -.->|"persists records"| node_database

click node_server "https://github.com/rizky-iqbal36/testgooglepubsubwithnodejs/blob/master/server.js"
click node_router "https://github.com/rizky-iqbal36/testgooglepubsubwithnodejs/blob/master/src/routes/router.js"
click node_controller "https://github.com/rizky-iqbal36/testgooglepubsubwithnodejs/blob/master/src/controller/topic-controller.js"
click node_repo "https://github.com/rizky-iqbal36/testgooglepubsubwithnodejs/blob/master/src/repositories/pubSub-repo.js"
click node_age "https://github.com/rizky-iqbal36/testgooglepubsubwithnodejs/blob/master/src/pubsub/subscribers/ageSub.js"
click node_year "https://github.com/rizky-iqbal36/testgooglepubsubwithnodejs/blob/master/src/pubsub/subscribers/yearSub.js"
click node_birthservice "https://github.com/rizky-iqbal36/testgooglepubsubwithnodejs/blob/master/src/services/birthDayService.js"
click node_models "https://github.com/rizky-iqbal36/testgooglepubsubwithnodejs/blob/master/models/index.js"
click node_agetable "https://github.com/rizky-iqbal36/testgooglepubsubwithnodejs/blob/master/models/agetable.js"
click node_birthtable "https://github.com/rizky-iqbal36/testgooglepubsubwithnodejs/blob/master/models/birthtable.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_router,node_controller toneBlue
class node_repo,node_google,node_age,node_year toneAmber
class node_birthservice,node_caller toneMint
class node_models,node_agetable,node_birthtable,node_database toneRose
```

## Components

### HTTP API

- [HTTP server](https://github.com/rizky-iqbal36/testgooglepubsubwithnodejs/blob/master/server.js): `server.js`
- [Create route](https://github.com/rizky-iqbal36/testgooglepubsubwithnodejs/blob/master/src/routes/router.js): `src/routes/router.js`
- [Publish controller](https://github.com/rizky-iqbal36/testgooglepubsubwithnodejs/blob/master/src/controller/topic-controller.js): `src/controller/topic-controller.js`

### Pub/Sub Messaging

- [Pub/Sub handler](https://github.com/rizky-iqbal36/testgooglepubsubwithnodejs/blob/master/src/repositories/pubSub-repo.js): `src/repositories/pubSub-repo.js`
- **Google Pub/Sub**
- [Age subscriber](https://github.com/rizky-iqbal36/testgooglepubsubwithnodejs/blob/master/src/pubsub/subscribers/ageSub.js): `src/pubsub/subscribers/ageSub.js`
- [Year subscriber](https://github.com/rizky-iqbal36/testgooglepubsubwithnodejs/blob/master/src/pubsub/subscribers/yearSub.js): `src/pubsub/subscribers/yearSub.js`

### Message Processing

- [Birth data service](https://github.com/rizky-iqbal36/testgooglepubsubwithnodejs/blob/master/src/services/birthDayService.js): `src/services/birthDayService.js`

### Persistence

- [Model loader](https://github.com/rizky-iqbal36/testgooglepubsubwithnodejs/blob/master/models/index.js): `models/index.js`
- [Age model](https://github.com/rizky-iqbal36/testgooglepubsubwithnodejs/blob/master/models/agetable.js): `models/agetable.js`
- [Birth model](https://github.com/rizky-iqbal36/testgooglepubsubwithnodejs/blob/master/models/birthtable.js): `models/birthtable.js`
- **SQL database**

### Other components

- **API caller**

## Connections

- API caller → HTTP server: sends request (evidence: `server.js`)
- HTTP server → Create route: mounts routes (evidence: `server.js`)
- Create route → Publish controller: routes create (evidence: `src/routes/router.js`)
- Publish controller → Pub/Sub handler: publishes payload (evidence: `src/controller/topic-controller.js`)
- Pub/Sub handler → Google Pub/Sub: publishes message (evidence: `src/repositories/pubSub-repo.js`)
- Age subscriber → Pub/Sub handler: starts listener (evidence: `src/pubsub/subscribers/ageSub.js`)
- Year subscriber → Pub/Sub handler: starts listener (evidence: `src/pubsub/subscribers/yearSub.js`)
- Google Pub/Sub → Pub/Sub handler: delivers messages (evidence: `src/repositories/pubSub-repo.js`)
- Pub/Sub handler → Birth data service: stores parsed message (evidence: `src/repositories/pubSub-repo.js`)
- Birth data service → Model loader: loads models (evidence: `src/services/birthDayService.js`)
- Birth data service → Age model: creates age record (evidence: `src/services/birthDayService.js`)
- Birth data service → Birth model: creates year record (evidence: `src/services/birthDayService.js`)
- Age model → SQL database: persists records
- Birth model → SQL database: persists records
