跳到正文
GitHub·· 7 天前AI 评分12

Sree AI 多模态 AI SaaS 平台:支持 102+ 模型与 Gemini Live 实时语音

sree-ai-assistant/sree.ai

AI 导读

Sree AI 是一个全栈多模态 AI SaaS 平台,支持 NVIDIA NIM、Google Gemini、Groq、Deepgram 多提供商路由,可在 102+ 模型间切换,包括 Gemini 3.8 Flash、DeepSeek V4 Pro、Kimi K3 等。

正文

Sree AI — Next-Generation Multi-Modal AI SaaS Platform


🌟 Overview

Sree AI is a full-stack, production-ready AI SaaS platform built for high-throughput AI interactions. It offers seamless multi-provider AI model routing (NVIDIA NIM, Google Gemini, Groq, Deepgram), real-time conversational voice mode, multi-modal file analysis, image/video creation studio, a Bring-Your-Own-Key (BYOK) system with quota discounts, and an end-to-end Razorpay subscription lifecycle.

Designed with a dual-identity architecture, users can start chatting immediately without registration, experience progressive conversion nudges (2nd-response banner and 24-hour rate-limited 5th-response auth modal), and enjoy automatic conversation and quota migration upon signing up.


🚀 Key Features

💬 Multi-Model Conversational Chat

  • Multi-turn Contextual Chat: Streaming completions with real-time markdown rendering, LaTeX math support, sticky code block headers, and resilient text wrapping (word-break: break-word, overflow-wrap: anywhere) ensuring zero horizontal overflow or avatar collision.
  • Flagship AI Model Catalog: Seamlessly switch between 102+ models, featuring cutting-edge flagships: Gemini 3.8 Flash, DeepSeek V4 Pro, DeepSeek V4 Flash, DeepSeek V4.1 Flash, z-ai/glm-5.3, z-ai/glm-5.3-flash, Moonshot Kimi K3, GPT-OSS 120B/20B, Qwen 3.8 27B, Gemini 3.5 Flash Lite, LLaMA 3.3, and Nemotron 3.5.
  • Perplexity-Style Reasoning Drawer: Collapsible live thinking viewer that parses <think> streams in real-time with step execution timers, animated status indicators, and clean separation from final answers.
  • Sequenced Thinking Notifications: Responsive thinking animations in ThinkingAnimation cycling through an initial preparation notice (30s) and subsequent completion notification alert ("🔊 I Will Notify You, Once Done !!!").
  • Progressive Anonymous Conversion Funnel: Frictionless guest exploration with dual conversion nudges: (1) Subtle bottom banner above chat input after the 2nd AI response (session-persisted dismissal); (2) High-intent ChatGPT-styled modal dialog (AnonAuthModal) after the 5th AI response, strictly rate-limited to once every 24 hours with Google/GitHub OAuth and pre-filled email support.
  • Multi-Modal File Analysis: Upload and analyze PDFs, Word documents (.docx), Excel spreadsheets (.xlsx), images, audio recordings, and video clips (with hard 10-file safety cap, individual upload cancellation, and touch-and-drag scroll UX).
  • Native Gemini Multimodal & Uploads Cleanup Service: Native inline processing for Google Gemini models (handling PDFs, audio, and video directly with prompt context preservation) paired with an automated background 30-minute TTL disk cleanup service (TempCleanupService) to prevent transient storage leaks.
  • R2 Content Deduplication & Garbage Collection: Cryptographic SHA-256 hashing avoids storing duplicate files in Cloudflare R2, paired with database reference-counting triggers and automated weekly orphan sweeps.

