DTECH Ecosystem System & ation

Digital Innovation Hub
Back to Gateway

1. Executive Summary

DTECH (Dynamic Tech), founded by Seakwa Jonas Mochebane (PREASX24), is a sophisticated digital rewards platform built primarily as a Telegram Mini App. The system allows users to earn monetary rewards by interacting with various ad formats (interstitials, popups, direct links, in-page push, and an auto-miner) powered by the Monetag ad network.

The architecture is highly modernized, leveraging a serverless backend via Cloudflare Workers and Cloudflare KV for high-speed, edge-based storage. Users accumulate a digital balance that can be withdrawn as proprietary "DTECH Vouchers," which are secure, verifiable codes generated natively by the system.

Core Principles:

---

2. System Architecture & Data Flow

The system operates on a decoupled frontend/backend model:

Data Flow Example (Claiming a Reward):

1. User clicks "Watch Video" in tma.html.

2. Frontend calls Monetag SDK (show_10600930), passing a unique ymid (tracking ID).

3. Upon completion, Monetag sends an asynchronous server-to-server webhook (/monetag-webhook) to the Worker.

4. The Worker validates the webhook, calculates the ZAR (Rand) amount, and updates the user's KV record directly.

5. Simultaneously, the frontend adds the task to a local pendingBatch array.

6. The user clicks "Claim Now" or the auto-timer fires, sending the batch to /add-points.

7. The Worker acknowledges the batch and returns the updated balance.

---

3. Core Workflows (Step-by-Step)

A. Telegram Authentication Flow (`index.html` -> `tma.html`)

1. User opens the DTECH bot/link in Telegram.

2. index.html loads and initializes window.Telegram.WebApp.

3. Frontend extracts initDataUnsafe.user (containing id, first_name, username).

4. Frontend sends a POST /telegram-auth request to the Worker.

5. Backend Logic:

6. Frontend saves the user object (including token) to localStorage/sessionStorage.

7. Frontend redirects to tma.html (The primary dashboard).

B. Ad Integration, Verification, and Earnings Flow (`tma.html`)

1. Ad Trigger: User clicks an ad button or the Auto-Miner interval hits (every 5 mins).

2. SDK Call: Frontend triggers the Monetag SDK: show_10600930({ type: '...', ymid: '...', requestVar: '...' }).

3. Local Batching: After the SDK promise resolves, the ad type is pushed to the local pendingBatch array stored in localStorage.

4. Backend Webhook: Monetag independently pings GET /monetag-webhook?ymid=...&estimated_price=...&reward_event_type=valued. The backend credits 100% of the converted USD to ZAR value to the user's main balance.

5. Claiming: Every 20 minutes (or manually via the "Claim" button with a 5-min cooldown), the frontend sends POST /add-points with the batch array.

6. The backend processes any fallback/web-based rewards if needed, clears the batch, and returns the synced balance.

C. The Voucher & Withdrawal System

1. User requests a withdrawal via tma.html (e.g., 20R).

2. Frontend sends POST /generate-voucher with amount and token.

3. Backend Logic:

4. Frontend displays the voucher code in a stylized ticket UI with a native "Copy" button.

5. Vouchers can be redeemed externally or verified via POST /redeem-voucher.

---

4. Database (Cloudflare KV) Schema

The Cloudflare KV namespace (bound as USERS) uses stringified JSON objects.

4.1. User Object (Key: `username` or `tg_id`)


{
  "username": "preasx24",
  "telegramId": 123456789,
  "balance": 25.50,
  "balance_pending": 0.00,
  "status": "active",
  "token": "preasx24-1715500000000",
  "referral_count": 5,
  "referred_by": null,
  "history": [
    {
      "id": "REW-1715500123-456",
      "amount": 0.35,
      "date": "2024-05-12T10:00:00.000Z",
      "status": "approved",
      "source": "monetag_instant"
    }
  ],
  "rounds": {
    "r1_last_completed: 0,
    "r2_last_completed": 0,
    "mission_progress": { "popunder": 0, "inpage": 0, "direct": 0, "push": 0 }
  },
  "processed_postbacks": ["preasx24_1715500000000"],
  "daily_stats": {
    "2024-05-12": {
      "total_approved": 1.50,
      "total_pending": 0,
      "status": "active"
    }
  }
}

4.2. Global Stats (Key: `GLOBAL_STATS`)


{
  "total_users": 1500,
  "active_today": 350,
  "ads_today": 1200,
  "rewards_today": 450.25,
  "liability": 1200.50,
  "paid": 500.00,
  "month": "2024-05",
  "last_active_date": "2024-05-12",
  "system_status": {
    "freeze_rewards": false,
    "emergency_cut": false,
    "withdrawals_enabled": true,
    "ads_enabled": true
  }
}

4.3. Voucher Object (Key: `VOUCHER:<voucher_code>`)


{
  "worth": 50.00,
  "is_used": false,
  "username": "preasx24",
  "created_at": "2024-05-12T12:00:00.000Z"
}

4.4. Other System Keys

---

5. API Endpoint Documentation (`worker.js`)

All endpoints are hosted on the Cloudflare Worker. They expect and return application/json and handle CORS natively.

`POST /telegram-auth`

`POST /add-points`

`POST /generate-voucher`

`GET /profile`

`GET /monetag-webhook`

`GET /system-status`

Admin Endpoints (Requires `X-Admin-Secret` Header)

---

6. Active Files Breakdown

`index.html` (Entry Point / Login)

`tma.html` (Primary Telegram Mini App Dashboard)

`worker.js` (The Brains / Backend)

`profile.html`

`admin.html` (Admin Console)

`berserker.html` & `berserker_inpage.html` (Unified Task Dashboards)

`apps.html`

---

7. Legacy & Secondary Files Breakdown (Obsolete but Retained)

The user explicitly prefers hiding or deprecating code rather than deleting it.

---

8. External Integrations & Dependencies

1. Monetag Ad SDK (libtl.com/sdk.js):

2. Telegram WebApp SDK (telegram.org/js/telegram-web-app.js):

3. Canvas Confetti (confetti.browser.min.js):

4. Cloudflare Workers & KV:

Visit Live Platform