Getting Started

StartupDeckAI Documentation

Everything you need to build, deploy, and scale your StartupDeckAI platform.

Getting Started

Quick Start

Get StartupDeckAI running on your machine in under 5 minutes.

Prerequisites: Node.js 20+, PostgreSQL 14+, Redis 6+ (optional), Git

1. Clone the Repository

bash
git clone https://github.com/trynayash/StartupDeckAI.git
cd StartupDeckAI

2. Install Dependencies

bash
npm install

3. Environment Setup

bash
cp .env.example .env
# Edit .env with your configuration

4. Database Setup

bash
npm run db:push
npm run create-admin

5. Start Development Server

bash
npm run dev

Visit http://localhost:5000 to see the application.

Getting Started

Installation

Detailed installation guide including all dependencies and services.

Required Services

ServiceVersionPurpose
Node.js20+Runtime environment
PostgreSQL14+Primary database
Redis6+Caching & queues (optional)
GitLatestVersion control

Production Dependencies

bash
npm install stripe speakeasy qrcode ioredis express-rate-limit helmet compression

Available Scripts

CommandDescription
npm run devStart development server
npm run buildBuild for production
npm startStart production server
npm run checkTypeScript type checking
npm run db:pushPush database schema
npm run create-adminCreate admin user
npm testRun unit tests
npm run lintLint codebase
Getting Started

Environment Setup

Configure all environment variables required for the application.

Create a .env file in the root directory with the following variables:

env
# Database
DATABASE_URL=postgresql://username:password@localhost:5432/startupdeck
REDIS_URL=redis://localhost:6379

# Architecture & URLs
BASE_URL=http://localhost:5000
VITE_API_BASE_URL=http://localhost:5000
FRONTEND_URL=http://localhost:5000

# Authentication
SESSION_SECRET=your-super-secret-key
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
GITHUB_CLIENT_ID=your-github-client-id
GITHUB_CLIENT_SECRET=your-github-client-secret

# Email (SMTP)
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
[email protected]
SMTP_PASS=your-app-password

# Payments
razorpay_key_id=rzp_test_...
razorpay_key_secret=...

# AI Service
OPENAI_API_KEY=sk-...

# Application
NODE_ENV=development
PORT=5000
Production Payments: To switch to live mode, update RAZORPAY_ENVIRONMENT to live and replace test keys with live keys (starting with rzp_live_).
Architecture

System Architecture

High-level overview of StartupDeckAI's split-architecture design.

Frontend — Vercel

  • React 18 + TypeScript
  • Vite build tool
  • Tailwind CSS + Shadcn UI
  • TanStack Query
  • Framer Motion

Backend — Render

  • Node.js + Express
  • Drizzle ORM
  • Passport.js Auth
  • Redis + BullMQ
  • Prerender.io SEO

Data Layer

  • PostgreSQL (Neon.tech)
  • Redis Cache
  • File Storage
  • Session Store
Architecture

Frontend (Vercel)

The client-side React application built with modern web technologies.

Tech Stack

TechnologyPurpose
React 18UI framework with concurrent features
TypeScriptType-safe codebase
WouterLightweight client-side routing
Tailwind CSSUtility-first styling
Shadcn UIBeautifully designed component library
Framer MotionPremium UI animations
TanStack QueryServer state management
ViteLightning-fast build tool with HMR

Project Structure

text
client/
├── src/
│   ├── components/     # Reusable UI components
│   ├── pages/          # Page components
│   ├── hooks/          # Custom React hooks
│   ├── lib/            # Utility functions
│   └── services/       # API service layer
├── index.html
└── vite.config.ts
Architecture

Backend (Render)

Express-based API server with services architecture.

Service Architecture

text
server/
├── services/
│   ├── notificationService.ts    # Email notifications
│   ├── advancedCacheService.ts   # Redis caching
│   ├── analyticsService.ts       # Analytics & reporting
│   ├── monitoringService.ts      # System monitoring
│   ├── advancedAIService.ts      # Enhanced AI features
│   ├── backupService.ts          # Backup & recovery
│   └── adminService.ts           # Admin operations
├── middleware/
│   ├── adminAuth.ts              # Admin authentication
│   ├── advancedRateLimiting.ts   # Rate limiting
│   └── prerender.ts              # SEO Optimization
└── routes/
    ├── auth.ts                   # Authentication (OAuth/Local)
    ├── analysis.ts               # Analysis endpoints
    ├── admin.ts                  # Admin routes
    └── webhooks.ts               # Payment webhooks
