# onicyborg/bilcode-project-monitoring-be architecture

> Architecture diagram of the GitHub repository onicyborg/bilcode-project-monitoring-be, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/onicyborg/bilcode-project-monitoring-be
- Repository: https://github.com/onicyborg/bilcode-project-monitoring-be

## Overview

Bilcode Monitoring Backend is a NestJS API for operator authentication, persistent Bilcode project monitoring, chat, and bid workflows. The main path is operator/API client → controllers → monitoring or bid services → Bilcode and PostgreSQL, with optional GOWA notifications and Hermes-assisted bid generation. The graph also preserves attachment review, chat uploads, and audit logging. Relationships are limited to those visible in excerpts or stated in the README; unsampled implementation details are not inferred.

Main entry points: [`src/bids.ts`](https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/src/bids.ts) (Bid management), [`src/controllers.ts`](https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/src/controllers.ts) (API controllers), [`src/monitor.ts`](https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/src/monitor.ts) (Monitor worker), [`src/upstream.ts`](https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/src/upstream.ts) (Bilcode and GOWA client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and access"]
  node_bootstrap["API bootstrap<br/>[main.ts]"]
  node_controllers["API controllers<br/>[controllers.ts]"]
  node_auth["Panel authentication<br/>[auth.ts]"]
  node_dto["Request validation<br/>[dto.ts]"]
end

subgraph group_monitoring["Monitoring and chat"]
  node_monitor["Monitor worker<br/>[monitor.ts]"]
  node_chat["Chat service<br/>[chat.ts]"]
  node_uploads["Chat uploads<br/>[chat-upload.ts]"]
  node_download["Attachment download<br/>[chat-download.ts]"]
end

subgraph group_bids["Bid workflow"]
  node_bids["Bid management<br/>[bids.ts]"]
  node_attachment["Attachment collection<br/>[attachments.ts]"]
  node_analysis["Attachment analysis"]
  node_reference["Public reference fetch"]
  node_proposal["Proposal style<br/>[proposal-style.ts]"]
  node_bidresponse["Bid response parsing<br/>[bid-response.ts]"]
  node_draftfailure["Draft failure handling<br/>[draft-failure.ts]"]
  node_generationlog["Generation logs"]
  node_notificationsummary["Notification summary"]
  node_hermes["Hermes bid integration<br/>[hermes-bid.ts]"]
end

subgraph group_shared["Persistence and integrations"]
  node_upstream["Bilcode and GOWA client<br/>[upstream.ts]"]
  node_secrets["Secret management<br/>[secrets.ts]"]
  node_database[("Prisma database<br/>[database.ts]")]
  node_audit["Audit logging<br/>[audit.ts]"]
end

subgraph group_ops["Messaging operations"]
  node_gowaops["VPS WhatsApp transport<br/>[whatsapp.py]"]
end

node_operator(("Operator / client"))
node_bilcode{{"Bilcode API"}}
node_gowa{{"GOWA gateway"}}
node_hermesservice{{"Hermes service"}}

node_operator -->|"sends requests"| node_controllers
node_bootstrap -->|"registers routes"| node_controllers
node_controllers -->|"authenticates"| node_auth
node_controllers -->|"dispatches monitoring"| node_monitor
node_controllers -->|"dispatches bids"| node_bids
node_controllers -->|"handles uploads"| node_uploads
node_controllers -->|"downloads attachment"| node_download
node_controllers -->|"validates input"| node_dto
node_bootstrap -->|"records requests"| node_audit
node_auth -->|"stores sessions"| node_database
node_monitor -->|"reads and writes"| node_database
node_monitor -->|"calls upstream"| node_upstream
node_monitor -->|"coordinates bids"| node_bids
node_monitor -->|"uses chat helpers"| node_chat
node_monitor -->|"checks uploads"| node_uploads
node_monitor -->|"records activity"| node_audit
node_chat -->|"reads and writes"| node_database
node_chat -->|"requests chat data"| node_upstream
node_uploads -->|"uses upload metadata"| node_dto
node_bids -->|"persists bid state"| node_database
node_bids -->|"collects references"| node_attachment
node_bids -->|"analyzes attachments"| node_analysis
node_bids -->|"uses style guidance"| node_proposal
node_bids -->|"parses responses"| node_bidresponse
node_bids -->|"records draft failures"| node_draftfailure
node_bids -->|"records generation"| node_generationlog
node_bids -->|"builds summaries"| node_notificationsummary
node_bids -->|"requests generation"| node_hermes
node_attachment -->|"fetches references"| node_reference
node_attachment -->|"uses attachment cache"| node_database
node_attachment -->|"validates references"| node_upstream
node_upstream -->|"decrypts credentials"| node_secrets
node_upstream -->|"sends API requests"| node_bilcode
node_upstream -->|"sends notifications"| node_gowa
node_audit -->|"writes event logs"| node_database
node_gowaops -->|"sends WhatsApp"| node_gowa
node_hermes -->|"requests bid generation"| node_hermesservice
node_generationlog -->|"uses failure details"| node_draftfailure

click node_bootstrap "https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/src/main.ts"
click node_controllers "https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/src/controllers.ts"
click node_auth "https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/src/auth.ts"
click node_dto "https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/src/dto.ts"
click node_monitor "https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/src/monitor.ts"
click node_chat "https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/src/chat.ts"
click node_uploads "https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/src/chat-upload.ts"
click node_download "https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/src/chat-download.ts"
click node_bids "https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/src/bids.ts"
click node_attachment "https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/src/attachments.ts"
click node_analysis "https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/src/attachment-analysis.ts"
click node_reference "https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/src/public-reference.ts"
click node_proposal "https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/src/proposal-style.ts"
click node_bidresponse "https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/src/bid-response.ts"
click node_draftfailure "https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/src/draft-failure.ts"
click node_generationlog "https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/src/bid-generation-log.ts"
click node_notificationsummary "https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/src/notification-summary.ts"
click node_hermes "https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/src/hermes-bid.ts"
click node_upstream "https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/src/upstream.ts"
click node_secrets "https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/src/secrets.ts"
click node_database "https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/src/database.ts"
click node_audit "https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/src/audit.ts"
click node_gowaops "https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/deploy/hermes/ops/whatsapp.py"

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_controllers,node_auth,node_dto,node_operator toneBlue
class node_monitor,node_chat,node_uploads,node_download toneAmber
class node_bids,node_attachment,node_analysis,node_reference,node_proposal,node_bidresponse,node_draftfailure,node_generationlog,node_notificationsummary,node_hermes,node_bilcode toneMint
class node_upstream,node_secrets,node_database,node_audit toneRose
class node_gowaops,node_gowa,node_hermesservice toneIndigo
```

## Components

### API and access

- [API bootstrap](https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/src/main.ts): `src/main.ts`
- [API controllers](https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/src/controllers.ts): `src/controllers.ts`
- [Panel authentication](https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/src/auth.ts): `src/auth.ts`
- [Request validation](https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/src/dto.ts): `src/dto.ts`

### Monitoring and chat

- [Monitor worker](https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/src/monitor.ts): `src/monitor.ts`
- [Chat service](https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/src/chat.ts): `src/chat.ts`
- [Chat uploads](https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/src/chat-upload.ts): `src/chat-upload.ts`
- [Attachment download](https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/src/chat-download.ts): `src/chat-download.ts`

### Bid workflow

- [Bid management](https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/src/bids.ts): `src/bids.ts`
- [Attachment collection](https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/src/attachments.ts): `src/attachments.ts`
- [Attachment analysis](https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/src/attachment-analysis.ts): `src/attachment-analysis.ts`
- [Public reference fetch](https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/src/public-reference.ts): `src/public-reference.ts`
- [Proposal style](https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/src/proposal-style.ts): `src/proposal-style.ts`
- [Bid response parsing](https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/src/bid-response.ts): `src/bid-response.ts`
- [Draft failure handling](https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/src/draft-failure.ts): `src/draft-failure.ts`
- [Generation logs](https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/src/bid-generation-log.ts): `src/bid-generation-log.ts`
- [Notification summary](https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/src/notification-summary.ts): `src/notification-summary.ts`
- [Hermes bid integration](https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/src/hermes-bid.ts): `src/hermes-bid.ts`

### Persistence and integrations

- [Bilcode and GOWA client](https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/src/upstream.ts): `src/upstream.ts`
- [Secret management](https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/src/secrets.ts): `src/secrets.ts`
- [Prisma database](https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/src/database.ts): `src/database.ts`
- [Audit logging](https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/src/audit.ts): `src/audit.ts`

### Messaging operations

- [VPS WhatsApp transport](https://github.com/onicyborg/bilcode-project-monitoring-be/blob/main/deploy/hermes/ops/whatsapp.py): `deploy/hermes/ops/whatsapp.py`

### Other components

- **Operator / client**
- **Bilcode API**
- **GOWA gateway**
- **Hermes service**

## Connections

- Operator / client → API controllers: sends requests (evidence: `README.md`)
- API bootstrap → API controllers: registers routes
- API controllers → Panel authentication: authenticates (evidence: `src/controllers.ts`)
- API controllers → Monitor worker: dispatches monitoring (evidence: `src/controllers.ts`)
- API controllers → Bid management: dispatches bids (evidence: `src/controllers.ts`)
- API controllers → Chat uploads: handles uploads (evidence: `src/controllers.ts`)
- API controllers → Attachment download: downloads attachment (evidence: `src/controllers.ts`)
- API controllers → Request validation: validates input (evidence: `src/controllers.ts`)
- API bootstrap → Audit logging: records requests (evidence: `src/main.ts`)
- Panel authentication → Prisma database: stores sessions (evidence: `src/auth.ts`)
- Monitor worker → Prisma database: reads and writes (evidence: `src/monitor.ts`)
- Monitor worker → Bilcode and GOWA client: calls upstream (evidence: `src/monitor.ts`)
- Monitor worker → Bid management: coordinates bids (evidence: `src/monitor.ts`)
- Monitor worker → Chat service: uses chat helpers (evidence: `src/monitor.ts`)
- Monitor worker → Chat uploads: checks uploads (evidence: `src/monitor.ts`)
- Monitor worker → Audit logging: records activity (evidence: `README.md`)
- Chat service → Prisma database: reads and writes (evidence: `src/chat.ts`)
- Chat service → Bilcode and GOWA client: requests chat data (evidence: `src/chat.ts`)
- Chat uploads → Request validation: uses upload metadata (evidence: `src/chat-upload.ts`)
- Bid management → Prisma database: persists bid state (evidence: `src/bids.ts`)
- Bid management → Attachment collection: collects references (evidence: `src/bids.ts`)
- Bid management → Attachment analysis: analyzes attachments (evidence: `src/bids.ts`)
- Bid management → Proposal style: uses style guidance (evidence: `src/bids.ts`)
- Bid management → Bid response parsing: parses responses (evidence: `src/bids.ts`)
- Bid management → Draft failure handling: records draft failures (evidence: `src/bids.ts`)
- Bid management → Generation logs: records generation (evidence: `src/bids.ts`)
- Bid management → Notification summary: builds summaries (evidence: `src/bids.ts`)
- Bid management → Hermes bid integration: requests generation (evidence: `src/bids.ts`)
- Attachment collection → Public reference fetch: fetches references (evidence: `src/attachments.ts`)
- Attachment collection → Prisma database: uses attachment cache (evidence: `src/attachments.ts`)
- Attachment collection → Bilcode and GOWA client: validates references (evidence: `src/attachments.ts`)
- Bilcode and GOWA client → Secret management: decrypts credentials (evidence: `src/upstream.ts`)
- Bilcode and GOWA client → Bilcode API: sends API requests (evidence: `src/upstream.ts`)
- Bilcode and GOWA client → GOWA gateway: sends notifications (evidence: `README.md`)
- Audit logging → Prisma database: writes event logs (evidence: `src/audit.ts`)
- VPS WhatsApp transport → GOWA gateway: sends WhatsApp (evidence: `deploy/hermes/ops/whatsapp.py`)
- Hermes bid integration → Hermes service: requests bid generation
- Generation logs → Draft failure handling: uses failure details (evidence: `src/bid-generation-log.ts`)
