Signal Distribution Platform

Complete Technical Documentation - Version 1.0

Admin Support Client

Table of Contents

1. System Overview

Architecture: Client-server system with HighLevel CRM integration, distributing real-time signals via API polling (100ms) to customer EAs.
graph TB TV[TradingView Alert] -->|Webhook| SERVER[Central Server] HL[HighLevel CRM] -->|Auto Sync| SERVER SERVER -->|Signals via API| EA1[Client EA - License 1] SERVER -->|Signals via API| EA2[Client EA - License 2] SERVER -->|Signals via API| EA3[Support/Admin EA - Test/Use] ADMIN[๐Ÿ‘‘ Admin] -->|Full Control| SERVER SUPPORT[๐Ÿ”ง Support] -->|Limited Access| SERVER CLIENT[๐Ÿ‘ค Client] -->|Self-Manage| SERVER SERVER --> DB[(Database)] SERVER --> REDIS[(Redis Cache)] style SERVER fill:#4CAF50,color:#fff style ADMIN fill:#f44336,color:#fff style SUPPORT fill:#2196F3,color:#fff style CLIENT fill:#9C27B0,color:#fff style DB fill:#FF9800,color:#fff style REDIS fill:#FF5722,color:#fff

Main Components

Component Role Technology
TradingView Send alerts when signals trigger HTTPS Webhook
HighLevel CRM Customer & order management REST API Sync
Central Server Process logic, distribute signals FastAPI + PostgreSQL + Redis
Client EA Execute trades on MT4/MT5 MQL5 + WebRequest (polling 100ms)
Client Portal Management interface for clients React + TypeScript

2. User Roles & Permissions

Admin (Full Access)

Dashboard Access:

Client Management:

Credentials:


Support (Limited Access)

Dashboard Access:

Client Management:

Credentials:


Client (Self-Service)

Dashboard Access:

Credentials:

Products:

3. Status System

Important: The system has 3 separate status types to manage customer lifecycle.

3.1. Purchase Status

Status Meaning When
purchased Customer has purchased product After successful payment
not_purchased Customer hasn't purchased (lead or expired) New record or after expiration

3.2. Account Status

Status Meaning Next Action
new Purchased but hasn't set password Waiting for client to verify email & set password
verified Password set, can login Client can access portal
active Subscription is active Receiving signals
expired Subscription has expired Needs renewal to continue

3.3. Subscription Status

Status Meaning Auto-Renewal
active Currently using service Can auto-renew
trial On trial period No auto-renew
cancelled Cancelled No auto-renew
expired Expired No auto-renew

4. Client Registration Flows

2 Registration Methods: Client self-registration (no approval needed) OR Support manual creation.

4.1. Flow 1: Self-Registration (No Support approval)

sequenceDiagram participant C as Client participant HL as HighLevel participant SYS as System participant EMAIL as Email Service participant PORTAL as Client Portal C->>HL: 1. Purchase product HL->>SYS: 2. Webhook: New purchase SYS->>SYS: 3. Create customer record Note over SYS: purchase_status: purchased
account_status: new HL->>C: 4. Send invoice email Note over HL,C: Email contains link:
example.com/lets-verify C->>PORTAL: 5. Click verify link PORTAL->>C: 6. Enter email PORTAL->>EMAIL: 7. Generate & send OTP EMAIL->>C: 8. Receive OTP (6 digits) C->>PORTAL: 9. Enter OTP PORTAL->>SYS: 10. Verify OTP SYS->>PORTAL: 11. OTP valid C->>PORTAL: 12. Set password PORTAL->>SYS: 13. Hash & save password Note over SYS: account_status: verified PORTAL->>C: 14. Success! Redirect to login C->>PORTAL: 15. Login PORTAL->>C: 16. Access Dashboard

Key Points:


4.2. Flow 2: Support Creates Customer (Manual)

sequenceDiagram participant C as Client participant SUP as Support participant HL as HighLevel participant SYS as System participant EMAIL as Email Service participant PORTAL as Client Portal C->>SUP: 1. Request service (phone/email) SUP->>HL: 2. Create customer record manually Note over HL: Fill: name, email, phone, product SUP->>SYS: 3. Click "Refresh Data" SYS->>HL: 4. Fetch new records HL->>SYS: 5. Return new customer data SYS->>SYS: 6. Create customer record Note over SYS: purchase_status: not_purchased
account_status: new SUP->>SYS: 7. Find customer in list SUP->>SYS: 8. Click "Send Verify Link" SYS->>EMAIL: 9. Send verification email Note over EMAIL: example.com/lets-verify?token=xxx EMAIL->>C: 10. Receive verify email C->>PORTAL: 11. Click verify link PORTAL->>C: 12. Enter OTP from email C->>PORTAL: 13. Enter OTP PORTAL->>SYS: 14. Verify OTP C->>PORTAL: 15. Set password PORTAL->>SYS: 16. Hash & save password Note over SYS: account_status: verified
purchase_status: purchased PORTAL->>C: 17. Success! Redirect to login C->>PORTAL: 18. Login C->>PORTAL: 19. Add MT4/MT5 licenses

