AI Automation SaaS

WealthMirror AI

Production AI automation SaaS for real-time financial decision analysis delivered via Telegram bot.
Node.js TypeScript OpenAI API Telegram Bot PostgreSQL 2026

Context & Problem

Business Case

Financial decision-making requires quick, personalized analysis that most individuals cannot access without expensive advisory services. Traditional financial advisors are costly, slow, and not available 24/7. Users need instant, AI-powered insights tailored to their financial profile.

The Challenge: Build a scalable SaaS that delivers real-time financial analysis through a familiar interface (Telegram), with user behavior modeling, usage-based monetization, and structured AI outputs that users can act on immediately.

Goal: Create a fully automated financial advisor flow — from user query to AI-generated structured insight — delivered via Telegram with persistent user profiles and usage tracking.

System Architecture

Data Flow

The system is built as a webhook-based backend that orchestrates the entire pipeline: receiving user input from Telegram, processing it through OpenAI, storing structured data in PostgreSQL, and returning personalized responses.

Telegram
User Input
→
Express Webhook
API Gateway
→
OpenAI API
Analysis Engine
→
PostgreSQL
Prisma/Supabase
→
Response
Structured Output
Node.js
TypeScript
OpenAI API
Telegraf
PostgreSQL
Prisma ORM
Supabase
Render

Key Features

Implementation Details
Financial DNA
  • User behavior modeling
  • Risk profile analysis
  • Personalized insights
  • Persistent user profiles
SaaS Logic
  • Usage-based limits
  • Monetization system
  • Tier management
  • Quota tracking
AI Pipeline
  • Structured output
  • Context awareness
  • Response formatting
  • Error handling
TypeScript / Webhook Handler Pattern
// Express webhook handler for Telegram bot
bot.on('text', async (ctx) => {
  const userId = ctx.from.id;
  const message = ctx.message.text;

  // 1. Get or create user profile (Financial DNA)
  const user = await prisma.user.upsert({
    where: { telegramId: userId },
    update: { lastActive: new Date() },
    create: { telegramId: userId, tier: 'free' }
  });

  // 2. Check usage limits (SaaS logic)
  const usage = await checkUserLimits(user);
  if (!usage.allowed) {
    return ctx.reply('Daily limit reached. Upgrade for more.');
  }

  // 3. Process through OpenAI with user context
  const analysis = await openai.chat.completions.create({
    model: 'gpt-4',
    messages: buildContext(user, message),
    response_format: { type: 'json_object' }
  });

  // 4. Store interaction and increment usage
  await prisma.interaction.create({
    data: { userId: user.id, query: message, response: analysis }
  });

  // 5. Return structured response
  ctx.reply(formatResponse(analysis));
});

Results

Project Outcomes
Technical
  • Fully automated pipeline
  • Scalable cloud deployment
  • Type-safe codebase
  • Reliable webhook handling
User Experience
  • Instant AI responses
  • Personalized analysis
  • Familiar Telegram interface
  • 24/7 availability
Business Value
  • Monetization-ready SaaS
  • Low operational cost
  • Usage analytics built-in
  • Scalable infrastructure