🎙️ Real-Time Voice Assistant (Gemini Live & Cascading Fallback)

  • Gemini Live Bidirectional Streaming: Ultra-low-latency real-time voice mode powered by Google Gemini Live WebSockets (/api/live/voice/ws) with Web Audio API PCM Worklets (pcmWorklet.js).
  • 30+ Google AI Studio Voice Personas: User-selectable voices (Aoede, Puck, Zephyr, Fenrir, Despina, etc.) with live in-app audio previews and prompt personalization.
  • Audio Chimes & Visualizer: Includes native voice wake-up chime (Voice-mode-wakeup-tune.mp3), background tab chat completion notification (chat-inactive-completion-notifier.mp3), and organic Canvas thinking ring animation.
  • Cascading STT & TTS Fallback: Automatic failover to Deepgram Nova-2 STT $\rightarrow$ Chat LLM $\rightarrow$ TTS if WebSocket or network conditions degrade.
  • Tier-Based Session Guardrails: Tiered session duration limits (Free, Starter, Pro) with real-time countdown popups and high-traffic notices.

🩺 Self-Healing AI Model Error Observer

  • Automated Health Monitoring: Hybrid zero-latency in-memory error tracking backed by asynchronous PostgreSQL persistence (model_error_counters table).
  • Smart Circuit Breaker: Auto-flags models as in_maintenance = true upon encountering 5 consecutive failures of status codes 404, 410, 500, 502, or 503, preventing repeated user disruption.
  • 12-Hour Self-Healing Window: Stale unflagged counters automatically purge every 12 hours via reset_stale_error_counters RPC.
  • Live Diagnostics API: Instant visibility into in-memory counters and active database flags via GET /api/models/observer-status.

🎨 Creative Studio (Images & Videos)

  • AI Image Generation: Prioritizes FLUX.2 klein as the default high-speed studio model, alongside FLUX.1 (Dev/Schnell), SDXL, and SD 3.5 Large with local settings persistence, aspect ratios, and instant downloads.
  • Anonymous Download Limits: Built-in rate limiting (5 downloads/hr, 10 downloads/day) with interactive DownloadLimitModal prompting user registration.
  • AI Video Generation: Text-to-video capabilities powered by Google Veo 3.1 & Omni Flash models with automated Cloudflare R2 asset storage.

🌐 SEO & AEO (Answer Engine Optimization) Engine

  • Search & AI Discoverability: Built-in robots.txt granting verified search crawlers and welcoming AI answer engines (GPTBot, PerplexityBot, ClaudeBot, Applebot).
  • Dynamic Sitemaps & Agent Context: 15 canonical URLs mapped in sitemap.xml, plus lightweight llms.txt and exhaustive llms-full.txt for AI agent consumption and Schema.org JSON-LD structured data.

