# anasrawuthar-bit/gibilling architecture

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

- Interactive diagram: https://gitdiagram.com/anasrawuthar-bit/gibilling
- Repository: https://github.com/anasrawuthar-bit/gibilling

## Overview

ZynBill is an offline-capable desktop billing and accounting product with a companion multi-tenant cloud service. The principal runtime centers on the Electron application, which uses the local database for business operations and also coordinates synchronization and WhatsApp features. The cloud server handles customer accounts and related services; sync transfers events between the desktop database and its HTTP API. Database migration and integrity diagnostics form an important internal layer. The README is empty, and the sampled excerpts do not show renderer workflows or all business capabilities, so those relationships are not inferred.

Main entry points: [`server/server.js`](https://github.com/anasrawuthar-bit/gibilling/blob/main/server/server.js) (Cloud API Server), [`main.js`](https://github.com/anasrawuthar-bit/gibilling/blob/main/main.js) (Desktop Application), [`sync-service.js`](https://github.com/anasrawuthar-bit/gibilling/blob/main/sync-service.js) (Sync Service), [`database.js`](https://github.com/anasrawuthar-bit/gibilling/blob/main/database.js) (Business Database)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_desktop["Desktop Runtime"]
  node_electron_app["Desktop Application<br/>[main.js]"]
  node_cloud_client["Cloud Client"]
  node_sync_service["Sync Service<br/>[sync-service.js]"]
  node_whatsapp_service["WhatsApp Service"]
end

subgraph group_accounting["Accounting Data"]
  node_local_database[("Business Database<br/>[database.js]")]
  node_migrations["Schema Migrations"]
  node_integrity_checks["Integrity Dry Run"]
  node_db_diagnostics["Database Diagnostics"]
  node_migration_readiness["Migration Readiness"]
end

subgraph group_cloud["Cloud Service"]
  node_cloud_server["Cloud API Server<br/>[server.js]"]
  node_cloud_database[("Cloud Database<br/>[db.js]")]
  node_environment_config["Environment Config<br/>[env-loader.js]"]
  node_email_service["Email Service<br/>[smtp.js]"]
  node_backup_crypto["Backup Encryption<br/>[backup-crypto.js]"]
end

subgraph group_integrations["External Integrations"]
  node_sync_api["Sync HTTP API<br/>[sync-service.js]"]
  node_whatsapp(("WhatsApp Network"))
end

node_electron_app -->|"uses"| node_local_database
node_electron_app -->|"starts"| node_sync_service
node_electron_app -->|"uses"| node_whatsapp_service
node_local_database -->|"runs"| node_migrations
node_db_diagnostics -->|"checks"| node_integrity_checks
node_migration_readiness -->|"uses"| node_integrity_checks
node_sync_service -->|"claims events"| node_local_database
node_sync_service -->|"pushes and pulls"| node_sync_api
node_whatsapp_service -.->|"sends messages"| node_whatsapp
node_cloud_server -->|"loads"| node_environment_config
node_cloud_server -->|"uses"| node_cloud_database
node_cloud_server -->|"uses"| node_email_service
node_cloud_server -->|"uses"| node_backup_crypto
node_cloud_database -->|"loads"| node_environment_config
node_email_service -->|"uses"| node_cloud_database

click node_electron_app "https://github.com/anasrawuthar-bit/gibilling/blob/main/main.js"
click node_cloud_client "https://github.com/anasrawuthar-bit/gibilling/blob/main/cloud-desktop-client.js"
click node_sync_service "https://github.com/anasrawuthar-bit/gibilling/blob/main/sync-service.js"
click node_whatsapp_service "https://github.com/anasrawuthar-bit/gibilling/blob/main/whatsapp-service.js"
click node_local_database "https://github.com/anasrawuthar-bit/gibilling/blob/main/database.js"
click node_migrations "https://github.com/anasrawuthar-bit/gibilling/blob/main/database-migrations.js"
click node_integrity_checks "https://github.com/anasrawuthar-bit/gibilling/blob/main/data-integrity-dry-run.js"
click node_db_diagnostics "https://github.com/anasrawuthar-bit/gibilling/blob/main/database-diagnostic-core.js"
click node_migration_readiness "https://github.com/anasrawuthar-bit/gibilling/blob/main/migration-readiness.js"
click node_cloud_server "https://github.com/anasrawuthar-bit/gibilling/blob/main/server/server.js"
click node_cloud_database "https://github.com/anasrawuthar-bit/gibilling/blob/main/server/db.js"
click node_environment_config "https://github.com/anasrawuthar-bit/gibilling/blob/main/server/env-loader.js"
click node_email_service "https://github.com/anasrawuthar-bit/gibilling/blob/main/server/smtp.js"
click node_backup_crypto "https://github.com/anasrawuthar-bit/gibilling/blob/main/server/backup-crypto.js"
click node_sync_api "https://github.com/anasrawuthar-bit/gibilling/blob/main/sync-service.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_electron_app,node_cloud_client,node_sync_service,node_whatsapp_service toneBlue
class node_local_database,node_migrations,node_integrity_checks,node_db_diagnostics,node_migration_readiness toneAmber
class node_cloud_server,node_cloud_database,node_environment_config,node_email_service,node_backup_crypto toneMint
class node_sync_api,node_whatsapp toneRose
```

## Components

### Desktop Runtime

- [Desktop Application](https://github.com/anasrawuthar-bit/gibilling/blob/main/main.js): `main.js`
- [Cloud Client](https://github.com/anasrawuthar-bit/gibilling/blob/main/cloud-desktop-client.js): `cloud-desktop-client.js`
- [Sync Service](https://github.com/anasrawuthar-bit/gibilling/blob/main/sync-service.js): `sync-service.js`
- [WhatsApp Service](https://github.com/anasrawuthar-bit/gibilling/blob/main/whatsapp-service.js): `whatsapp-service.js`

### Accounting Data

- [Business Database](https://github.com/anasrawuthar-bit/gibilling/blob/main/database.js): `database.js`
- [Schema Migrations](https://github.com/anasrawuthar-bit/gibilling/blob/main/database-migrations.js): `database-migrations.js`
- [Integrity Dry Run](https://github.com/anasrawuthar-bit/gibilling/blob/main/data-integrity-dry-run.js): `data-integrity-dry-run.js`
- [Database Diagnostics](https://github.com/anasrawuthar-bit/gibilling/blob/main/database-diagnostic-core.js): `database-diagnostic-core.js`
- [Migration Readiness](https://github.com/anasrawuthar-bit/gibilling/blob/main/migration-readiness.js): `migration-readiness.js`

### Cloud Service

- [Cloud API Server](https://github.com/anasrawuthar-bit/gibilling/blob/main/server/server.js): `server/server.js`
- [Cloud Database](https://github.com/anasrawuthar-bit/gibilling/blob/main/server/db.js): `server/db.js`
- [Environment Config](https://github.com/anasrawuthar-bit/gibilling/blob/main/server/env-loader.js): `server/env-loader.js`
- [Email Service](https://github.com/anasrawuthar-bit/gibilling/blob/main/server/smtp.js): `server/smtp.js`
- [Backup Encryption](https://github.com/anasrawuthar-bit/gibilling/blob/main/server/backup-crypto.js): `server/backup-crypto.js`

### External Integrations

- [Sync HTTP API](https://github.com/anasrawuthar-bit/gibilling/blob/main/sync-service.js): `sync-service.js`
- **WhatsApp Network**

## Connections

- Desktop Application → Business Database: uses (evidence: `main.js`)
- Desktop Application → Sync Service: starts (evidence: `main.js`)
- Desktop Application → WhatsApp Service: uses (evidence: `main.js`)
- Business Database → Schema Migrations: runs (evidence: `database.js`)
- Database Diagnostics → Integrity Dry Run: checks (evidence: `database-diagnostic-core.js`)
- Migration Readiness → Integrity Dry Run: uses (evidence: `migration-readiness.js`)
- Sync Service → Business Database: claims events (evidence: `sync-service.js`)
- Sync Service → Sync HTTP API: pushes and pulls (evidence: `sync-service.js`)
- WhatsApp Service → WhatsApp Network: sends messages
- Cloud API Server → Environment Config: loads (evidence: `server/server.js`)
- Cloud API Server → Cloud Database: uses (evidence: `server/server.js`)
- Cloud API Server → Email Service: uses (evidence: `server/server.js`)
- Cloud API Server → Backup Encryption: uses (evidence: `server/server.js`)
- Cloud Database → Environment Config: loads (evidence: `server/db.js`)
- Email Service → Cloud Database: uses (evidence: `server/smtp.js`)
