Product Documentation · v1.0

Spoken English Course App

Complete business logic, database schema, admin panel features, and system architecture documentation for the Play Store app and backend platform.

📱 Flutter Android App 🖥️ React Admin Panel 🔧 Node.js + MySQL Backend ☁️ OCI Always Free Hosting

Table of Contents

  1. Platform Overview
  2. Course & Content Structure
  3. Subscription Plans & Access Control
  4. AI Sentence Correction & Credits
  5. Payments & Razorpay Integration
  6. Coupon Code System
  7. Referral Program
  8. Database Schema
  9. Admin Panel Modules
  10. Tech Stack
1

Platform Overview

What This App Does

A monetized Spoken English training app for Indian learners, delivered via a Flutter Android app on the Play Store. Users browse structured course modules, watch video classes, read Google Drive materials, submit Google Form assignments, and practice sentence correction powered by AI — all gated by subscription tier.

👤 For Learners (Android App)

  • Browse free & paid course modules
  • Watch YouTube video classes
  • Read Google Drive study materials
  • Submit Google Form assignments
  • AI sentence correction (Basic & Advanced)
  • Razorpay subscription & coupon codes
  • Referral link sharing via WhatsApp / Telegram

🛠️ For Admin (React Web Panel)

  • Manage modules, classes, attachments
  • Configure Razorpay keys
  • Generate & manage coupon codes
  • View subscription & revenue analytics
  • Monitor AI credit usage
  • Manage referral tracking
  • User management & subscription status
2

Course & Content Structure

Hierarchy: Module → Class (Video) → Attachments (Materials + Assignment). Each class carries an access tag that determines which subscribers can watch it.

📦 Module

A Module is the top-level grouping — e.g., "Foundation Level", "Intermediate Conversations", "Advanced Business English". Each module has a title, description, display order, and thumbnail image.

🎬 Class (Video Lesson)

Each class inside a module is a YouTube video rendered via WebView in the app. A class also carries an access tag controlling who can play it.

FREE — Open to all users BEGINNER — Beginner or Pro subscribers PRO — Pro subscribers only

📎 Study Materials

Each class can have one or more PDF / document attachments hosted on Google Drive. Rendered via WebView or opened with the Drive viewer.

📝 Assignment

Each class can link to a Google Form. Rendered inside the app via WebView so users submit without leaving the app. Admin can track responses via Google Sheets integration.

Access Control Logic (In-App)

When a user taps a class, the app compares the class tag against the user's active subscription status:

Class TagFREE UserBEGINNER SubscriberPRO Subscriber
FREE✅ Accessible✅ Accessible✅ Accessible
BEGINNER🔒 Locked✅ Accessible✅ Accessible
PRO🔒 Locked🔒 Locked✅ Accessible
3

Subscription Plans & Access Control

FREE
₹0
  • All FREE-tagged classes
  • Limited AI credits (to be defined)
  • No materials or assignments for paid classes
BEGINNER
₹199/mo
  • FREE + BEGINNER tagged classes
  • All materials & assignments
  • AI credit pack included
  • Coupon discounts applicable
PRO
₹399/mo
  • All classes (FREE + BEGINNER + PRO)
  • Higher AI credit allowance
  • Priority access to new content
  • Coupon discounts applicable

Subscription Lifecycle

1

User selects plan

User picks Beginner or Pro plan in the app. Coupon code optionally applied for discount.

2

Razorpay payment

Payment processed via Razorpay. On success, webhook fires to backend.

3

Backend updates subscription

user_subscriptions row created/updated with plan type, start date, expiry date.

4

Access unlocked

App checks subscription status on each class open. Locked classes show upgrade prompt.

5

Renewal / Expiry

On expiry, user reverts to FREE status. Renewal uses the same payment flow.

4

AI Sentence Correction & Credits

Every user has a credit balance. Each AI correction request deducts credits. When credits reach zero, the user must purchase more or wait for a plan refresh.

⚡ Basic Correction — 1 Credit

Grammar and spelling corrections. Quick fix for simple sentences. Powered by Grok xAI API (or Gemini fallback).

🚀 Advanced Correction — 2 Credits

