# DeepAIBots Central Hub - Technical Architecture Document

## 1. System Overview
DeepAIBots Central Hub is built using a modern, serverless architecture that separates the frontend presentation layer from the backend API services.

## 2. Technology Stack
- **Frontend:** HTML5, Tailwind CSS (via CDN), Vanilla JavaScript.
- **Backend (Serverless APIs):** Node.js hosted on Vercel (or similar serverless platform).
- **Authentication:** Firebase Admin SDK & Firebase Client SDK.
- **Payments Integration:** NOWPayments (Crypto) / Stripe (Fiat).
- **Database:** Firebase Realtime Database / Firestore (for user telemetry and promotions).

## 3. Component Architecture

### Frontend Layer (`index.html`, `success.html`)
- **Public Storefront:** Landing page for unauthorized users.
- **Enterprise Dashboard:** Secure area for authenticated users.
- **Admin Control Panel:** Secure area restricted to administrators via custom claims or UID verification.
- **State Management:** Handled locally via Vanilla JS and DOM manipulation.

### Backend API Services (`/api/`)
- `chat.js`: Handles communication between the frontend and AI providers.
- `create-invoice.js`: Generates payment links and invoice IDs by interfacing with the payment gateway.
- `webhook.js`: Receives asynchronous event callbacks from payment providers to fulfill orders and provision user tiers.
- `validate-reset.js`: Secure endpoint for handling password resets.
- `promotions.js`: Validates promo codes and applies discounts.
- `phantom-provision.js`: Secure endpoint for admins to manually create user accounts.

## 4. Environment & Deployment
- The platform supports dynamic switching between **Sandbox** and **Live** routing for payment gateways via the admin panel.
- Deployments are continuous via Git integration with the serverless hosting provider.
