Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

Terraform Academy Platform - Enterprise Learning & Marketing System

A comprehensive enterprise SaaS platform for infrastructure-as-code education featuring AI-powered learning assistants, interactive coaching, gamified PvP challenges, and a full marketing automation suite with intelligent AI agents.

Platform Tiers

Feature Pro Max
Learning Modules Yes Yes
Interactive Labs Yes Yes
AI RAG Bot Assistant Yes Yes
AI Interactive Coach Yes Yes
Platform Navigation AI Yes Yes
PvP Gaming Arena Yes Yes
AI Gaming Bots Yes Yes
Admin Dashboard No Yes
Marketing Platform No Yes
AI Marketing Agent No Yes
Email Automation No Yes
Win-Back Campaigns No Yes
Lead Management No Yes

Architecture Overview

┌─────────────────────────────────────────────────────────────────────────────────────────────┐
│                           TERRAFORM ACADEMY PLATFORM                                        │
├─────────────────────────────────────────────────────────────────────────────────────────────┤
│                                                                                             │
│   PRESENTATION LAYER                                                                        │
│   ┌───────────────────────────────────────────────────────────────────────────────────────┐ │
│   │                          React 18 + TypeScript + Tailwind                             │ │
│   │  ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌────────────────────────────────────┐│ │
│   │  │ Learning    │ │ PvP Arena  │ │ User Portal │ │ Admin Dashboard (Max Only)         ││ │
│   │  │ Platform    │ │ & Gaming   │ │ & Profile   │ │ - Marketing Suite                  ││ │
│   │  │             │ │            │ │             │ │ - Email Automation                 ││ │
│   │  │             │ │            │ │             │ │ - AI Marketing Agent               ││ │
│   │  └─────────────┘ └─────────────┘ └─────────────┘ └────────────────────────────────────┘│ │
│   └───────────────────────────────────────────────────────────────────────────────────────┘ │
│                                           │                                                 │
├───────────────────────────────────────────│─────────────────────────────────────────────────┤
│   AI SERVICES LAYER                       │                                                 │
│   ┌───────────────────────────────────────┴───────────────────────────────────────────────┐ │
│   │                                                                                       │ │
│   │  ┌─────────────────────┐  ┌─────────────────────┐  ┌─────────────────────────────┐   │ │
│   │  │ AI RAG Bot          │  │ AI Interactive      │  │ Platform Navigation AI      │   │ │
│   │  │ (Knowledge Base)    │  │ Coach               │  │                             │   │ │
│   │  │                     │  │                     │  │ - Context-aware guidance    │   │ │
│   │  │ - Terraform docs    │  │ - Real-time hints   │  │ - Feature discovery         │   │ │
│   │  │ - AWS/Azure/GCP     │  │ - Learning path     │  │ - Personalized workflows    │   │ │
│   │  │ - Course content    │  │   recommendations   │  │ - Voice commands            │   │ │
│   │  │ - Best practices    │  │ - Code review       │  │                             │   │ │
│   │  │ - Community Q&A     │  │ - Progress tracking │  │                             │   │ │
│   │  └─────────────────────┘  └─────────────────────┘  └─────────────────────────────┘   │ │
│   │                                                                                       │ │
│   │  ┌─────────────────────┐  ┌─────────────────────────────────────────────────────────┐│ │
│   │  │ AI Gaming Bots      │  │ AI Marketing Agent (Max Only)                           ││ │
│   │  │                     │  │                                                         ││ │
│   │  │ - 20 bot profiles   │  │ - Real-time data aggregation from DB, APIs, webhooks   ││ │
│   │  │ - Auto-simulation   │  │ - Intelligent email generation based on user behavior  ││ │
│   │  │ - Social proof      │  │ - Campaign suggestions from payment/subscription data  ││ │
│   │  │ - Leaderboard pop   │  │ - Bulk promo campaigns with CSV/Excel import           ││ │
│   │  │ - Skill tiers       │  │ - Win-back strategy recommendations                    ││ │
│   │  └─────────────────────┘  └─────────────────────────────────────────────────────────┘│ │
│   └───────────────────────────────────────────────────────────────────────────────────────┘ │
│                                           │                                                 │
├───────────────────────────────────────────│─────────────────────────────────────────────────┤
│   API & INTEGRATION LAYER                 │                                                 │
│   ┌───────────────────────────────────────┴───────────────────────────────────────────────┐ │
│   │                                                                                       │ │
│   │  ┌──────────────┐  ┌──────────────┐  ┌──────────────┐  ┌──────────────────────────┐  │ │
│   │  │ REST API     │  │ Webhooks     │  │ JWT Auth     │  │ Real-time Subscriptions │  │ │
│   │  │              │  │              │  │              │  │                          │  │ │
│   │  │ /api/users   │  │ Stripe       │  │ Supabase     │  │ Supabase Realtime        │  │ │
│   │  │ /api/courses │  │ GoodBarber   │  │ JWT tokens   │  │ Live leaderboards        │  │ │
│   │  │ /api/games   │  │ Resend       │  │ Role-based   │  │ Active user counts       │  │ │
│   │  │ /api/admin   │  │ Custom       │  │ Entitlements │  │ Game state sync          │  │ │
│   │  └──────────────┘  └──────────────┘  └──────────────┘  └──────────────────────────┘  │ │
│   └───────────────────────────────────────────────────────────────────────────────────────┘ │
│                                           │                                                 │
├───────────────────────────────────────────│─────────────────────────────────────────────────┤
│   DATA LAYER                              │                                                 │
│   ┌───────────────────────────────────────┴───────────────────────────────────────────────┐ │
│   │                                                                                       │ │
│   │  ┌──────────────────────┐  ┌──────────────────────┐  ┌──────────────────────────────┐│ │
│   │  │ Supabase PostgreSQL  │  │ Stripe              │  │ Resend Email                 ││ │
│   │  │                      │  │                      │  │                              ││ │
│   │  │ - Users & profiles   │  │ - Subscriptions     │  │ - Transactional emails       ││ │
│   │  │ - Subscriptions      │  │ - Payment history   │  │ - Marketing campaigns        ││ │
│   │  │ - Game stats         │  │ - Customer data     │  │ - Automation triggers        ││ │
│   │  │ - Learning progress  │  │ - Entitlements      │  │ - Template management        ││ │
│   │  │ - AI chat history    │  │ - Webhooks          │  │ - Delivery analytics         ││ │
│   │  │ - Bot profiles       │  │                      │  │                              ││ │
│   │  │ - Marketing leads    │  │                      │  │                              ││ │
│   │  └──────────────────────┘  └──────────────────────┘  └──────────────────────────────┘│ │
│   └───────────────────────────────────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────────────────────────────────┘