🔑 Bring Your Own Key (BYOK) & Key Pooling

  • Encrypted User Key Vault: Users can supply their own API keys (encrypted at rest using native AES-256-GCM with a unique 16-byte initialization vector iv per key) to unlock extended quotas with a 0.2x rate multiplier.
  • HMAC-SHA256 Blind Indexing (key_hash): Fast cryptographic blind index prevents duplicate key submissions across user vaults without decrypting database records.
  • Real-Time Pre-Flight Validation: Dedicated pre-validation endpoint (POST /api/user/settings/keys/validate) verifies credentials against live upstream provider endpoints (NVIDIA, Google, Groq, Deepgram) prior to vault persistence.
  • Multi-Window Submission Guardrails: Rate-limited key endpoints (5 requests/min burst, 10 requests/hour, 15 requests/day) prevent credential abuse and brute-force testing.
  • Full Key Lifecycle Management: Multi-key management with masked display, user-defined labels, active toggling (/settings/keys/:id/toggle), and instant key revocation/deletion.
  • Zero-Dependency Native Vector Logos: Inlined official vector SVGs for NVIDIA (#76B900), Google (4-color), Deepgram (#13EF93), and Groq (#F54F35) with 0 external network requests or bulky icon library dependencies.
  • Backend Key Pool Rotation: Server-side API key pool that rotates round-robin and automatically fails over when provider rate limits are hit.

💳 Tiered Subscriptions & Razorpay Billing

  • Flexible Tiers: Free, Starter, and Pro plans with customizable daily, monthly, and per-minute usage quotas.
  • Smart Subscription State Machine: Supports instant upgrades, deferred downgrades at billing-cycle end, auto-renewals, cancellation retention, and automated rollback on payment failure.
  • Webhook Idempotency: HMAC SHA-256 signature verification with duplicate event rejection and automated n8n failure notifications.

🛡️ Enterprise Rate Limiting & Abuse Prevention

  • Atomic Rate Limiting Engine: PostgreSQL RPC (increment_multi_usage) calculates per-minute, daily, and monthly quotas in a single atomic transaction.
  • Identity-Based Abuse Detection: Tracks browser fingerprints, salted IP hashes, rapid-request patterns, and disposable email detection without storing raw PII.

🏗️ System Architecture & Engineering Deep-Dive

1. Core End-to-End Topology

flowchart TD
    subgraph Client ["Frontend (React 19 + Vite + Zustand)"]
        UI[User Interface / Chat / Voice]
        Stores[Zustand State Stores]
        APIClient[Axios API Client + Interceptors]
    end

    subgraph Gateway ["Backend API (Express 5 + TypeScript)"]
        MW[Middleware: Rate Limit / Auth / Abuse Check]
        Router[API Route Handlers]
        AI_Router[AI Routing Engine & Key Pool Manager]
        Payment_Svc[Razorpay Billing & Webhook Handler]
    end

    subgraph Data ["Persistence & Storage"]
        SupaDB[(Supabase PostgreSQL + RLS)]
        SupaAuth[Supabase Auth Engine]
        R2[Cloudflare R2 Object Storage]
    end

    subgraph AI_Providers ["AI Inference Providers"]
        NVIDIA[NVIDIA NIM API]
        Google[Google Gemini API]
        Groq[Groq LLaMA / Whisper]
        Deepgram[Deepgram Nova-2 STT]
    end

    subgraph External ["Integrations"]
        Razorpay[Razorpay Payment Gateway]
        n8n[n8n Notification Webhooks]
        PostHog[PostHog Analytics]
    end

    UI --> Stores
    Stores --> APIClient
    APIClient -->|REST / SSE Streams| MW
    MW --> Router
    Router --> AI_Router
    Router --> Payment_Svc

    Router --> SupaAuth
    Router --> SupaDB
    Router --> R2

    AI_Router --> NVIDIA
    AI_Router --> Google
    AI_Router --> Groq
    AI_Router --> Deepgram

    Payment_Svc <--> Razorpay
    Payment_Svc --> n8n
    Router --> PostHog

Loading


2. Rate Limiting & Atomic Usage Tracking Architecture

The platform enforces quota boundaries across three time windows (1-minute bursts, daily limits, and monthly quotas) with single-transaction atomicity in PostgreSQL to eliminate race conditions.

flowchart TD
    Req["Incoming API Request"] --> MW["rateLimitEnforcement Middleware"]
    MW --> CheckID{"Identify Caller"}
    
    CheckID -->|Bearer JWT| AuthUser["Extract auth.uid<br/>Lookup profiles.plan_type"]
    CheckID -->|x-anon-id Header| AnonUser["Extract anon_id<br/>Hash IP & Fingerprint"]
    
    AuthUser --> TierLookup["Determine Tier Limits:<br/>Free / Starter / Pro"]
    AnonUser --> TierLookup
    
    TierLookup --> BYOKCheck{"Using BYOK Key?"}
    BYOKCheck -->|Yes| Multiplier["Apply 0.2x Quota Multiplier"]
    BYOKCheck -->|No| StdQuota["Apply 1.0x Full Quota"]
    
    Multiplier --> RPC["Call PostgreSQL RPC:<br/>increment_multi_usage"]
    StdQuota --> RPC
    
    subgraph Postgres_RPC ["PostgreSQL Atomic Transaction"]
        RPC --> RowLock["SELECT ... FOR UPDATE on usage_tracking"]
        RowLock --> WindowReset{"Has Window Expired?"}
        WindowReset -->|1-min passed| ResetMin["minute_count = 0"]
        WindowReset -->|24h passed| ResetDay["daily_count = 0"]
        WindowReset -->|30d passed| ResetMonth["monthly_count = 0"]
        
        ResetMin & ResetDay & ResetMonth --> LimitCheck{"Any Limit Exceeded?"}
        LimitCheck -->|Yes| Rollback["Return allowed = false<br/>(Exceeded burst or quota)"]
        LimitCheck -->|No| Commit["Increment counters + Sync profile<br/>Return allowed = true"]
    end
    
    Rollback -->|HTTP 429| Reject["Reject Request with Retry-After Header"]
    Commit --> ExecuteAI["Forward to AI Router"]

Loading


3. AI Model Resolution, Key Pooling & Fallback Retries

All AI requests flow through a resilient routing layer that manages API key pool rotation, provider failover, and automatic STT degradation.

sequenceDiagram
    autonumber
    actor Client
    participant Gateway as Express AI Router
    participant KeyPool as Key Pool Manager
    participant Provider as Primary Provider (NVIDIA / Google)
    participant Fallback as Fallback Provider (Groq / Whisper)
    participant Supa as Supabase DB

    Client->>Gateway: POST /api/ai/chat (Model ID, Messages, Stream: true)
    Gateway->>KeyPool: Get Active Key for Provider (Round-Robin)
    KeyPool-->>Gateway: Key #1 (Index: 0)

    Gateway->>Provider: Send Streaming Inference Request
    alt Primary Provider 200 OK
        Provider-->>Gateway: SSE Token Stream
        Gateway-->>Client: Forward SSE Data Chunks
    else Rate Limited (429) or Auth Error (401)
        Provider-->>Gateway: HTTP 429 Too Many Requests
        Gateway->>KeyPool: Mark Key #1 Cooldown & Rotate to Key #2
        KeyPool-->>Gateway: Key #2 (Index: 1)
        Gateway->>Provider: Retry Request with Key #2
        Provider-->>Gateway: SSE Token Stream
        Gateway-->>Client: Forward SSE Data Chunks
    else Provider Unreachable / 5xx Failover
        Gateway->>Fallback: Dispatch to Fallback Provider (Groq)
        Fallback-->>Gateway: SSE Token Stream
        Gateway-->>Client: Forward SSE Chunks with Provider Fallback Header
    end
    Gateway->>Supa: Commit Total Token & Request Usage

Loading


4. Subscription State Machine & Webhook Retry Pipeline

The billing system handles upgrade, downgrade, deferral, and payment failure events with guaranteed idempotency and rollback safety.

stateDiagram-v2
    [*] --> Free: User Signs Up
    Free --> Starter: Razorpay Checkout (Starter Plan)
    Free --> Pro: Razorpay Checkout (Pro Plan)
    
    state Starter {
        [*] --> Active_Starter
        Active_Starter --> Upgrading_To_Pro: Select Pro (Activate Now)
        Active_Starter --> Deferred_Pro: Select Pro (Deferred at Cycle End)
        Active_Starter --> Cancelling_Starter: Cancel Subscription
    }
    
    state Pro {
        [*] --> Active_Pro
        Active_Pro --> Deferred_Starter: Downgrade (Deferred at Cycle End)
        Active_Pro --> Cancelling_Pro: Cancel Subscription
    }
    
    Upgrading_To_Pro --> Active_Pro: subscription.charged Webhook
    Deferred_Pro --> Active_Pro: Cycle End Reached
    Deferred_Starter --> Active_Starter: Cycle End Reached
    
    Cancelling_Starter --> Free: subscription.cancelled (at Period End)
    Cancelling_Pro --> Free: subscription.cancelled (at Period End)

    state "Payment Failure & Retry" as FailureHandler {
        Active_Pro --> Retry_Pending: payment.failed Webhook
        Retry_Pending --> Active_Pro: Retry Succeeded
        Retry_Pending --> Rollback_Free: Retries Exhausted (Max 3 Attempts)
    }

    Rollback_Free --> Free: Restore Previous Tier + Trigger n8n Alert

Loading


💻 Tech Stack

Layer Technologies
Frontend React 19, TypeScript, Vite, TailwindCSS, Radix UI, Lucide Icons, Zustand, Axios, Canvas Confetti
Backend Node.js (v20+), Express 5, TypeScript, SSE (Server-Sent Events), Node Crypto (AES-256-GCM)
Database & Auth Supabase (PostgreSQL 15+), Row Level Security (RLS), PL/pgSQL Atomic RPCs
File & Media Storage Cloudflare R2 (S3-compatible bucket storage), Multer
Payment Gateway Razorpay Subscriptions & Orders API, Webhook Signature Verification
AI Inference NVIDIA NIM, Google Gemini, Groq, Deepgram
Observability PostHog Product Analytics & Error Tracking, n8n Workflow Automations

📁 Repository Structure

.
├── backend/                  # Express 5 backend service
│   ├── src/
│   │   ├── config/           # Plans, models, rate-limits, and app constants
│   │   ├── middleware/       # Auth, anonymous identity, rate-limiting, abuse prevention
│   │   ├── routes/           # AI, payment, user, auth, and feature request routes
│   │   ├── services/         # AI routing, STT fallback, key-pool, storage, usage engine
│   │   └── lib/              # Supabase admin client and helper utilities
│   └── package.json
│
├── frontend/                 # React 19 single-page application
│   ├── public/               # Static assets & SEO/AEO files (robots.txt, sitemap.xml, llms.txt)
│   ├── src/
│   │   ├── components/       # Layout, modals, chat, voice, studio, and ui/ primitives
│   │   ├── features/         # Feature modules (auth, dashboard, feature-requests)
│   │   ├── pages/            # Core pages (Chat, Image, Video, Dashboard, Settings, Pricing, etc.)
│   │   ├── pages-legal/      # Legal Center pages (Terms, Privacy, Security, etc.)
│   │   ├── hooks/            # Custom React hooks (voice recording, payments, SSE)
│   │   ├── store/            # Zustand state management (auth, chat, image, video, models, UI)
│   │   ├── services/         # Frontend API integration layer
│   │   └── styles/           # Global styles and design system variables
│   └── package.json
│
├── shared/                   # Shared TypeScript models, schemas & plan constants (@sree/shared)
│   ├── src/
│   │   ├── types/            # User, conversation, model, and subscription definitions
│   │   └── constants/        # Shared tier configurations & tool limits
│   └── package.json
│
├── legal/                    # Watertight legal policies & statutory compliance suite
│   ├── 01-privacy-policy.md
│   ├── 02-terms-of-service.md
│   ├── 03-security-and-byok-policy.md
│   ├── 04-refund-and-cancellation-policy.md
│   ├── 05-acceptable-use-policy.md
│   └── 06-cookie-policy.md
│
├── project-context/          # Complete architectural & technical documentation
│   ├── 01-project-overview.md
│   ├── 02-tech-stack.md
│   ├── 03-architecture.md
│   ├── 04-authentication-and-users.md
│   ├── 05-payment-and-subscriptions.md
│   ├── 06-features-and-pages.md
│   ├── 07-api-reference.md
│   ├── 08-database-schema.md
│   ├── 09-ui-ux-design.md
│   ├── 10-security-and-rate-limiting.md
│   └── full-schema.sql       # 100% production-verified ready-to-run database schema
│
├── supabase/migrations/      # 30 sequential PostgreSQL migration files
├── .env.example              # Environment variables template
└── README.md

🚦 Getting Started

Prerequisites

  • Node.js: v20.0.0 or higher
  • npm or pnpm
  • Supabase Account: A new or existing project
  • Razorpay Account: Live or Test Mode credentials
  • AI Provider API Keys: At least one key from NVIDIA NIM, Google AI Studio, or Groq

Installation & Setup

  1. Clone the repository:

    git clone https://github.com/your-username/sree-ai.git
    cd sree-ai
  2. Install dependencies:

    # Install dependencies across all workspaces (root, frontend, backend, shared)
    npm install
  3. Configure Environment Variables:

    Create .env in backend/:

    PORT=5000
    NODE_ENV=development
    FRONTEND_URL=http://localhost:5173
    
    # Supabase Configuration
    SUPABASE_URL=https://your-project.supabase.co
    SUPABASE_ANON_KEY=your_supabase_anon_key
    SUPABASE_SERVICE_ROLE_KEY=your_supabase_service_role_key
    
    # AI Provider Keys (supports single or comma-separated keys for pool rotation)
    NVIDIA_API_KEY=your_nvidia_api_key
    # NVIDIA_API_KEYS=nvapi-key1,nvapi-key2
    GOOGLE_API_KEY=your_google_gemini_key
    # GOOGLE_API_KEYS=key1,key2
    GROQ_API_KEY=your_groq_api_key
    # GROQ_API_KEYS=gsk-key1,gsk-key2
    DEEPGRAM_API_KEY=your_deepgram_api_key
    # DEEPGRAM_API_KEYS=key1,key2
    
    # Gemini Live API Voice (uses GOOGLE_API_KEY pool — no extra key needed)
    # Models are tried in order: first → second → third (fallback cascade)
    GEMINI_LIVE_MODELS=gemini-3.8-live,gemini-3.1-flash-live-preview,gemini-2.5-flash-native-audio-preview-12-2025
    GEMINI_LIVE_VOICE=Puck
    
    # BYOK Key Encryption (32-character hex key)
    ENCRYPTION_KEY=your_32_character_hex_encryption_key
    
    # Razorpay Payment Gateway
    RAZORPAY_KEY_ID=your_razorpay_key_id
    RAZORPAY_KEY_SECRET=your_razorpay_key_secret
    RAZORPAY_WEBHOOK_SECRET=your_razorpay_webhook_secret
    
    # Cloudflare R2 Storage (File Uploads & Media Assets)
    CLOUDFLARE_R2_ACCESS_KEY_ID=your_r2_access_key
    CLOUDFLARE_R2_SECRET_ACCESS_KEY=your_r2_secret_key
    CLOUDFLARE_R2_BUCKET_NAME=chat-files
    CLOUDFLARE_R2_ENDPOINT=https://your_account_id.r2.cloudflarestorage.com
    CLOUDFLARE_R2_PUBLIC_URL=https://pub-your-r2-dev-url.r2.dev
    IMAGE_GENERATION_PUBLIC_URL=https://imggen.yourdomain.com
    VIDEO_GENERATION_PUBLIC_URL=https://videogen.yourdomain.com
    FEATURE_REQUEST_R2_BUCKET_NAME=feature-request
    FEATURE_REQUEST_R2_PUBLIC_URL=https://frss.yourdomain.com
    
    # Feature Request & Bug Report Webhook (backend only)
    FEATURE_REQUEST_WEBHOOK_URL=https://your.webhook.url/webhook/uuid
    FEATURE_REQUEST_WEBHOOK_SECRET=your_webhook_secret
    
    # n8n Webhook for Payment Failure Email Notifications
    N8N_WEBHOOK_SECRET=your_n8n_webhook_secret
    N8N_PAYMENT_FAILURE_WEBHOOK_URL=https://your.webhook.url/webhook/uuid
    
    # PostHog Analytics & Error Tracking (Backend)
    POSTHOG_PROJECT_TOKEN=your_posthog_project_token
    POSTHOG_HOST=https://us.i.posthog.com
    
    # Admin Secret for Internal Maintenance & Health Checks
    ADMIN_SECRET=your_admin_secret_key_here

    Create .env in frontend/:

    VITE_SUPABASE_URL=https://your-project.supabase.co
    VITE_SUPABASE_ANON_KEY=your_supabase_anon_key
    VITE_API_URL=http://localhost:5000/api
    VITE_API_BASE_URL=http://localhost:5000/api
    
    # PostHog Analytics & Error Tracking (Frontend)
    VITE_POSTHOG_PROJECT_TOKEN=your_posthog_project_token
    VITE_POSTHOG_HOST=https://us.i.posthog.com
  4. Initialize Database: Run the ready-to-use schema script in your Supabase SQL Editor:

    • Copy contents of project-context/full-schema.sql and execute.
  5. Start Local Development:

    # Run Backend (Port 5000)
    cd backend
    npm run dev
    
    # In a separate terminal, run Frontend (Port 5173)
    cd frontend
    npm run dev

🗄️ Database & RLS Setup

The database utilizes Supabase PostgreSQL with strict Row Level Security (RLS) on all 19 tables, managed via 30 sequential migrations in supabase/migrations/:

  • All-In-One Production Script: project-context/full-schema.sql
  • Included Tables:
    • profiles: User account details, legal consent, and synced limits
    • subscriptions: Razorpay subscription state machine
    • payment_history: Idempotent transaction logs
    • conversations & messages: Chat persistence (Auth & Anonymous)
    • file_uploads: Cloudflare R2 content-addressable deduplication records and reference counts
    • anonymous_users: Identity fingerprinting and usage tracking
    • usage_tracking: Unified per-minute, daily, and monthly rate counters
    • api_keys: Encrypted BYOK key vault (with HMAC-SHA256 key_hash blind indexing)
    • ai_models: Dynamic AI model capabilities catalog (102+ models)
    • model_error_counters: Circuit breaker consecutive failure logs
    • feature_requests: Integrated ticket submission and status tracking
    • user_images & user_videos: Studio generation asset metadata
    • user_sessions & trusted_devices: Session and security management
    • abuse_flags, app_config, & cleanup_logs: Governance and operational diagnostics

🔌 API Endpoints Overview

Scope Method Endpoint Description
AI POST /api/ai/chat Streaming SSE multi-turn chat completion
AI POST /api/ai/image Text-to-image studio generation (FLUX.2 klein default)
AI POST /api/ai/video Text-to-video studio generation (Veo 3.1 / Omni Flash)
AI POST /api/ai/stt Cascading speech-to-text audio transcription
AI POST /api/ai/tts Text-to-speech voice synthesis
Billing POST /api/payment/create-subscription Initiates Razorpay checkout session
Billing POST /api/payment/verify Validates payment signature & activates plan
Billing POST /api/payment/webhook Handles recurring charges, failures, & cancellations
Billing POST /api/payment/cancel Schedules downgrade at end of current cycle
User GET /api/user/profile Retrieves profile, active plan, and real-time quotas
User PATCH /api/user/profile Updates system prompts & personal preferences
User GET /api/user/sessions Retrieves active user sessions and trusted devices
User POST /api/user/sessions/sync Syncs client device fingerprint & session state
Keys POST /api/user/settings/keys/validate Tests & validates BYOK key against provider upstream
Keys POST /api/user/settings/keys Saves user BYOK API key (encrypted AES-256-GCM)
Keys GET /api/user/settings/keys Retrieves saved BYOK keys with masked previews
Keys PATCH /api/user/settings/keys/:id/toggle Enables or disables an active BYOK key
Keys DELETE /api/user/settings/keys/:id Revokes and deletes a saved BYOK key from vault
Models GET /api/models/observer-status Live circuit breaker & error observer telemetry
Feature POST /api/feature-requests Submits feature requests / bug reports
Config GET /api/config/public Retrieves whitelisted public runtime configuration
Admin POST /api/admin/r2/health-check Performs R2 bucket integrity check (x-admin-secret)
Admin POST /api/admin/r2/garbage-collect Cleans up orphaned R2 files (x-admin-secret)
Admin GET /api/admin/r2/status Reports R2 storage metrics & orphan count (x-admin-secret)

Detailed request/response contracts available in project-context/07-api-reference.md.


🔒 Security & Privacy

  1. Zero Raw Key Storage (BYOK): User-provided API keys are encrypted at rest using AES-256-GCM with a unique Initialization Vector (iv) per key.
  2. Blind Indexing for BYOK Vault (key_hash): Key lookups and duplicate prevention use HMAC-SHA256 blind indexing keyed with the master encryption secret, avoiding full-table decryption or ciphertext leakage.
  3. Multi-Window Key Submission Guardrails: Rate limits key save and validation routes (5 req/min burst, 10 req/hour, 15 req/day) to prevent key brute-forcing and provider quota exhaustion.
  4. Payment Webhook Verification: Razorpay webhooks require strict HMAC-SHA256 signature verification; unverified payloads are discarded immediately.
  5. No Plaintext IP Storage: Anonymous visitors are tracked using salted SHA-256 hashes of client fingerprints and IPs to comply with GDPR & CCPA.
  6. Row Level Security (RLS): Enforced across 100% of exposed tables to isolate tenant data.
  7. Isolated Local Brand Marks: Zero external runtime CDN hotlinking for provider branding, eliminating external telemetry or asset injection vectors.

⚖️ Legal & Compliance Documentation

Sree AI operates under a comprehensive legal, statutory compliance, and zero-liability framework designed in strict accordance with the Digital Personal Data Protection (DPDP) Act, 2023, the Information Technology Act, 2000 (Section 79 Intermediary Safe Harbor), GDPR, and CCPA/CPRA.

All policies are maintained as markdown source files in legal/ and are served through responsive, accessible web pages in the frontend:

Policy Markdown Document Public App Route Core Coverage & Statutory Protections
Legal Center legal/ /legal Central statutory compliance hub with categorized directory of all legal policies, disclaimers, and dispute pathways.
Privacy Policy legal/01-privacy-policy.md /privacy DPDP Act 2023 data rights, 9 sub-processors, zero raw IP storage, AI provider transmission disclosures, and designated Grievance Officer.
Terms of Service legal/02-terms-of-service.md /terms Section 79 IT Act safe harbor, Zero-Liability shield for cloud/database breaches, 100% user sole liability for uploaded files/BYOK, and Indian arbitration.
Security & BYOK Policy legal/03-security-and-byok-policy.md /security AES-256-GCM encryption architecture, HMAC-SHA256 blind indexing, 100% table RLS matrix, and Shared Responsibility Framework.
Refund & Cancellation Policy legal/04-refund-and-cancellation-policy.md /refund-policy Consumable digital service rules, in-app self-service cancellations, 3 exception categories, and 5–7 business days Razorpay refund SLA.
Acceptable Use Policy (AUP) legal/05-acceptable-use-policy.md /acceptable-use Zero-tolerance for CSAM (NCMEC referral), bans on deepfakes/malware/DDoS/proxy circumvention, and prohibitions on certified high-risk decisions.
Cookie Policy legal/06-cookie-policy.md /cookies Complete transparency for Supabase Auth JWTs, anonymous guest tokens, PostHog telemetry cookies (zero PII), local UI preferences, and client conversion state tokens (sree_anon_banner_dismissed, sree_anon_modal_last_shown_at).

📄 License

This project is proprietary and closed-source. All rights reserved.

Unauthorized copying, distribution, modification, or commercial use of any part of this software without explicit permission is strictly prohibited.

来源:GitHub · github.com