# mpteixeirarj-glit/vigia architecture

> Architecture diagram of the GitHub repository mpteixeirarj-glit/vigia, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mpteixeirarj-glit/vigia
- Repository: https://github.com/mpteixeirarj-glit/vigia

## Overview

Vigia is a personal-finance app: users manage budgets and financial records in the web app, with an optional WhatsApp bot for recording income and expenses. The tree and excerpts show the bot’s message-to-Firestore workflow and the app’s offline shell; the main app implementation in index.html and several documented capabilities were not sampled, so those subsystems are represented at that file boundary. Relationships are limited to excerpted calls or README/source-index evidence.

Main entry points: [`index.html`](https://github.com/mpteixeirarj-glit/vigia/blob/main/index.html) (Finance interface), [`bot/index.js`](https://github.com/mpteixeirarj-glit/vigia/blob/main/bot/index.js) (Bot event handler), [`bot/parser.js`](https://github.com/mpteixeirarj-glit/vigia/blob/main/bot/parser.js) (Message parser), [`bot/firestore.js`](https://github.com/mpteixeirarj-glit/vigia/blob/main/bot/firestore.js) (Account lookup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Finance app"]
  node_finance_ui["Finance interface<br/>[index.html]"]
  node_records["Transactions and budgets<br/>[index.html]"]
  node_fixed["Recurring finances<br/>[index.html]"]
  node_cards["Cards and installments"]
  node_savings["Savings and investments<br/>[index.html]"]
  node_agenda["Agenda and alerts<br/>[index.html]"]
  node_profiles["User profiles<br/>[index.html]"]
  node_history["Financial history<br/>[index.html]"]
end

subgraph group_bot["WhatsApp bot"]
  node_bot_entry["Bot event handler<br/>[index.js]"]
  node_message_parser["Message parser<br/>[parser.js]"]
  node_text_safety["Text safeguards<br/>[sanitizer.js]"]
  node_account_link["Account lookup<br/>[firestore.js]"]
  node_entry_writer["Transaction writer<br/>[firestore.js]"]
end

subgraph group_storage["Persistence and offline"]
  node_firestore[("Firestore")]
  node_offline_cache["Offline app cache<br/>[sw.js]"]
end

node_person(("User"))
node_bot_user(("WhatsApp user"))
node_whatsapp{{"WhatsApp service"}}
node_browser_cache[("Browser cache")]

node_person -.->|"uses"| node_finance_ui
node_finance_ui -.->|"manages"| node_records
node_finance_ui -.->|"manages"| node_fixed
node_finance_ui -.->|"manages"| node_cards
node_finance_ui -.->|"manages"| node_savings
node_finance_ui -.->|"shows"| node_agenda
node_finance_ui -.->|"supports"| node_profiles
node_finance_ui -.->|"shows"| node_history
node_bot_user -.->|"messages"| node_whatsapp
node_whatsapp -->|"delivers events"| node_bot_entry
node_bot_entry -->|"checks length"| node_text_safety
node_bot_entry -->|"resolves account"| node_account_link
node_bot_entry -->|"parses message"| node_message_parser
node_message_parser -->|"sanitizes text"| node_text_safety
node_account_link -->|"reads links"| node_firestore
node_entry_writer -->|"updates records"| node_firestore
node_bot_entry -->|"saves transaction"| node_entry_writer
node_bot_entry -->|"replies"| node_whatsapp
node_finance_ui -.->|"registers worker"| node_offline_cache
node_offline_cache -->|"caches assets"| node_browser_cache

click node_finance_ui "https://github.com/mpteixeirarj-glit/vigia/blob/main/index.html"
click node_records "https://github.com/mpteixeirarj-glit/vigia/blob/main/index.html"
click node_fixed "https://github.com/mpteixeirarj-glit/vigia/blob/main/index.html"
click node_cards "https://github.com/mpteixeirarj-glit/vigia/tree/main/cartoes"
click node_savings "https://github.com/mpteixeirarj-glit/vigia/blob/main/index.html"
click node_agenda "https://github.com/mpteixeirarj-glit/vigia/blob/main/index.html"
click node_profiles "https://github.com/mpteixeirarj-glit/vigia/blob/main/index.html"
click node_history "https://github.com/mpteixeirarj-glit/vigia/blob/main/index.html"
click node_bot_entry "https://github.com/mpteixeirarj-glit/vigia/blob/main/bot/index.js"
click node_message_parser "https://github.com/mpteixeirarj-glit/vigia/blob/main/bot/parser.js"
click node_text_safety "https://github.com/mpteixeirarj-glit/vigia/blob/main/bot/sanitizer.js"
click node_account_link "https://github.com/mpteixeirarj-glit/vigia/blob/main/bot/firestore.js"
click node_entry_writer "https://github.com/mpteixeirarj-glit/vigia/blob/main/bot/firestore.js"
click node_offline_cache "https://github.com/mpteixeirarj-glit/vigia/blob/main/sw.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_finance_ui,node_records,node_fixed,node_cards,node_savings,node_agenda,node_profiles,node_history,node_person,node_bot_user toneBlue
class node_bot_entry,node_message_parser,node_text_safety,node_account_link,node_entry_writer,node_browser_cache toneAmber
class node_firestore,node_offline_cache toneMint
class node_whatsapp toneIndigo
```

## Components

### Finance app

- [Finance interface](https://github.com/mpteixeirarj-glit/vigia/blob/main/index.html): `index.html`
- [Transactions and budgets](https://github.com/mpteixeirarj-glit/vigia/blob/main/index.html): `index.html`
- [Recurring finances](https://github.com/mpteixeirarj-glit/vigia/blob/main/index.html): `index.html`
- [Cards and installments](https://github.com/mpteixeirarj-glit/vigia/tree/main/cartoes): `cartoes`
- [Savings and investments](https://github.com/mpteixeirarj-glit/vigia/blob/main/index.html): `index.html`
- [Agenda and alerts](https://github.com/mpteixeirarj-glit/vigia/blob/main/index.html): `index.html`
- [User profiles](https://github.com/mpteixeirarj-glit/vigia/blob/main/index.html): `index.html`
- [Financial history](https://github.com/mpteixeirarj-glit/vigia/blob/main/index.html): `index.html`

### WhatsApp bot

- [Bot event handler](https://github.com/mpteixeirarj-glit/vigia/blob/main/bot/index.js): `bot/index.js`
- [Message parser](https://github.com/mpteixeirarj-glit/vigia/blob/main/bot/parser.js): `bot/parser.js`
- [Text safeguards](https://github.com/mpteixeirarj-glit/vigia/blob/main/bot/sanitizer.js): `bot/sanitizer.js`
- [Account lookup](https://github.com/mpteixeirarj-glit/vigia/blob/main/bot/firestore.js): `bot/firestore.js`
- [Transaction writer](https://github.com/mpteixeirarj-glit/vigia/blob/main/bot/firestore.js): `bot/firestore.js`

### Persistence and offline

- **Firestore**
- [Offline app cache](https://github.com/mpteixeirarj-glit/vigia/blob/main/sw.js): `sw.js`

### Other components

- **User**
- **WhatsApp user**
- **WhatsApp service**
- **Browser cache**

## Connections

- User → Finance interface: uses
- Finance interface → Transactions and budgets: manages
- Finance interface → Recurring finances: manages
- Finance interface → Cards and installments: manages
- Finance interface → Savings and investments: manages
- Finance interface → Agenda and alerts: shows
- Finance interface → User profiles: supports
- Finance interface → Financial history: shows
- WhatsApp user → WhatsApp service: messages
- WhatsApp service → Bot event handler: delivers events (evidence: `bot/index.js`)
- Bot event handler → Text safeguards: checks length (evidence: `bot/index.js`)
- Bot event handler → Account lookup: resolves account (evidence: `bot/index.js`)
- Bot event handler → Message parser: parses message (evidence: `bot/index.js`)
- Message parser → Text safeguards: sanitizes text (evidence: `bot/parser.js`)
- Account lookup → Firestore: reads links (evidence: `bot/firestore.js`)
- Transaction writer → Firestore: updates records (evidence: `bot/firestore.js`)
- Bot event handler → Transaction writer: saves transaction (evidence: `bot/index.js`)
- Bot event handler → WhatsApp service: replies (evidence: `bot/index.js`)
- Finance interface → Offline app cache: registers worker
- Offline app cache → Browser cache: caches assets (evidence: `sw.js`)