Architecture

Database Schema

Core database tables powered by PostgreSQL and Drizzle ORM.

sql
-- Core Tables
users (id, email, name, role, subscription_plan)
startup_ideas (id, user_id, title, description, industry)
analysis_results (id, idea_id, analysis_data, created_at)
subscriptions (id, user_id, plan_type, status, billing_cycle)
usage_tracking (id, user_id, feature, usage_count, date)
payment_transactions (id, user_id, amount, status, payment_method)
system_logs (id, event_type, user_id, details, timestamp)

Database Commands

bash
# Push schema to database
npm run db:push

# Create admin user
npm run create-admin
Deployment

Deployment Guide

Deploy StartupDeckAI with a split architecture for maximum performance.

Split Architecture: Frontend on Vercel for edge-fast delivery, Backend on Render for server reliability. Custom domains: startupdeck.in (frontend) + api.startupdeck.in (backend).

Post-Deployment Checklist

Deployment

Vercel (Frontend)

Deploy the React frontend to Vercel for edge-optimized delivery.

Configuration

SettingValue
Repo RootStartupDeckAI
Build Commandvite build
Output Directorydist/client
Env VarsVITE_API_BASE_URL=https://api.startupdeck.in

Deploy Steps

bash
# Install Vercel CLI
npm install -g vercel

# Deploy
vercel --prod
Deployment

Render (Backend)

Deploy the Express backend to Render for reliable API hosting.

Configuration

SettingValue
Repo RootStartupDeckAI
Build Commandnpm install --include=dev && npm run build
Start Commandnpm start
Health Check/health
Custom Domainapi.startupdeck.in

Environment Variables

Set these in the Render dashboard:

env
NODE_ENV=production
DATABASE_URL=your-database-url
SESSION_SECRET=your-secret
BASE_URL=https://api.startupdeck.in
FRONTEND_URL=https://startupdeck.in
Deployment

Docker Setup

Self-hosted deployment using Docker and Docker Compose.

Dockerfile

dockerfile
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
RUN npm run build
EXPOSE 5000
CMD ["npm", "start"]

Docker Compose

yaml
version: '3.8'
services:
  app:
    build: .
    ports:
      - '5000:5000'
    environment:
      - DATABASE_URL=${DATABASE_URL}
      - REDIS_HOST=redis
    depends_on:
      - redis
      - postgres

  redis:
    image: redis:7-alpine
    ports:
      - '6379:6379'

  postgres:
    image: postgres:14-alpine
    environment:
      - POSTGRES_DB=startupdeck
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=password
    volumes:
      - postgres_data:/var/lib/postgresql/data

volumes:
  postgres_data:
Admin

Admin Setup

Create and configure administrator accounts.

Create Admin User

bash
# Using default credentials
npm run create-admin

# Using custom credentials
[email protected] ADMIN_PASSWORD=yourpass npm run create-admin

Default Credentials

⚠️ Change these immediately in production!
FieldDefault Value
Usernameadmin
Email[email protected]
Passwordadmin123456
Admin Levelsuper_admin
Admin

Dashboard Guide

Navigate the comprehensive admin dashboard for system management.

Dashboard Tabs

📊 Overview

System stats, health status, and recent activity

👥 Users

User management and role administration

📈 Analytics

Detailed analytics and reporting dashboards

🔍 Monitoring

Real-time system health and performance

💾 Backup

Backup scheduling and recovery management

📝 Logs

System logs and event tracking

Admin

User Management

Manage users, roles, and permissions through the admin panel.

Roles

RoleAccess LevelCapabilities
userStandardCreate analyses, manage own profile
adminElevatedUser management, analytics view
super_adminFullAll features including system config
API Reference

Authentication

Authenticate with the StartupDeckAI API using sessions or OAuth.

Local Authentication

POST /api/auth/login
json
{
  "email": "[email protected]",
  "password": "your-password"
}

OAuth Providers

GET /api/auth/google
GET /api/auth/github

Session Check

GET /api/auth/me

Returns the currently authenticated user object or 401 if not authenticated.

API Reference

Analysis Endpoints

Create AI-powered startup analyses and retrieve results.

Create Analysis

POST /api/analysis
json
{
  "title": "My Startup Idea",
  "description": "A detailed description of the startup concept...",
  "industry": "SaaS",
  "targetMarket": "B2B"
}