AI Systems

1. AI RAG Bot (Knowledge Assistant)

Retrieval-Augmented Generation bot with embedded knowledge of:

  • Terraform documentation and best practices
  • AWS, Azure, GCP provider configurations
  • Course content and lab solutions
  • Community questions and answers
  • Infrastructure patterns and anti-patterns
// Example RAG query flow
const response = await ragBot.query({
  question: "How do I configure S3 bucket versioning with Terraform?",
  context: {
    currentModule: "aws-storage-fundamentals",
    userLevel: "intermediate",
    previousQuestions: [...],
  }
});

2. AI Interactive Coach

Real-time learning assistant that:

  • Provides contextual hints during labs
  • Reviews code and suggests improvements
  • Tracks learning progress and adapts difficulty
  • Recommends next learning paths
  • Celebrates achievements and milestones

3. Platform Navigation AI

Intelligent assistant for platform discovery:

  • Context-aware feature suggestions
  • Personalized workflow recommendations
  • Voice command support
  • Accessibility enhancements
  • Quick action shortcuts

4. AI Gaming Bots (Social Proof System)

interface AIBot {
  id: string;
  displayName: string;
  country: string;
  avatar: string;
  stats: {
    gamesPlayed: number;
    winStreak: number;
    elo: number;
    tier: 'bronze' | 'silver' | 'gold' | 'platinum' | 'diamond';
  };
  behavior: {
    playStyle: 'aggressive' | 'defensive' | 'balanced';
    responseTime: { min: number; max: number };
    errorRate: number;
  };
}

