How avakconta91-gif/8n8 works
This repo is a small orchestration platform for handling incoming WhatsApp-like events, routing them into document/media processing pipelines, and persisting or summarizing results. It is not a single-purpose app; it is a set of bridges (“ponte-*”) plus queues and processors around a central dispatcher.
1. Core runtime
• The main runtime is Node.js.
• server.js, app.js, and router.js suggest an HTTP service with route-based entry points.
• env indicates runtime configuration is externalized rather than hardcoded.
2. Event intake and dispatch
• dispatcher.js appears to be the central coordination layer.
• It likely receives inbound events from the server/router and decides whether to send them to media, document, OCR, audio, or AI processing.
• evolution.js suggests integration with an external messaging/event provider, probably the source of incoming chat events.
3. Queue-based processing
• documentQueue.js and mediaQueue.js indicate asynchronous work queues for different payload types.
• This is an important architectural boundary: intake is separated from heavy processing so the system can continue accepting events while work is processed in the background.
• Queues likely protect the system from bursts of media or document uploads.
4. Document pipeline
• processDocument.js is the document-specific processing stage.
• ponte-documento.js likely acts as the adapter for extracting or normalizing document inputs before processing.
• The presence of por.traineddata strongly suggests OCR for Portuguese text recognition.
5. OCR boundary
• ocr.py is a separate Python component, likely used because OCR tooling is easier or more reliable in Python.
• This creates a cross-runtime boundary: Node.js orchestrates the workflow, while Python performs OCR extraction.
• ponte-ocr.js likely bridges the Node side to the Python OCR process.
6. Media and audio handling
• media-downloader.js suggests fetching attachments or remote media into local processing.
• ponte-audio.js and ponte-whatsapp.js indicate adapter layers for audio-related events and WhatsApp integration.
• This implies the system handles more than text: audio inputs are probably downloaded, normalized, and then passed into downstream analysis.
7. AI / language integration
• groq.js and ponte-ia.js point to an AI inference layer, likely using Groq as the model provider.
• This is probably where extracted text, OCR output, or transcript content is summarized, classified, or transformed.
• resumo.html reinforces that summarization is an important output path.
8. Persistence and external services
• supabase.js indicates Supabase is used as the backend data store or metadata store.
• The architecture likely persists job status, extracted content, or conversation/document records there.
• This creates a clear separation between transient queue/workflow state and durable application data.
9. Presentation layer
• index.html and resumo.html are static UI entry points.
• They likely expose operational views, summaries, or a lightweight dashboard rather than a full SPA.
• The UI seems secondary to the processing pipeline, not the core of the system.
10. Main data flow
• Incoming message/media event enters through the server/router.
• Dispatcher classifies the payload and hands it to the appropriate queue.
• Media/document content is downloaded or normalized.
• OCR/audio/AI bridges perform extraction or generation.
• Results are stored in Supabase and may be surfaced in the HTML views or sent back through the messaging bridge.
11. Important boundaries for a diagram
• Node.js orchestration vs Python OCR execution is a major boundary.
• Synchronous request handling vs queued background processing is another major boundary.
• External integrations are likely: WhatsApp/evolution-style messaging, Groq AI, and Supabase storage.
12. What to emphasize in the architecture diagram
• A central dispatcher with specialized adapters around it.
• Separate pipelines for document, media, OCR, audio, and AI work.
• Durable storage in Supabase.
• Static browser-facing pages as a small presentation surface.
• Environment-driven configuration and an OCR-trained data file as supporting infrastructure.
Main entry points: ponte.js Bridge core · ponte-ia.js AI bridge · app.js App · processDocument.js Document proc
Components 22
Node.js runtime
HTTP entrypoints, routing, and orchestration code.
- Server · Starts the application and exposes the service surface.
server.js - App · Wires application-level middleware and runtime composition.
app.js - Router · Directs inbound requests into the appropriate handlers.
router.js - Env · External runtime configuration and secrets.
env - Dispatcher · Central routing layer that classifies inbound events and chooses a processing path.
dispatcher.js
Processing pipelines
Queued document, media, OCR, audio, and AI processing stages.
- Doc queue · Async queue for document-related jobs.
documentQueue.js - Media queue · Async queue for media-related jobs.
mediaQueue.js - Doc bridge · Normalizes or extracts document inputs before processing.
ponte-documento.js - Document proc · Document processing logic after intake and normalization.
processDocument.js - Media downloader · Retrieves remote attachments or media for downstream work.
media-downloader.js - OCR bridge · Node-side bridge to the OCR execution boundary.
ponte-ocr.js - OCR engine · Python OCR component for text extraction.
ocr.py - Audio bridge · Handles audio-related intake and normalization.
ponte-audio.js - AI bridge · Routes extracted content into the AI/inference layer.
ponte-ia.js - OCR data · Portuguese OCR training data used by the OCR stage.
por.traineddata
External services
Messaging, AI, and persistence boundaries.
- Evolution · Integration with the incoming messaging/event provider.
evolution.js - WhatsApp bridge · Adapter for WhatsApp-like message events.
ponte-whatsapp.js - Bridge core · Shared bridge/orchestration helper used by the platform adapters.
ponte.js - Groq · External model/inference service used for generation or summarization.
groq.js - Supabase · Durable storage for records, job state, or generated outputs.
supabase.js
Presentation
Static HTML views for lightweight output and inspection.
- Home UI · Primary lightweight browser-facing page.
index.html - Summary UI · Static page for summaries or operational output.
resumo.html
Connections 28
- Server → App: bootstraps · Server starts the application runtime.
- App → Router: routes · Application hands requests to the router.
- App → Dispatcher: wires · Application connects intake to the central dispatcher.
- App → Env: reads · Runtime configuration is loaded externally.
- Router → Evolution: ingests · Routes inbound messaging/event traffic into the provider bridge.
- Evolution → WhatsApp bridge: adapts · Provider events are normalized through the WhatsApp bridge.
- WhatsApp bridge → Dispatcher: dispatches · Normalized message events are handed to the dispatcher.
- Dispatcher → Doc queue: enqueues · Document payloads are sent to asynchronous processing.
- Dispatcher → Media queue: enqueues · Media payloads are sent to asynchronous processing.
- Doc queue → Doc bridge: normalizes · Queued document jobs enter the document adapter.
- Doc bridge → Document proc: processes · Document inputs flow into the document pipeline.
- Document proc → OCR bridge: extracts · Document processing can invoke OCR when text needs extraction.
- OCR bridge → OCR engine: executes · Node bridges into the Python OCR worker.
- OCR engine → OCR data: uses · OCR consumes Portuguese trained language data.
- Media queue → Media downloader: downloads · Queued media jobs fetch remote attachments for local processing.
- Media downloader → Audio bridge: routes · Fetched media can be treated as audio when appropriate.
- Document proc → AI bridge: summarizes · Processed text or extracted content is passed to AI.
- Audio bridge → AI bridge: transforms · Audio-derived content can be forwarded into AI analysis.
- AI bridge → Groq: calls · AI bridge invokes the model provider.
- Document proc → Supabase: persists · Document results and metadata are stored durably.
- AI bridge → Supabase: stores · Generated summaries or classifications are persisted.
- Supabase → Home UI: surfaces · Stored data may be shown in the lightweight UI.
- Supabase → Summary UI: surfaces · Summaries or reports may be rendered in the summary page.
- Bridge core → WhatsApp bridge: shared core · Common bridge logic supports the WhatsApp adapter.
- Bridge core → Doc bridge: shared core · Common bridge logic supports the document adapter.
- Bridge core → Audio bridge: shared core · Common bridge logic supports the audio adapter.
- Bridge core → OCR bridge: shared core · Common bridge logic supports the OCR bridge.
- Bridge core → AI bridge: shared core · Common bridge logic supports the AI bridge.