Get Analysis Results

GET /api/analysis/:id

List User Analyses

GET /api/analysis
API Reference

Webhooks

Handle payment and subscription events via webhooks.

Razorpay Webhook

POST /api/webhooks/razorpay

Receives payment status updates from Razorpay. Configure the webhook URL in your Razorpay dashboard to point to https://api.startupdeck.in/api/webhooks/razorpay.

Supported Events

  • payment.captured — Payment successfully captured
  • payment.failed — Payment failed
  • subscription.activated — Subscription activated
  • subscription.cancelled — Subscription cancelled
API Reference

Health Checks

Monitor system health and service availability.

GET /health
GET /api/health/database
GET /api/health/redis
bash
curl https://api.startupdeck.in/health
Developer API & SDK

SDK Overview

Integrate StartupDeckAI validation into your product with API keys and the REST API v2.

Get started: Open the API Dashboard to generate keys and recharge credits (₹1 = 1 API call, minimum recharge ₹500).

Authentication

Include your API key on every request:

bash
curl -X POST https://api.startupdeck.in/api/v2/analyze \
  -H "X-API-Key: sk_live_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{"title":"My Idea","description":"...","industry":"SaaS","location":"India"}'

Interactive API schema

Discover all v2 routes programmatically:

GET /api/v2/docs

Node.js example

typescript
const res = await fetch('https://api.startupdeck.in/api/v2/analyze', {
  method: 'POST',
  headers: {
    'X-API-Key': process.env.STARTUPDECK_API_KEY,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    title: 'Urban fleet routing',
    description: 'Dynamic routing for last-mile delivery fleets.',
    industry: 'Logistics',
    location: 'India',
    options: { includeCompetitors: true, includeMarketData: true },
  }),
});
const data = await res.json();
Developer API & SDK

API Keys & Credits

Manage keys, balances, and pay-as-you-go billing from the API Dashboard.

Generate an API key

  1. Sign in and open /api-dashboard.
  2. Click Generate Key.
  3. Copy the full key immediately — it is only shown once. Later views show a masked key.
Security: Delete compromised keys from the dashboard; access is revoked instantly.

Dashboard API (session auth)

EndpointMethodDescription
/api/developer/keysGETList your API keys (masked)
/api/developer/keysPOSTCreate a new API key
/api/developer/keys/:idDELETERevoke a key
/api/developer/usageGETCredit balance and usage stats
/api/developer/checkoutPOSTCreate Razorpay recharge order
/api/developer/verify-paymentPOSTVerify payment and add credits

Credits

RuleValue
Rate₹1 = 1 API call
Minimum recharge₹500
ExpiryCredits do not expire while the account is active
Developer API & SDK

API v2 Reference

Primary programmatic endpoints for AI analysis and market data.

Analyze startup idea

POST /api/v2/analyze
json
{
  "title": "My Startup Idea",
  "description": "Detailed concept description...",
  "industry": "SaaS",
  "location": "India",
  "options": {
    "includeCompetitors": true,
    "includeMarketData": true,
    "includeFinancials": true,
    "enhanced": false
  }
}

Instant analyze

POST /api/v2/instant-analyze

Faster, lighter validation for low-latency workflows.

Market data

GET /api/v2/market-data?industry=SaaS&location=India

Usage stats

GET /api/v2/usage

Rate limits

PlanLimit
Free100 requests / hour
Pro1,000 requests / hour
Enterprise10,000 requests / hour
Platform Features

Product Features

AI-powered tools available in the StartupDeck web app beyond core idea validation.

Tip: Most features consume plan usage limits. Check Pricing for quotas; API calls use separate pay-as-you-go credits.
Security

Two-Factor Authentication (2FA / MFA)

Protect your StartupDeckAI account, analyses, and financial details with industry-grade multi-factor security.

Overview

StartupDeckAI supports two-factor authentication (2FA) for all user accounts. When enabled, logging in via username/password or Google/GitHub/LinkedIn OAuth requires you to verify your identity with a dynamic, single-use 6-digit passcode. This prevents unauthorized access even if your password or OAuth credentials become compromised.

Supported Authentication Methods

📱 Authenticator Apps (TOTP)

Scan a cryptographically secure 2D QR code using standard authenticators like Google Authenticator, Microsoft Authenticator, Authy, or 1Password. Generates time-based, offline tokens refreshed every 30 seconds.