Grammar + tone + fluency + vocabulary improvement. Detailed explanation of changes. Full rewrite with rationale.

Credit Flow

EventCredit ChangeNotes
New user signup (FREE)+5 creditsStarter credits
BEGINNER plan active+30 credits/monthAuto-top-up on renewal
PRO plan active+80 credits/monthAuto-top-up on renewal
Basic correction used−1 creditPer request
Advanced correction used−2 creditsPer request
Referral bonus (referred user pays)+5 creditsOne-time per referral
5

Payments & Razorpay Integration

Razorpay Setup

Admin configures Razorpay keys from the admin panel. The keys are stored securely in the backend environment (not hard-coded in the app). The app fetches order details from the backend before opening the Razorpay checkout.

Payment Flow

  1. User selects plan & enters coupon (optional)
  2. App calls backend: POST /api/orders/create
  3. Backend calculates final amount (after coupon)
  4. Razorpay order created on server
  5. App opens Razorpay SDK checkout
  6. On success: backend verifies signature
  7. Subscription record activated

Admin Configurable Keys

  • Razorpay Key ID
  • Razorpay Key Secret
  • Webhook Secret
  • Plan IDs (Beginner, Pro)
  • Test / Live mode toggle
6

Coupon Code System

Admin generates coupon codes manually. Each coupon has a discount percentage, optional usage limit, and expiry date. System coupons and user referral coupons share the same table.

Coupon Types

🏷️ Admin-Created Coupons

Created manually in the admin panel for promotions, launch offers, or event discounts. Can have usage limits and expiry dates.

🔗 User Referral Coupons

Auto-generated for every registered user. Shared via WhatsApp/Telegram along with the Play Store link. Gives a discount to the new user who applies it.

Coupon Validation Rules

CheckRule
ExpiryCurrent date must be ≤ expire_date
Usage Limittimes_used < max_uses (if max_uses is set)
Active StatusCoupon must be is_active = true
Self-ReferralUser cannot use their own referral coupon
Duplicate UseReferral coupon can only be used once per new user
7

Referral Program

Every registered user gets a unique referral coupon code stored in their user row. When they share the Play Store link + coupon code via WhatsApp or Telegram and someone registers using it, the referral is tracked and both parties benefit.
👤 Existing User
Has unique code: RAVI2024
📲 Shares link + code
WhatsApp / Telegram
📥 New User
Downloads app, registers
🎟️ Applies coupon
Gets discount on plan
🎁 Referrer earns
+5 AI credits

Referral Tracking Logic

When a new user registers with a referral code at payment time, the backend records the referral in the referrals table linking referrer_user_id → referred_user_id. Credit bonus to the referrer is applied on the referred user's first successful payment.

8

Database Schema

📋 users

ColumnTypeNotes
idINT PK AUTO_INCREMENTPrimary key
nameVARCHAR(100)
emailVARCHAR(150) UNIQUE
phoneVARCHAR(15)
password_hashVARCHAR(255)Bcrypt hashed
referral_codeVARCHAR(20) UNIQUEAuto-generated on signup
ai_creditsINT DEFAULT 5Current credit balance
subscription_statusENUM('free','beginner','pro')Denormalized for fast access checks
created_atTIMESTAMP
updated_atTIMESTAMP

📦 modules

ColumnTypeNotes
idINT PK AUTO_INCREMENT
titleVARCHAR(200)
descriptionTEXT
thumbnail_urlVARCHAR(500)
display_orderINTControls app listing order
is_activeTINYINT(1) DEFAULT 1
created_atTIMESTAMP

🎬 classes

ColumnTypeNotes
idINT PK AUTO_INCREMENT
module_idINT FK → modules.id
titleVARCHAR(200)
youtube_urlVARCHAR(500)YouTube embed/watch URL
descriptionTEXT
access_tagENUM('free','beginner','pro')Access control
display_orderINT
is_activeTINYINT(1) DEFAULT 1
created_atTIMESTAMP

📎 class_attachments

ColumnTypeNotes
idINT PK AUTO_INCREMENT
class_idINT FK → classes.id
typeENUM('material','assignment')Material = Drive link, Assignment = Google Form
titleVARCHAR(200)
urlVARCHAR(500)Google Drive or Google Form URL
display_orderINT
created_atTIMESTAMP