// Bot simulation runs every 5 minutes
const botSimulation = {
  totalBots: 20,
  autoSimulation: true,
  simulationInterval: '*/5 * * * *',
  features: [
    'Appear in public leaderboards',
    'Show in "online now" counts',
    'Play simulated games for fresh stats',
    'Excluded from admin analytics',
  ],
};

5. AI Marketing Agent (Tcv7 AI)

Full-featured AI marketing assistant with platform knowledge:

interface MarketingAI {
  capabilities: [
    'Analyze users, subscriptions, and promo data',
    'Draft and send emails via Resend API',
    'Grant promo access to users',
    'Parse Excel/CSV name lists',
    'Suggest marketing and retention strategies',
    'Execute campaigns directly',
  ];
  
  dataAccess: {
    database: 'Full read access to all user/subscription tables',
    stripe: 'Customer and subscription data via API',
    resend: 'Email sending and analytics',
    goodbarber: 'Mobile app user data',
  };
  
  quickActions: [
    'User Summary',
    'Campaign Ideas',
    'Draft Upgrade Email',
    'Re-engagement',
    'Bulk Promo Campaign',
  ];
}

Marketing Platform (Max Only)

Admin Dashboard Sections

Section Description
Overview Live data: Total users, pending signups, active subscribers, trial users
Pending Signups Users who paid but haven't confirmed email
Live Analytics Real-time platform activity and metrics
All Users Complete user management with search and filters
Subscriptions Stripe subscription management with sync
Win-Back Targets Canceled, expired, and inactive users for re-engagement
Promo Users Trial and promotional access management
GB Pro Discounts GoodBarber mobile app user discounts
TA Pro Winback Legacy Pro user recovery campaigns
Email Actions Manual email triggers (confirmation, reset, magic link, invite)
Email Templates System and custom template management
Marketing & Leads Lead tracking with conversion rates
Automations Automated email sequences
AI Bots Bot system control for social proof
Tcv7 AI AI marketing assistant
Support Tools User lookup, trial extension, manual subscription
Activity Logs Platform activity audit trail

Email Automation System

automations:
  3_day_signup_reminder:
    trigger: "3 days after subscription created, user_id still NULL"
    template: "Signup Reminder (Magic Link)"
    description: "Remind users who paid but haven't confirmed email"
    
  5_day_final_reminder:
    trigger: "5 days after subscription, still no user_id"
    template: "Final Reminder (Urgency)"
    description: "Last chance reminder before trial expires"
    
  trial_expiring_soon:
    trigger: "1 day before preview expires"
    template: "Trial Expiring"
    description: "Notify users when preview pass is about to expire"
    
  welcome_email:
    trigger: "After successful signup"
    template: "Welcome Email"
    description: "Send welcome email after account confirmation"

Lead Management & Tracking

interface LeadTracking {
  sources: ['Stripe', 'GoodBarber', 'Direct', 'Referral'];
  
  metrics: {
    totalLeads: number;
    unconverted: number;      // Paid but no account
    converted: number;        // Active users
    conversionRate: number;   // Percentage
  };
  
  actions: [
    'Email via Resend',
    'Bulk email selected',
    'Export CSV',
    'View profile',
  ];
}

Win-Back Campaign System

interface WinBackTarget {
  categories: [
    'Canceled Subscription',
    'Expired Promo',
    'Inactive 30+ days',
  ];
  