📧 Email One-Time Passcodes (OTP)

Receive a high-entropy, 6-digit verification code directly to your registered email address. Perfect for users who prefer secure verification without needing secondary mobile authenticator apps.

How to Enable 2FA

  1. Log into your account and navigate to Account Settings.
  2. Scroll down to the Security & Two-Factor Authentication section.
  3. Select your preferred method: Authenticator App or Email OTP.
  4. For Authenticator Apps, scan the generated QR code or copy the plaintext secret key. For Email OTP, verify the test code sent to your inbox.
  5. Enter the 6-digit confirmation token to securely activate 2FA.
  6. Copy and store your Emergency Recovery Codes in a safe place. If you ever lose access to your device, these codes are the only way to regain access without administrator intervention.

Login Verification Flow

Once activated, the authentication sequence intercepts access post-credentials check:

1. Login Trigger

User submits email/pass or authenticates via Google/GitHub OAuth.

2. 2FA Intercept

Server checks if user has active 2FA and halts the auth session.

3. Verification

User enters 6-digit TOTP token or Email OTP in secure overlay.

Admin Exemption & Panel Security

For administrative accounts, standard user-level 2FA is deactivated. Instead, administrators must verify their identity using a specialized **Secret Key Verification Challenge Overlay**. This timing-safe, cryptographically hashed challenge must be verified before the system grants access to the high-privilege Admin Panel, ensuring maximum defense for user data and infrastructure control.

API Specifications for Developers

If you are building custom clients or programmatically managing authentication, use these endpoints:

1. Request 2FA Setup

POST /api/security/2fa/setup

Initiates a Speakeasy key generation and outputs secret details:

json
{
  "secret": "JBSWY3DPEHPK3PXP",
  "qrCodeUrl": "data:image/png;base64,iVBORw0KGgoAAA..."
}

2. Confirm/Activate 2FA

POST /api/security/2fa/verify
json
{
  "token": "123456"
}

3. Deactivate 2FA

POST /api/security/2fa/disable
json
{
  "token": "123456"
}
Security

Rate Limiting

API protection with configurable rate limits.

Endpoint TypeWindowMax Requests
General API15 minutes1000
AI Analysis1 hour100
Authentication15 minutes20

Rate-limited responses return 429 Too Many Requests with a Retry-After header.

Security

SSL / TLS

Configure secure connections with SSL certificates.

Nginx Configuration

nginx
server {
    listen 443 ssl http2;
    server_name your-domain.com;

    ssl_certificate /path/to/cert.pem;
    ssl_certificate_key /path/to/key.pem;

    location / {
        proxy_pass http://localhost:5000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}
Advanced

Monitoring

Set up comprehensive monitoring for system health and performance.

Health Check Endpoints

bash
# API Health
curl https://api.startupdeck.in/health

# Database Health
curl https://api.startupdeck.in/api/health/database

# Redis Health
curl https://api.startupdeck.in/api/health/redis

Error Tracking with Sentry

bash
npm install @sentry/node @sentry/profiling-node

Key Metrics to Track

  • System Health: Database, Redis, and email service status
  • User Analytics: Growth tracking and user behavior
  • Revenue Analytics: MRR, ARR, and financial projections
  • Performance: CPU, memory, and response times
Advanced

Scaling

Scale StartupDeckAI for production workloads.

Database Optimization

sql
-- Add indexes for performance
CREATE INDEX CONCURRENTLY idx_analyses_user_id_created_at
  ON analyses(user_id, created_at);

CREATE INDEX CONCURRENTLY idx_competitors_analysis_id
  ON competitors(analysis_id);

CREATE INDEX CONCURRENTLY idx_usage_tracking_user_id_feature
  ON usage_tracking(user_id, feature);

Load Balancing

nginx
upstream startupdeck_backend {
    server 127.0.0.1:5000;
    server 127.0.0.1:5001;
    server 127.0.0.1:5002;
}

server {
    location / {
        proxy_pass http://startupdeck_backend;
    }
}
Advanced

Troubleshooting

Common issues and their solutions.

Redis Connection Failed

bash
# Check Redis status
sudo systemctl status redis-server

# Restart Redis
sudo systemctl restart redis-server

Database Connection Issues

bash
# Test database connection
psql $DATABASE_URL -c "SELECT 1;"

Payment Webhook Failures

bash
# Test webhook endpoint
stripe events resend evt_webhook_id

# Check webhook logs
stripe logs tail