Key Points:

5. Admin Features

5.1. Dashboard with Filters

graph LR DASH[Admin Dashboard] --> FILTER[Filters] FILTER --> F1[Purchase Status] FILTER --> F2[Account Status] FILTER --> F3[Subscription Status] FILTER --> F4[Date Range] FILTER --> F5[Product Type] style DASH fill:#f44336,color:#fff style FILTER fill:#FF9800,color:#fff

5.2. Product Management

Features: Admin can sync products from HighLevel and configure auto-renewal for each product individually.

Main Functions:

5.3. Bulk Renewal

Powerful Feature: Admin can select multiple customers and renew them all at once - useful for combo purchases or promotions.

Bulk Renewal Process:

flowchart TD START[Admin Dashboard] --> SELECT[Select customers to renew] SELECT --> CHECK[โœ“ Checkbox: select multiple] CHECK --> BTN[Click Bulk Renew button] BTN --> MODAL[Show configuration popup] MODAL --> CONFIG{Configure renewal} CONFIG --> C1[Select product to renew] CONFIG --> C2[Enter days: 30/60/90] CONFIG --> C3[Note reason for renewal] CONFIG --> C4[Send email notification?] C1 --> PREVIEW[Preview list] C2 --> PREVIEW C3 --> PREVIEW C4 --> PREVIEW PREVIEW --> CONFIRM{Confirm?} CONFIRM -->|Cancel| CANCEL[Close popup] CONFIRM -->|OK| PROCESS[Process bulk renewal] PROCESS --> LOOP[Loop each customer] LOOP --> UPDATE1[Update subscription_end] UPDATE1 --> UPDATE2[Update HighLevel] UPDATE2 --> UPDATE3[Log audit trail] UPDATE3 --> EMAIL{Send email?} EMAIL -->|Yes| SEND[Send notification email] EMAIL -->|No| SKIP[Skip] SEND --> NEXT[Next customer] SKIP --> NEXT NEXT --> DONE{End of list?} DONE -->|No| LOOP DONE -->|Yes| RESULT[Display results] RESULT --> SUMMARY[Success: X customers
Failed: Y customers
Total: Z customers] style START fill:#f44336,color:#fff style PROCESS fill:#2196F3,color:#fff style RESULT fill:#4CAF50,color:#fff

Main Features:

Feature Description
Multiple Selection Checkbox per customer, or "Select all" on page
Pre-Filter Filter by product/status then bulk select
Flexible Configuration Select specific product + renewal days
Preview Review list before execution
Parallel Processing Fast processing with background job
Detailed Report Success/Failure/Reason for each customer
Audit Trail Log: who, when, renewed whom, how many days

Use Cases:

5.4. Revenue Reports

Report Type Content Display
Total Revenue This week, This month, Compare with last period Line Chart
Customers New customers, Active, Churned Bar Chart
By Product Revenue per product Pie Chart

5.5. Layout Customization

Layout Builder: Admin can customize the dashboard interface for Clients and workspace for Support using drag & drop tools.

Available Widgets:

6. Support Features

6.1. Dashboard with Masked Data

Security: Support only sees masked email and phone numbers to protect customer information.
Information Admin Sees Support Sees
Email customer (full address) cus***mer (masked)
Phone +00 000 000 000 +00 ***000***
Name Full display Full display
Status Full display Full display

6.2. Customer Verification Process

Steps:
  1. Support creates customer record on HighLevel
  2. Click "Refresh Data" button on dashboard
  3. System syncs and displays new customer
  4. Support clicks "Verify Customer"
  5. System automatically updates status
  6. Support contacts customer to provide login information

6.3. Personal Credentials (20 max)

7. Client Portal Features

7.1. Dashboard Overview

graph TD subgraph DASHBOARD["๐Ÿ“Š CLIENT DASHBOARD"] D1[Welcome, Customer Name] D2[Account Status: verified] D3[Subscription Status: active] D4[Expires: Jan 15, 2025] end subgraph STATS["๐Ÿ“ˆ QUICK STATS"] S1[Signals Today: 5] S2[Signals This Week: 35] S3[Licenses: 3/5 used] S4[Auto-Renewal: ON] end style DASHBOARD fill:#e3f2fd style STATS fill:#e8f5e9