  data: {
    email: string;
    gamerId: string;
    category: string;
    lastActive: Date;
    daysGone: number;
    previousStatus: 'Subscriber' | 'Trial' | 'Registered';
  };
  
  actions: ['Win Back', 'View Profile', 'Send Email'];
}

API Structure

Authentication & Authorization

// JWT-based authentication with Supabase
interface AuthConfig {
  provider: 'supabase';
  jwtSecret: process.env.SUPABASE_JWT_SECRET;
  
  roles: {
    user: ['read:own', 'write:own'],
    subscriber: ['read:own', 'write:own', 'access:premium'],
    admin: ['read:all', 'write:all', 'admin:full'],
  };
  
  entitlements: {
    pro: ['ai_rag_bot', 'ai_coach', 'pvp_arena', 'all_courses'],
    max: ['pro', 'admin_dashboard', 'marketing_suite', 'ai_marketing'],
  };
}

Core API Endpoints

# User Management
GET    /api/users                   # List users (admin)
GET    /api/users/:id               # Get user profile
PUT    /api/users/:id               # Update user
DELETE /api/users/:id               # Delete user (admin)

# Subscriptions
GET    /api/subscriptions           # List subscriptions
POST   /api/subscriptions/sync      # Sync from Stripe
POST   /api/subscriptions/manual    # Create manual subscription
PUT    /api/subscriptions/:id       # Update subscription

# Gaming
GET    /api/games/leaderboard       # Public leaderboard
GET    /api/games/stats/:userId     # User game stats
POST   /api/games/match             # Create match
PUT    /api/games/match/:id         # Update match result

# AI Services
POST   /api/ai/rag/query            # RAG bot query
POST   /api/ai/coach/hint           # Get coaching hint
POST   /api/ai/navigate             # Navigation assistance
POST   /api/ai/marketing/suggest    # Marketing suggestions

# Marketing (Admin)
GET    /api/admin/leads             # Lead list
GET    /api/admin/winback           # Win-back targets
POST   /api/admin/email/send        # Send email
POST   /api/admin/promo/grant       # Grant promo access
GET    /api/admin/automations       # Automation status
POST   /api/admin/bots/simulate     # Run bot simulation

Webhook Integrations

// Stripe webhook handlers
const stripeWebhooks = {
  'customer.subscription.created': handleNewSubscription,
  'customer.subscription.updated': handleSubscriptionUpdate,
  'customer.subscription.deleted': handleCancellation,
  'invoice.payment_succeeded': handlePaymentSuccess,
  'invoice.payment_failed': handlePaymentFailure,
};

// GoodBarber mobile app webhooks
const goodbarberWebhooks = {
  'user.registered': syncMobileUser,
  'subscription.purchased': linkMobileSubscription,
  'user.updated': updateMobileProfile,
};

// Resend email webhooks
const resendWebhooks = {
  'email.delivered': trackDelivery,
  'email.opened': trackOpen,
  'email.clicked': trackClick,
  'email.bounced': handleBounce,
};

Database Schema

-- Core user tables
CREATE TABLE profiles (
  id UUID PRIMARY KEY REFERENCES auth.users(id),
  email TEXT UNIQUE NOT NULL,
  display_name TEXT,
  gamer_id TEXT UNIQUE,
  avatar_url TEXT,
  tier TEXT DEFAULT 'free',
  created_at TIMESTAMPTZ DEFAULT NOW(),
  last_active TIMESTAMPTZ
);

-- Subscription management
CREATE TABLE subscriptions (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  user_id UUID REFERENCES profiles(id),
  stripe_customer_id TEXT,
  stripe_subscription_id TEXT,
  status TEXT NOT NULL,
  plan TEXT NOT NULL,
  current_period_start TIMESTAMPTZ,
  current_period_end TIMESTAMPTZ,
  cancel_at_period_end BOOLEAN DEFAULT FALSE,
  source TEXT DEFAULT 'stripe',
  created_at TIMESTAMPTZ DEFAULT NOW()
);