💳 user_subscriptions

ColumnTypeNotes
idINT PK AUTO_INCREMENT
user_idINT FK → users.id
planENUM('beginner','pro')
statusENUM('active','expired','cancelled')
started_atTIMESTAMP
expires_atTIMESTAMP
coupon_idINT FK → coupons.id NULLCoupon applied at payment
amount_paidDECIMAL(10,2)After discount
razorpay_order_idVARCHAR(100)
razorpay_payment_idVARCHAR(100)
created_atTIMESTAMP

🤖 ai_correction_log

ColumnTypeNotes
idINT PK AUTO_INCREMENT
user_idINT FK → users.id
correction_typeENUM('basic','advanced')
credits_usedINT1 or 2
input_textTEXTUser's original sentence
output_textTEXTAI-corrected sentence
created_atTIMESTAMP

🎟️ coupons

ColumnTypeNotes
idINT PK AUTO_INCREMENT
codeVARCHAR(30) UNIQUEe.g. LAUNCH30, RAVI2024
typeENUM('admin','referral')Admin-created or user referral
owner_user_idINT FK → users.id NULLFor referral coupons only
discount_percentDECIMAL(5,2)e.g. 20.00 = 20%
max_usesINT NULLNULL = unlimited
times_usedINT DEFAULT 0
expire_dateDATE NULLNULL = never expires
is_activeTINYINT(1) DEFAULT 1
created_atTIMESTAMP

🔗 referrals

ColumnTypeNotes
idINT PK AUTO_INCREMENT
referrer_user_idINT FK → users.idWho shared the code
referred_user_idINT FK → users.idNew user who used the code
coupon_idINT FK → coupons.idReferral coupon used
bonus_creditedTINYINT(1) DEFAULT 0Whether referrer got AI credit bonus
bonus_credited_atTIMESTAMP NULLWhen first payment triggered bonus
created_atTIMESTAMPWhen referral was recorded

⚙️ app_settings

ColumnTypeNotes
keyVARCHAR(100) PK
valueTEXT
updated_atTIMESTAMP

Stores: razorpay_key_id, razorpay_key_secret, razorpay_webhook_secret, razorpay_mode (test/live), plan prices, credit allocations per plan, referral bonus credits, etc.

9

Admin Panel Modules

The React admin panel is a separate web app authenticated with an admin JWT. It communicates with the same Node.js backend through protected /api/admin/* routes.
📦

Content Management

  • Create / Edit / Delete modules
  • Add / Edit / Delete classes
  • Set YouTube URL & access tag
  • Attach materials & assignment forms
  • Reorder modules & classes (drag)
  • Toggle active/inactive
💳

Razorpay Settings

  • Set Key ID & Key Secret
  • Set Webhook Secret
  • Toggle Test / Live mode
  • Set plan prices
  • View recent payment logs
🎟️

Coupon Management

  • Create admin coupons
  • Set discount % & expiry
  • Set max usage limit
  • Enable / disable coupons
  • View usage history per coupon
👥

User Management

  • List all users
  • View subscription status
  • View AI credit balance
  • Manually adjust credits
  • View referral history
  • Revoke / extend subscriptions
📊

Analytics Dashboard

  • Total active subscribers
  • Revenue by month (chart)
  • Plan distribution (pie chart)
  • New signups per day
  • AI credits consumed per day
  • Top referrers leaderboard
  • Coupon usage stats
🤖

AI Credit Settings

  • Set credits per plan on renewal
  • Set referral bonus credits
  • Set signup starter credits
  • View correction log
  • Set Grok API key
10

Tech Stack

📱 Android App

Flutter Dart WebView (YouTube) WebView (Google Forms) Razorpay Flutter SDK Play Store

🖥️ Admin Panel

React Vite Recharts / Chart.js Axios JWT Auth

🔧 Backend

Node.js Express.js MySQL JWT Razorpay Node SDK Grok xAI API

☁️ Infrastructure

OCI Always Free A1 Flex (ARM) Nginx PM2 Google Drive YouTube Embed Google Forms