7.2. Products Tab

Active Products:

Trendline Pro 2.0
โ€ข Status: โ— Active
โ€ข Purchased: Dec 15, 2024
โ€ข Expires: Jan 15, 2025 (30 days left)
โ€ข Auto-renewal: โœ… ON

Download EA | View Details

Expired Products:

Breakout Strategy
โ€ข Status: โ—‹ Expired
โ€ข Purchased: Nov 1, 2024
โ€ข Expired: Dec 1, 2024

Renew Subscription โ†’ (redirect to sales page)

8. Credentials Management

8.1. Quota Per Role

Role Quota Purpose Separate?
Client 5 licenses MT4/MT5 licenses for trading -
Support 20 credentials Testing & personal use โœ… Separate from clients
Admin Unlimited Development & production โœ… Separate from clients

8.2. Client Add License Flow

Steps:
  1. Client logs into portal
  2. Go to "Credentials" tab
  3. Click "+ Add License" button
  4. Fill form: Platform (MT4/MT5), Account ID, Broker, Label
  5. System validates (check quota, duplicates)
  6. If valid: Create API key + Webhook URL
  7. Display credentials (client needs to copy immediately)
  8. Client sets up TradingView alert + EA

8.3. API Key View Security

Re-authentication: When client wants to view API key again, must re-authenticate with password OR OTP via email.

Security Flow:

  1. Client clicks "View API Key"
  2. System requires: Enter password OR Enter OTP from email
  3. If correct: Display full API key for 30 seconds
  4. After 30 seconds: Auto-hide again
  5. Log: IP, time, action in audit trail

9. Purchase History

9.1. Access

9.2. Data Source

Auto Sync: System syncs purchase history from HighLevel every 5 minutes via cron job.

9.3. Display Columns

Column Description
Date Purchase date
Customer Name Full name
Email Admin: full | Support: masked
Product Product name purchased
Amount Order value
Status completed / refunded / cancelled
HighLevel Order ID Order ID from HighLevel

9.4. Filters

9.5. Data Export

Export CSV: Admin can export all purchase history to CSV file for analysis or archiving.

10. Product Management

10.1. Sync from HighLevel

How it works:
  1. Admin clicks "Sync from HighLevel" button
  2. System calls HighLevel API: GET /products
  3. Compare with local database
  4. Add new products, update changed information
  5. Display sync results

10.2. Product Information

Field Source Can Admin Edit?
Product name HighLevel โŒ Read-only
Price HighLevel โŒ Read-only
Description HighLevel โŒ Read-only
Auto-renewal System โœ… Can enable/disable
Renewal days System โœ… Can set (30/60/90)

10.3. Auto-Renewal Configuration

Renewal Rules: Admin can configure auto-renewal for each product individually.

Parameters:

11. Revenue Reports

11.1. Total Revenue

Period Revenue Comparison
This Week $โ€ข,โ€ขโ€ขโ€ข +12% โ–ฒ
This Month $โ€ข,โ€ขโ€ขโ€ข +15% โ–ฒ

11.2. Customers

Metric Count Change
New this week 8 +2 vs last week
New this month 35 +10 vs last month
Currently active 120 -

11.3. Revenue by Product

Product Revenue This Month % of Total
Trendline Pro $โ€ข,โ€ขโ€ขโ€ข 66%
Breakout Strategy $โ€ข,โ€ขโ€ขโ€ข 34%

11.4. Charts

12. Layout Customization

Layout Builder: Admin can customize dashboard interface for Clients and workspace for Support using visual drag & drop tools.

12.1. Client Dashboard Customization

Available Widgets:

Widget Description Size
Subscription Status Card Display status and expiry date 4x2
Signals Counter Signals today/week 4x2
License Gauge 3/5 licenses used 4x2
Quick Actions Panel Buttons: Add License, View API Keys 6x2
Recent Signals Table Last 10 signals 12x4
Expiry Alert Products expiring soon 6x2

Actions:

12.2. Support Workspace Customization

Customer Table Configuration:

Column Display Width Masked?
Customer Name โœ“ 200px โŒ
Email โœ“ 250px โœ… Masked
Phone โœ“ 150px โœ… Masked
Status โœ“ 120px โŒ
Subscription Expires โœ“ 150px โŒ

Default Filters:

13. Database Schema