-- AI Bot profiles
CREATE TABLE ai_bots (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  display_name TEXT NOT NULL,
  country TEXT,
  avatar_url TEXT,
  elo INTEGER DEFAULT 1000,
  tier TEXT DEFAULT 'bronze',
  games_played INTEGER DEFAULT 0,
  win_streak INTEGER DEFAULT 0,
  is_online BOOLEAN DEFAULT FALSE,
  last_simulation TIMESTAMPTZ,
  play_style TEXT DEFAULT 'balanced'
);

-- Marketing leads
CREATE TABLE leads (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  email TEXT UNIQUE NOT NULL,
  source TEXT NOT NULL,
  stripe_customer_id TEXT,
  status TEXT DEFAULT 'unconverted',
  converted_user_id UUID REFERENCES profiles(id),
  emails_sent INTEGER DEFAULT 0,
  created_at TIMESTAMPTZ DEFAULT NOW()
);

-- Email automation tracking
CREATE TABLE email_automations (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  name TEXT NOT NULL,
  trigger_condition TEXT NOT NULL,
  template_id TEXT NOT NULL,
  is_active BOOLEAN DEFAULT TRUE,
  last_run TIMESTAMPTZ,
  emails_sent_24h INTEGER DEFAULT 0
);

-- Win-back targets view
CREATE VIEW winback_targets AS
SELECT 
  p.email,
  p.gamer_id,
  CASE 
    WHEN s.status = 'canceled' THEN 'Canceled Sub'
    WHEN p.last_active < NOW() - INTERVAL '30 days' THEN 'Inactive'
    ELSE 'Other'
  END as category,
  p.last_active,
  EXTRACT(DAY FROM NOW() - p.last_active) as days_gone,
  s.plan as previous_status
FROM profiles p
LEFT JOIN subscriptions s ON p.id = s.user_id
WHERE s.status = 'canceled' 
   OR p.last_active < NOW() - INTERVAL '30 days';

Tagging Standards

// User tagging for segmentation
const userTags = {
  lifecycle: ['new_signup', 'trial', 'subscriber', 'churned', 'winback'],
  engagement: ['active', 'inactive_7d', 'inactive_30d', 'power_user'],
  source: ['organic', 'referral', 'mobile_app', 'stripe_direct'],
  tier: ['free', 'pro', 'max', 'enterprise'],
};

// Email campaign tagging
const emailTags = {
  type: ['transactional', 'marketing', 'automation', 'winback'],
  template: ['welcome', 'reminder', 'upgrade', 'reengagement'],
  urgency: ['low', 'medium', 'high', 'critical'],
};

Support Tools

Tool Description
Lookup User Get complete profile, subscription, and gaming stats
Grant Trial Extension Add minutes to user's trial period
Link Stripe to User Fix orphaned subscriptions
Delete User Account Permanent deletion with confirmation
Create Manual Subscription For users who paid outside Stripe
Force Email Verification Bypass confirmation (customer support)

Tech Stack

Layer Technology
Frontend React 18, TypeScript, Tailwind CSS
State Zustand, React Query
Backend Supabase (PostgreSQL, Auth, Realtime, Edge Functions)
Payments Stripe (Subscriptions, Webhooks, Entitlements)
Email Resend (Transactional, Marketing, Automation)
AI OpenAI GPT-4, Custom RAG Pipeline, Embeddings
Mobile GoodBarber (iOS/Android apps)
Hosting Vercel (Frontend), Supabase (Backend)

License

PROPRIETARY - ALL RIGHTS RESERVED

This software and associated documentation files are proprietary and confidential. No part of this codebase may be reproduced, distributed, transmitted, displayed, published, or broadcast without the prior written permission of the copyright holder.

See LICENSE for full terms.


Enterprise learning platform with AI-powered everything