System Architecture
A deep dive into the OConnect technical stack and data flow.
Architecture
OBrain OConnect is designed as a modular, event-driven platform optimized for the Cloudflare ecosystem.
Component Breakdown
1. Backend Worker (Hono)
Located in backend-worker/, this is the unified API that handles everything from authentication to supplier synchronization. It leverages Drizzle ORM for type-safe database interactions with Cloudflare D1.
2. Agent & Intelligence Layer
Specialized agents handle market analysis and automation:
- GlobalTrendScanner: Monitors viral products in US/EU markets (Fase 2).
- ReviewGapAnalyzer: Extracts consumer pain points from negative reviews (Reverse Data Logistics).
- CopyMaster: AI-driven offer repositioning for high conversion.
- PriceWatchAgent: Periodic competitor scanning.
3. AI Hub Gateway
A resilient gateway that handles all LLM interactions:
- Provider Fallback: Automatically failover between Groq, OpenAI, and Cloudflare AI.
- Budget Governor: Real-time token tracking and cost enforcement per user via KV.
4. Real-time Orchestration (Fase 3)
Leverages Cloudflare Durable Objects to maintain stateful, asynchronous pipelines for continuous market monitoring.
Data Flow
graph TD
A[Supplier API] -->|Sync| B[Backend Worker]
B -->|Persist| C[(Cloudflare D1)]
B -->|Upload| D[Cloudflare R2]
B -->|Notify| E[User Portal]
F[Agents] -->|Analyze| C
F -->|Trigger| BStorage Strategy
- Database (D1): Stores products, users, orders, and configuration.
- KV Store: Used for high-frequency tokens, idempotency keys, and budget tracking.
- R2 Storage: Hosts product images, banners, and static assets.
- Durable Objects: Manages persistent state for real-time automation pipelines.
Observabilidade
O sistema utiliza logs JSON Estruturados integrados ao Datadog para garantir rastreabilidade completa e auditoria de cada decisão tomada pelos agentes de IA.
E-Commerce Automation
OConnect leverages AI across the supply chain:
- Smart Catalog: Automatically pulls detailed imagery, stock, and descriptions via API.
- Dynamic Margins: Margin adjustments driven by competitive intelligence.
- Automated Fulfillment: Pushing customer details back upstream immediately upon checkout.