# mendesdevel0per/visionapplications architecture

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

- Interactive diagram: https://gitdiagram.com/mendesdevel0per/visionapplications
- Repository: https://github.com/mendesdevel0per/visionapplications

## Overview

This repository is a Discord bot and companion web service for configuring and operating Discord communities, including a storefront, tickets, giveaways, automations, moderation/protection, and bot hosting controls. The main user-to-result path is a Discord interaction handled by a bot command or feature module, with configuration and operational data persisted through the bot database; the web backend separately serves dashboard/API and billing functions. The tree documents broad capabilities, but sampled source is limited, so several feature links are shown as unverified rather than asserted as calls.

Main entry points: [`bot/functions/database.py`](https://github.com/mendesdevel0per/visionapplications/blob/main/bot/functions/database.py) (Bot data access), [`bot/connections/handlers/__init__.py`](https://github.com/mendesdevel0per/visionapplications/blob/main/bot/connections/handlers/__init__.py) (WebSocket handlers), [`site/backend/src/app.js`](https://github.com/mendesdevel0per/visionapplications/blob/main/site/backend/src/app.js) (Web API server), [`bot/modules/cloud/update_api.py`](https://github.com/mendesdevel0per/visionapplications/blob/main/bot/modules/cloud/update_api.py) (Cloud API updates)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_bot["Discord bot"]
  node_bot_runtime["Bot runtime<br/>[bot.py]"]
  node_commands["Bot commands"]
  node_database_api["Bot data access<br/>[database.py]"]
  node_mongo[("MongoDB collection<br/>[mongo_db.py]")]
end

subgraph group_commerce["Store and payments"]
  node_shop["Storefront"]
  node_purchase["Purchase management"]
  node_stock["Product stock<br/>[stock_manager.py]"]
  node_balance["User balance<br/>[balance_manager.py]"]
  node_payments["Payment workflows"]
end

subgraph group_community["Community features"]
  node_tickets["Ticket system"]
  node_giveaways["Giveaways"]
  node_automations["Automations"]
  node_protection["Server protection"]
end

subgraph group_cloud["Cloud control"]
  node_ws_handlers["WebSocket handlers<br/>[__init__.py]"]
  node_ws_manager["Bot WebSocket<br/>[ws_manager.py]"]
  node_cloud_api["Cloud API updates<br/>[update_api.py]"]
end

subgraph group_web["Web platform"]
  node_web_client["Dashboard client<br/>[route.ts]"]
  node_web_backend["Web API server<br/>[app.js]"]
  node_application_model[("Bot application records<br/>[Application.js]")]
  node_billing["Billing services"]
  node_backend_runtime["Backend service runner<br/>[server.js]"]
end

node_discord_user(("Discord user"))

node_discord_user -.->|"invokes"| node_commands
node_commands -.->|"reads/writes"| node_database_api
node_database_api -->|"queries"| node_mongo
node_shop -.->|"manages purchases"| node_purchase
node_purchase -->|"reads/writes"| node_database_api
node_stock -->|"reads/writes"| node_database_api
node_balance -->|"reads/writes"| node_database_api
node_payments -.->|"credits balance"| node_balance
node_tickets -.->|"persists settings"| node_database_api
node_giveaways -.->|"persists settings"| node_database_api
node_automations -.->|"persists settings"| node_database_api
node_protection -.->|"persists settings"| node_database_api
node_ws_manager -->|"registers handlers"| node_ws_handlers
node_ws_handlers -->|"registers store"| node_shop
node_ws_handlers -->|"registers tickets"| node_tickets
node_ws_handlers -->|"registers giveaways"| node_giveaways
node_ws_handlers -->|"registers protection"| node_protection
node_cloud_api -->|"uses connection"| node_ws_manager
node_cloud_api -->|"reads/writes"| node_database_api
node_web_client -.->|"forwards requests"| node_web_backend
node_backend_runtime -->|"starts server"| node_web_backend
node_backend_runtime -->|"starts service"| node_billing
node_web_backend -.->|"serves API data"| node_application_model

click node_bot_runtime "https://github.com/mendesdevel0per/visionapplications/blob/main/bot/bot.py"
click node_commands "https://github.com/mendesdevel0per/visionapplications/tree/main/bot/commands"
click node_database_api "https://github.com/mendesdevel0per/visionapplications/blob/main/bot/functions/database.py"
click node_mongo "https://github.com/mendesdevel0per/visionapplications/blob/main/bot/connections/mongo_db.py"
click node_shop "https://github.com/mendesdevel0per/visionapplications/tree/main/bot/modules/loja"
click node_purchase "https://github.com/mendesdevel0per/visionapplications/blob/main/bot/modules/loja/cart/purchase_manager.py"
click node_stock "https://github.com/mendesdevel0per/visionapplications/blob/main/bot/modules/loja/cart/stock_manager.py"
click node_balance "https://github.com/mendesdevel0per/visionapplications/blob/main/bot/modules/loja/saldo/balance_manager.py"
click node_payments "https://github.com/mendesdevel0per/visionapplications/tree/main/bot/functions/payments"
click node_tickets "https://github.com/mendesdevel0per/visionapplications/tree/main/bot/modules/tickets"
click node_giveaways "https://github.com/mendesdevel0per/visionapplications/tree/main/bot/modules/giveaways"
click node_automations "https://github.com/mendesdevel0per/visionapplications/tree/main/bot/modules/automations"
click node_protection "https://github.com/mendesdevel0per/visionapplications/tree/main/bot/modules/protection"
click node_ws_handlers "https://github.com/mendesdevel0per/visionapplications/blob/main/bot/connections/handlers/__init__.py"
click node_ws_manager "https://github.com/mendesdevel0per/visionapplications/blob/main/bot/connections/ws_manager.py"
click node_cloud_api "https://github.com/mendesdevel0per/visionapplications/blob/main/bot/modules/cloud/update_api.py"
click node_web_client "https://github.com/mendesdevel0per/visionapplications/blob/main/site/frontend/src/app/api/%5B...endpoint%5D/route.ts"
click node_web_backend "https://github.com/mendesdevel0per/visionapplications/blob/main/site/backend/src/app.js"
click node_application_model "https://github.com/mendesdevel0per/visionapplications/blob/main/site/backend/src/database/models/Application.js"
click node_billing "https://github.com/mendesdevel0per/visionapplications/blob/main/site/backend/src/services/billing/inactivityService.js"
click node_backend_runtime "https://github.com/mendesdevel0per/visionapplications/blob/main/site/backend/server.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_bot_runtime,node_commands,node_database_api,node_mongo,node_discord_user toneBlue
class node_shop,node_purchase,node_stock,node_balance,node_payments toneAmber
class node_tickets,node_giveaways,node_automations,node_protection toneMint
class node_ws_handlers,node_ws_manager,node_cloud_api toneRose
class node_web_client,node_web_backend,node_application_model,node_billing,node_backend_runtime toneIndigo
```

## Components

### Discord bot

- [Bot runtime](https://github.com/mendesdevel0per/visionapplications/blob/main/bot/bot.py): `bot/bot.py`
- [Bot commands](https://github.com/mendesdevel0per/visionapplications/tree/main/bot/commands): `bot/commands`
- [Bot data access](https://github.com/mendesdevel0per/visionapplications/blob/main/bot/functions/database.py): `bot/functions/database.py`
- [MongoDB collection](https://github.com/mendesdevel0per/visionapplications/blob/main/bot/connections/mongo_db.py): `bot/connections/mongo_db.py`

### Store and payments

- [Storefront](https://github.com/mendesdevel0per/visionapplications/tree/main/bot/modules/loja): `bot/modules/loja`
- [Purchase management](https://github.com/mendesdevel0per/visionapplications/blob/main/bot/modules/loja/cart/purchase_manager.py): `bot/modules/loja/cart/purchase_manager.py`
- [Product stock](https://github.com/mendesdevel0per/visionapplications/blob/main/bot/modules/loja/cart/stock_manager.py): `bot/modules/loja/cart/stock_manager.py`
- [User balance](https://github.com/mendesdevel0per/visionapplications/blob/main/bot/modules/loja/saldo/balance_manager.py): `bot/modules/loja/saldo/balance_manager.py`
- [Payment workflows](https://github.com/mendesdevel0per/visionapplications/tree/main/bot/functions/payments): `bot/functions/payments`

### Community features

- [Ticket system](https://github.com/mendesdevel0per/visionapplications/tree/main/bot/modules/tickets): `bot/modules/tickets`
- [Giveaways](https://github.com/mendesdevel0per/visionapplications/tree/main/bot/modules/giveaways): `bot/modules/giveaways`
- [Automations](https://github.com/mendesdevel0per/visionapplications/tree/main/bot/modules/automations): `bot/modules/automations`
- [Server protection](https://github.com/mendesdevel0per/visionapplications/tree/main/bot/modules/protection): `bot/modules/protection`

### Cloud control

- [WebSocket handlers](https://github.com/mendesdevel0per/visionapplications/blob/main/bot/connections/handlers/__init__.py): `bot/connections/handlers/__init__.py`
- [Bot WebSocket](https://github.com/mendesdevel0per/visionapplications/blob/main/bot/connections/ws_manager.py): `bot/connections/ws_manager.py`
- [Cloud API updates](https://github.com/mendesdevel0per/visionapplications/blob/main/bot/modules/cloud/update_api.py): `bot/modules/cloud/update_api.py`

### Web platform

- [Dashboard client](https://github.com/mendesdevel0per/visionapplications/blob/main/site/frontend/src/app/api/%5B...endpoint%5D/route.ts): `site/frontend/src/app/api/[...endpoint]/route.ts`
- [Web API server](https://github.com/mendesdevel0per/visionapplications/blob/main/site/backend/src/app.js): `site/backend/src/app.js`
- [Bot application records](https://github.com/mendesdevel0per/visionapplications/blob/main/site/backend/src/database/models/Application.js): `site/backend/src/database/models/Application.js`
- [Billing services](https://github.com/mendesdevel0per/visionapplications/blob/main/site/backend/src/services/billing/inactivityService.js): `site/backend/src/services/billing/inactivityService.js`
- [Backend service runner](https://github.com/mendesdevel0per/visionapplications/blob/main/site/backend/server.js): `site/backend/server.js`

### Other components

- **Discord user**

## Connections

- Discord user → Bot commands: invokes
- Bot commands → Bot data access: reads/writes (evidence: `bot/commands/vendas/sincronizar_clientes.py`)
- Bot data access → MongoDB collection: queries (evidence: `bot/functions/database.py`)
- Storefront → Purchase management: manages purchases
- Purchase management → Bot data access: reads/writes (evidence: `bot/modules/loja/cart/purchase_manager.py`)
- Product stock → Bot data access: reads/writes (evidence: `bot/modules/loja/cart/stock_manager.py`)
- User balance → Bot data access: reads/writes (evidence: `bot/modules/loja/saldo/balance_manager.py`)
- Payment workflows → User balance: credits balance
- Ticket system → Bot data access: persists settings
- Giveaways → Bot data access: persists settings
- Automations → Bot data access: persists settings
- Server protection → Bot data access: persists settings (evidence: `bot/modules/protection/protecaogeral/webhooks/helpers.py`)
- Bot WebSocket → WebSocket handlers: registers handlers (evidence: `bot/connections/ws_manager.py`)
- WebSocket handlers → Storefront: registers store (evidence: `bot/connections/handlers/__init__.py`)
- WebSocket handlers → Ticket system: registers tickets (evidence: `bot/connections/handlers/__init__.py`)
- WebSocket handlers → Giveaways: registers giveaways (evidence: `bot/connections/handlers/__init__.py`)
- WebSocket handlers → Server protection: registers protection (evidence: `bot/connections/handlers/__init__.py`)
- Cloud API updates → Bot WebSocket: uses connection (evidence: `bot/modules/cloud/update_api.py`)
- Cloud API updates → Bot data access: reads/writes (evidence: `bot/modules/cloud/update_api.py`)
- Dashboard client → Web API server: forwards requests
- Backend service runner → Web API server: starts server (evidence: `site/backend/server.js`)
- Backend service runner → Billing services: starts service (evidence: `site/backend/server.js`)
- Web API server → Bot application records: serves API data