Note: This schema shows main tables only. See original markdown file for complete schema with all indexes and relationships.

13.1. Main Tables

-- USERS & AUTHENTICATION
users (Admin/Support)
โ”œโ”€โ”€ id, email, password_hash, role (admin/support)

client_users (Client accounts)
โ”œโ”€โ”€ id, customer_id, email, password_hash
โ”œโ”€โ”€ account_status (new/verified/active/expired)

-- CUSTOMERS
customers
โ”œโ”€โ”€ id, name, email, phone
โ”œโ”€โ”€ purchase_status (purchased/not_purchased)
โ”œโ”€โ”€ subscription_status (active/trial/cancelled/expired)
โ”œโ”€โ”€ subscription_start, subscription_end
โ”œโ”€โ”€ highlevel_id

-- PRODUCTS
products
โ”œโ”€โ”€ id, name, highlevel_product_id, price
โ”œโ”€โ”€ auto_renewal_enabled, auto_renewal_days

customer_products (Many-to-many relationship)
โ”œโ”€โ”€ customer_id, product_id
โ”œโ”€โ”€ purchase_date, expiry_date, auto_renewal

-- PURCHASE HISTORY
purchase_history
โ”œโ”€โ”€ customer_id, product_name, amount
โ”œโ”€โ”€ purchase_date, highlevel_order_id, status

-- CREDENTIALS
client_licenses (Max 5 per client)
โ”œโ”€โ”€ customer_id, platform (MT4/MT5), account_id
โ”œโ”€โ”€ api_key_hash, webhook_url, is_active

support_credentials (Max 20 per support)
โ”œโ”€โ”€ support_user_id, platform, account_id
โ”œโ”€โ”€ api_key_hash, webhook_url, is_active

admin_credentials (Unlimited)
โ”œโ”€โ”€ admin_user_id, platform, account_id
โ”œโ”€โ”€ api_key_hash, webhook_url, is_active

-- SIGNALS
signals
โ”œโ”€โ”€ symbol, action, entry_price, stop_loss
โ”œโ”€โ”€ take_profit_1, take_profit_2, take_profit_3

signal_deliveries
โ”œโ”€โ”€ signal_id, customer_id, license_id
โ”œโ”€โ”€ delivered_at, status (delivered/failed/pending)

-- SECURITY
otp_codes
โ”œโ”€โ”€ email, code_hash, purpose
โ”œโ”€โ”€ expires_at, attempts, used

-- LAYOUT CUSTOMIZATION
layout_settings
โ”œโ”€โ”€ role, view_name, config (JSON)
โ”œโ”€โ”€ created_by, is_active

-- AUDIT LOGS
audit_logs
โ”œโ”€โ”€ user_id, user_type, action
โ”œโ”€โ”€ resource_type, ip_address, created_at

13.2. Important Indexes

14. Workflow Diagrams

14.1. Auto-Renewal Workflow

Schedule: Cron job runs daily at 00:00 to check and auto-renew.
flowchart TD START([Daily Cron 00:00]) --> CHECK[Query customers] CHECK --> QUERY{subscription_end
= today OR tomorrow?} QUERY -->|No| END1[Skip] QUERY -->|Yes| GET[Get customer details] GET --> PURCHASE{purchase_status?} PURCHASE -->|not_purchased| SKIP[Skip auto-renewal] PURCHASE -->|purchased| PRODUCT[Get customer products] PRODUCT --> LOOP[Loop each product] LOOP --> AUTO{Product
auto_renewal_enabled?} AUTO -->|No| SKIP2[Skip this product] AUTO -->|Yes| PAYMENT{Payment status
from HighLevel?} PAYMENT -->|paid| EXTEND[Extend subscription] PAYMENT -->|unpaid/failed| REVOKE[Revoke access] EXTEND --> EXT_DB[Update database] EXT_DB --> EXT_DATE[subscription_end += 30 days] EXT_DATE --> EXT_HL[Update HighLevel] EXT_HL --> EXT_EMAIL[Send renewal email] EXT_EMAIL --> LOG1[Log: Renewed successfully] REVOKE --> REV_DB[Update database] REV_DB --> REV_STATUS[subscription_status: expired] REV_STATUS --> REV_LICENSE[Deactivate all licenses] REV_LICENSE --> REV_HL[Update HighLevel] REV_HL --> REV_EMAIL[Send expiry email] REV_EMAIL --> LOG2[Log: Expired] LOG1 --> END2[Complete] LOG2 --> END2 SKIP --> END2 SKIP2 --> END2 END1 --> END2 style START fill:#4CAF50,color:#fff style EXTEND fill:#2196F3,color:#fff style REVOKE fill:#f44336,color:#fff

