# DataGem Complete Technical Reference & Agent Specification Version: 2.0.0 Author: DataGem Engineering Team Canonical Domain: https://www.datagem.app API Host: https://api-production-cf34820e.up.railway.app ## 1. Product Overview DataGem is an enterprise financial intelligence and marketplace reconciliation workspace designed for multi-channel commerce (Amazon India, Flipkart, Shopify, WooCommerce) and subscription SaaS businesses. It combines an in-memory DuckDB columnar OLAP engine with Google Gemini Flash for natural language data interactions. ## 2. Core Domain Hubs ### 2.1 E-Commerce Marketplace Hub - **Target Channels**: Amazon Seller Central (MTR Reports, Settlement CSVs, Fee Invoices) and Flipkart Seller Hub (Settlement Sheets, SPF claims). - **Core Formula (Contribution Margin CM3)**: `CM3 = Gross GMV - COGS - Marketplace Commissions - Return Freight Pass-through - Pick & Pack Fees - Gateway Charges` - **Dispute Docket Generator**: Compiles statutory claim files with exact invoice references, order IDs, billed vs actual weight differentials, and Amazon/Flipkart policy citations. - **Price Elasticity Simulator**: Projects unit sales volume and net contribution delta for price adjustments between -20% and +20%. ### 2.2 SaaS & Subscription Intelligence Hub - **Metrics Tracked**: Net Revenue Retention (NDR), Annual Recurring Revenue (ARR), Churn Rate, Expansion ARR, Customer Lifetime Value (LTV), Payback Period. - **Cohort Analysis**: Monthly and quarterly retention curves computed via SQL window functions. ### 2.3 Ad-Hoc OLAP Studio - **Data Ingestion**: Multi-megabyte CSV and Excel uploads, Google Sheets URL export, public dataset URLs (with SSRF protection). - **Instant Profiling**: Zero-token column type inference, distinct count, null density, and duplicate detection. ## 3. Subscription & Monetization Tiers ### Starter Analyst ($0 / mo) - 15 Natural Language queries per day - Up to 10MB CSV upload support - Standard interactive Plotly charts - Community support ### Pro Growth ($29 / mo or ₹2,499 / mo) - 150 DuckDB queries per day - Up to 100MB dataset file uploads - Bi-weekly Watchdog Sentinel (Mon & Thu 8:00 AM alerts) - 3 Dispute Docket filings per month - Full Dynamic CM3 & Hidden Bleeders Ledger ### Autonomous Operator ($99 / mo or ₹7,999 / mo) - Unlimited natural language and SQL queries - 500MB dataset vault storage - Daily Watchdog alerts with custom timing - Unlimited 1-Click Amazon/Flipkart Dispute Claims & PDF export - Live marketplace connectors (Amazon SP-API, Flipkart, Shopify) - Price Elasticity & Buy Box War Room Simulator ### Enterprise Scale ($299 / mo or ₹24,999 / mo) - 5GB+ out-of-core Parquet processing - Multi-user Workspaces & Role-Based Access Control (RBAC) - Direct PostgreSQL, Snowflake, BigQuery sync - Dedicated solutions engineer & custom normalizer ## 4. API Endpoints Reference ### Authentication (`/auth`) - `POST /auth/signup` — Register new user account. - `POST /auth/login` — JSON authentication returning JWT bearer token. - `POST /auth/token` — OAuth2 form-data authentication. - `POST /auth/forgot-password` — Dispatches 6-digit verification OTP (rate limited to 3 req / 15 min). - `POST /auth/verify-otp` — Verifies OTP code. - `POST /auth/reset-password` — Updates account password after OTP verification. - `GET /auth/me` — Returns current authenticated user profile and tier. ### Intelligence & Reconciliation (`/profit-engine`) - `POST /profit-engine/cm3-audit` — Computes Contribution Margin 3 and hidden SKU leaks. - `POST /profit-engine/clawback-claims` — Detects weight discrepancy and volumetric fee spikes. - `POST /profit-engine/price-simulator` — Simulates price elasticity and margin delta. - `POST /profit-engine/generate-dispute-packet` — Formats official dispute dockets for Amazon & Flipkart. - `POST /profit-engine/buy-box-war-room` — Simulates Buy Box win probabilities and minimum price floors. ### Watchdog Sentinel (`/watchdog`) - `GET /watchdog/settings` — Returns user scan schedule and active status. - `POST /watchdog/settings` — Configures delivery days, time, and timezone. - `POST /watchdog/send-alert-test` — Dispatches instant test briefing to authenticated user's email. ## 5. Security & Privacy Guarantees - Zero-Retention In-Memory Processing: Datasets live in transient DuckDB tables during the session. - 12-round salted bcrypt password storage. - Rate limiting across auth and computational endpoints. - Strict Content-Security-Policy, HSTS, and X-Frame-Options headers. - SSRF validation blocking private RFC1918 subnets and cloud metadata IP (169.254.169.254).