14.2. Signal Distribution Workflow

Real-time: EA polls every 100ms to receive signals immediately when available.
sequenceDiagram participant TV as TradingView participant SERVER as Server participant REDIS as Redis Cache participant DB as Database participant EA as Client EA TV->>SERVER: POST /webhook Alert SERVER->>SERVER: Validate webhook SERVER->>DB: Save to signals table SERVER->>DB: Get active customers DB->>SERVER: Return list loop Each Active Customer SERVER->>DB: Get customer licenses loop Each License SERVER->>REDIS: Store signal Note over REDIS: TTL: 60 seconds SERVER->>DB: Log to signal_deliveries end end Note over EA: EA polls every 100ms EA->>SERVER: GET /signal/{api_key} SERVER->>REDIS: Check key alt Signal exists REDIS->>SERVER: Return signal SERVER->>REDIS: Delete key SERVER->>DB: Update: delivered SERVER->>EA: Return signal JSON EA->>EA: Execute trade else No signal SERVER->>EA: Return {} end

15. Security Features

15.1. Password Requirements

15.2. OTP System

Attribute Value
Length 6 digits
Expiration 10 minutes
Max attempts 3 times
New OTP after fail Auto-generate new
Rate limit Max 5 OTP/hour/email

15.3. API Key Security

15.4. Session Security

Mechanism Description
JWT Token Expires after 24 hours
Refresh Token Expires after 30 days
HttpOnly Cookie Prevents XSS attacks
Secure Flag HTTPS only
SameSite=Strict Prevents CSRF attacks
IP Binding Detect session hijacking
Device Fingerprinting Alert on new device login

15.5. Rate Limiting

Endpoint Limit
Login Max 5 times / 15 minutes / IP
API (EA) 10 requests / second / API key
OTP Request Max 5 times / hour / email
Password Reset Max 3 times / day / email

16. API Endpoints

16.1. Public Endpoints (No authentication)

POST /api/v1/webhook
    - Receive alerts from TradingView
    - Header: X-Webhook-Signature (HMAC validation)

POST /api/v1/verify/email
    - Send email to get OTP
    - Rate limit: 5/hour

POST /api/v1/verify/otp
    - Verify OTP code
    - Rate limit: 3 attempts

POST /api/v1/verify/password
    - Set password after OTP verification

16.2. Client Endpoints (JWT authentication)

GET /api/v1/signal/{api_key}
    - EA polls for signals
    - Rate limit: 10/second
    - Return: JSON signal or {}

GET /api/v1/client/dashboard
GET /api/v1/client/products
GET /api/v1/client/licenses
POST /api/v1/client/licenses
DELETE /api/v1/client/licenses/{id}
GET /api/v1/client/signals/history
GET /api/v1/client/settings
PUT /api/v1/client/settings

16.3. Support Endpoints (JWT + Role check)

GET /api/v1/support/customers
    - Email & phone masked
    - Assigned customers only

GET /api/v1/support/customers/{id}
PUT /api/v1/support/customers/{id}
POST /api/v1/support/customers/sync
POST /api/v1/support/customers/{id}/verify
GET /api/v1/support/credentials
POST /api/v1/support/credentials
DELETE /api/v1/support/credentials/{id}
GET /api/v1/support/purchase-history

16.4. Admin Endpoints (JWT + Admin role)

GET /api/v1/admin/customers
    - Full email & phone visibility
    - All customers

GET /api/v1/admin/customers/{id}
POST /api/v1/admin/customers
PUT /api/v1/admin/customers/{id}
DELETE /api/v1/admin/customers/{id}

GET /api/v1/admin/products
POST /api/v1/admin/products/sync
PUT /api/v1/admin/products/{id}

GET /api/v1/admin/reports/revenue
GET /api/v1/admin/reports/customers
GET /api/v1/admin/purchase-history

GET /api/v1/admin/layouts
PUT /api/v1/admin/layouts/{role}

GET /api/v1/admin/credentials
POST /api/v1/admin/credentials

POST /api/v1/admin/bulk-renew
    - Bulk renewal
    - Body: {
        "customer_ids": [1, 2, 3, ...],
        "product_id": 5,
        "days": 30,
        "reason": "Combo promotion Q1",
        "send_email": true
      }
    - Return: {
        "success": 45,
        "failed": 2,
        "total": 47,
        "details": [...]
      }
โ†‘
Built by Gnourt ยท algorithmic trading systems