Initializing
Back to Projects
Year2024
DomainFullstack
AccessOpen Source
Complexity0 / 10
Next.jsFastifytRPCPostgreSQLPrismaTurborepoNumerologySaaSAI
FullstackProduction

Vedic Numerology Calculator (VNC)

A premium full-stack SaaS application for calculating and visualizing Vedic Numerology charts including Natal Grids, Mahadasha periods, yearly forecasts, compatibility analysis, and AI-enhanced reports with remedies.

Parsing system architecture diagram...

Technology Stack

LayerTechnologyVersion/Details
FrontendNext.js16.1.1
Backend FrameworkFastify4.26.1
API LayertRPC10.45.1
DatabasePostgreSQL15 Alpine
ORMPrisma5.10.2
StylingTailwind CSS4.x
AnimationsFramer Motion12.23.26
State ManagementTanStack Query4.36.1
ValidationZod3.22.4
MonorepoTurborepoLatest
Package Managerpnpm8+
DeploymentDockerLatest

Purpose and Philosophy

The Vedic Numerology Calculator (VNC) is a premium SaaS platform designed to make ancient Vedic numerology calculations accessible, accurate, and visually engaging for modern users. The system provides comprehensive birth chart analysis including natal grid generation, planetary period (Mahadasha) calculations, yearly forecasts, and compatibility analysis.

The core philosophy centers on democratizing astrological knowledge while maintaining mathematical precision. Unlike generic numerology apps, VNC implements specific Vedic rules for natal grid generation, ensuring authenticity in the calculation methodology. The platform serves both casual users seeking basic number interpretations and premium subscribers who want deep astrological insights with personalized remedies.

Core Design Principles

  1. Mathematical Precision: All calculations follow established Vedic numerology rules, with Life Number derived from birth date, Destiny Number from full birth date, and Name Number using the Chaldean/Vedic alphabet system.
  1. Visual Excellence: The "Dark/Gold" Glassmorphism aesthetic provides a premium feel appropriate for spiritual/astrology applications. Animated transitions and interactive elements enhance user engagement.
  1. Tiered Access Model: The freemium model allows users to explore basic features while premium tiers unlock advanced reports, AI interpretations, and personalized remedies.
  1. Multi-Tenant Architecture: The database schema supports multiple tenants (different astrology businesses) on a single platform, enabling white-label deployments.
  1. Expert Content Ecosystem: Expert numerologists can contribute interpretations, remedies, and generate premium reports for clients.

Architecture Deep Dive

Monorepo Structure

code
VNC/
├── apps/
│   ├── web/                    # Next.js 16 frontend
│   │   ├── src/
│   │   │   ├── app/           # App Router pages
│   │   │   │   ├── page.tsx   # Home/Calculator
│   │   │   │   ├── calculator/
│   │   │   │   └── results/
│   │   │   ├── components/    # React components
│   │   │   │   ├── features/results/
│   │   │   │   └── ui/
│   │   │   ├── animations/    # Framer Motion animations
│   │   │   └── utils/         # tRPC client
│   │   └── package.json
│   │
│   └── api/                   # Fastify + tRPC backend
│       ├── src/
│       │   ├── index.ts       # Fastify server entry
│       │   ├── router.ts      # tRPC router definition
│       │   ├── context.ts     # Request context
│       │   ├── routes/        # API routes
│       │   │   ├── numerology.router.ts
│       │   │   ├── remedies.router.ts
│       │   │   ├── reports.router.ts
│       │   │   ├── subscriptions.router.ts
│       │   │   ├── portfolio.router.ts
│       │   │   └── compatibility.router.ts
│       │   ├── services/      # Business logic
│       │   │   ├── ai-interpretation.service.ts
│       │   │   ├── remedy.service.ts
│       │   │   ├── report-generation.service.ts
│       │   │   └── portfolio-integration.service.ts
│       │   └── prisma/        # Database client
│       └── prisma/
│           └── schema.prisma  # Database schema

├── packages/
│   ├── shared-types/         # TypeScript interfaces
│   ├── validators/          # Zod validation schemas
│   └── utils/               # Core numerology algorithms
│       ├── src/
│       │   ├── numerology.ts # Core calculation functions
│       │   ├── mahadasha.ts  # Mahadasha period calculations
│       │   ├── compatibility.ts # Compatibility scoring
│       │   └── types.ts
│       └── package.json

├── docker-compose.yml        # Database container
└── turbo.json               # Turborepo config

Core Numerology Calculations

The utility package implements fundamental Vedic numerology algorithms:

typescript
// packages/utils/src/numerology.ts
export function reduceToSingleDigit(num: number): number {
    while (num > 9) {
        let sum = 0;
        while (num > 0) {
            sum += num % 10;
            num = Math.floor(num / 10);
        }
        num = sum;
    }
    return num;
}

export function calculateLifeNumber(day: number): number {
    return reduceToSingleDigit(day);
}

export function calculateDestinyNumber(day: number, month: number, year: number): number {
    const dStr = day.toString().padStart(2, '0');
    const mStr = month.toString().padStart(2, '0');
    const yStr = year.toString().padStart(4, '0');
    let totalSum = 0;
    for (const char of (dStr + mStr + yStr)) {
        totalSum += parseInt(char, 10);
    }
    return reduceToSingleDigit(totalSum);
}

// Chaldean/Vedic alphabet values for Name Number
const LETTER_VALUES: Record<string, number> = {
    'A': 1, 'I': 1, 'J': 1, 'Q': 1, 'Y': 1,
    'B': 2, 'K': 2, 'R': 2,
    'C': 3, 'G': 3, 'L': 3, 'S': 3,
    'D': 4, 'M': 4, 'T': 4,
    'E': 5, 'H': 5, 'N': 5, 'X': 5,
    'U': 6, 'V': 6, 'W': 6,
    'O': 7, 'Z': 7,
    'F': 8, 'P': 8
};

export function calculateNameNumber(name: string): number {
    const cleanName = name.toUpperCase().replace(/[^A-Z]/g, '');
    let totalSum = 0;
    for (const char of cleanName) {
        totalSum += LETTER_VALUES[char] || 0;
    }
    return reduceToSingleDigit(totalSum);
}

Natal Grid Generation

The system generates a Vedic 3x3 natal grid following specific rules:

typescript
export function generateCoreGrid(dob: DateOfBirth, ln: number, dn: number): CoreNatalGrid {
    const { day, month, year } = dob;
    
    // Extract individual digits
    const dayStr = day.toString().padStart(2, '0');
    const D1 = parseInt(dayStr[0]);
    const D2 = parseInt(dayStr[1]);
    
    const monthStr = month.toString().padStart(2, '0');
    const M1 = parseInt(monthStr[0]);
    const M2 = parseInt(monthStr[1]);
    
    const yearStr = year.toString().padStart(4, '0');
    const Y3 = parseInt(yearStr[2]);
    const Y4 = parseInt(yearStr[3]);
    
    // Collect extracted values
    const extractedValues: number[] = [D1, D2, M1, M2, Y3, Y4];
    
    // Destiny Number is always included
    extractedValues.push(dn);
    
    // Life Number Logic (Conditional inclusion)
    const isRedundant = (ln === D1) || (ln === D2);
    if (!isRedundant) {
        extractedValues.push(ln);
    }
    
    // ... Grid placement logic follows specific Vedic rules
}

Database Schema

The Prisma schema models all numerology data:

prisma
// Core Numerology Model
model NumerologyCalculation {
  id                    String   @id @default(uuid())
  tenantId              String
  userId                String
  
  // Input
  fullName              String
  dateOfBirth           DateTime
  
  // Calculated Values
  lifeNumber            Int
  destinyNumber         Int
  nameNumber            Int
  
  // Natal Grid
  natalGridValues       Int[]
  natalGridJson         Json
  
  // Mahadasha Phase
  currentMahadashaPhase Int?
  mahadashaStartDate    DateTime?
  mahadashaEndDate      DateTime?
  
  // Relations
  tenant                Tenant   @relation(fields: [tenantId], references: [id])
  user                  User     @relation(fields: [userId], references: [id])
  mahadashaPhases       MahadashaPhase[]
  reports               NumerologyReport[]
  
  @@map("numerology_calculations")
}

// Mahadasha Period Tracking
model MahadashaPhase {
  id            String   @id @default(uuid())
  calculationId String
  
  phaseNumber   Int
  planetName    String
  durationYears Int
  startDate     DateTime
  endDate       DateTime
  
  isCurrent     Boolean  @default(false)
  
  calculation   NumerologyCalculation @relation(...)
  
  @@map("mahadasha_phases")
}

// Premium Content Models
model PremiumNumberMeaning {
  id               String   @id @default(uuid())
  number           Int       // 1-9
  interpretationType String  // 'LIFE', 'DESTINY', 'NAME'
  
  detailedMeaning  String
  strengths        String[]
  weaknesses       String[]
  rulingPlanet     String?
  gemstoneRecs     String[]
  mantraRecs       String[]
  
  @@unique([number, interpretationType])
}

model PremiumRemedy {
  id               String   @id @default(uuid())
  numberCombination String
  
  remedyType       String    // 'GEMSTONE', 'MANTRA', 'PRACTICE'
  remedyName       String
  description      String
  
  gemstoneName     String?
  mantraText       String?
  practiceDuration String?
  
  @@map("premium_remedies")
}

Key Features and Functionality

1. Core Numerology Calculations

Life Number (Psychic Number): Derived from the birth date, representing the core personality and life's purpose.

Destiny Number (Destiny Number): Calculated from the full birth date, indicating life's path and opportunities.

Name Number (Name Number): Using the Chaldean/Vedic alphabet system, derived from the full name at birth.

2. Natal Grid Visualization

The system generates an interactive 3x3 Vedic grid following authentic rules:

  • Grid positions determined by birth date digits
  • Redundant numbers handled according to Vedic principles
  • Visual representation with animations using Framer Motion
  • Grid reflects the unique numerical signature of the individual

3. Mahadasha Period Analysis

Main Periods (Mahadasha): 45-year planetary cycles starting from birth:

  • Sun, Moon, Mars, Rahu, Jupiter, Saturn, Mercury, Ketu, Venus
  • Each planet governs a specific duration based on Life Number

Sub-Periods (Antardasha): Within each Mahadasha, 9 sub-periods representing planetary interactions

Pratyantar Dasha: Detailed yearly timeline with "Active Phase" tracking for daily precision

4. Yearly Forecast System

  • Antardasha identification for each year
  • Active phase tracking throughout the year
  • Detailed 9-phase yearly timeline
  • Visual representation of planetary influences

5. Compatibility Analysis

  • Life Path compatibility scoring (0-100)
  • Destiny Number alignment
  • Name Number harmony
  • Analysis summary with detailed insights
  • User-to-user comparison capabilities

6. Subscription System

Tiered access model:

TierFeatures
FreeBasic calculations, Natal Grid
PremiumFull reports, AI interpretations, Remedies
PlusExtended compatibility, Unlimited calculations
ProfessionalExpert tools, White-label
BusinessMulti-tenant, Custom domain
EnterpriseFull API access, Dedicated support

7. AI-Enhanced Reports

  • Personalized PDF report generation
  • Deep analysis based on numerology charts
  • Integration with remedy recommendations
  • Shareable reports with token protection

8. Remedy Engine

Personalized recommendations including:

  • Gemstones: Specific stones for number/chakra alignment
  • Mantras: Sacred chants for spiritual balance
  • Practices: Auspicious activities and timing
  • Lucky Dates: Favorable dates based on calculations

9. Expert Content Management

Experts can contribute:

  • Number interpretations (Life, Destiny, Name)
  • Combination meanings (Number pair dynamics)
  • Remedy formulations
  • Professional profiles with credentials

API Endpoints

The tRPC router provides these key procedures:

typescript
// Public endpoints
numerology.calculate(input): CoreNumerologyResult
numerology.getById(id): NumerologyCalculation
compatibility.calculate(user1Id, user2Id): CompatibilityResult

// Protected endpoints
remedies.list(calculationId): PremiumRemedy[]
reports.generate(calculationId, type): NumerologyReport
subscriptions.upgrade(planType): Subscription

// Admin endpoints
meanings.create(content): PremiumNumberMeaning
remedies.create(remedy): PremiumRemedy

Development and Operations

Local Development

bash
# Install dependencies
pnpm install

# Start PostgreSQL
docker compose up -d

# Setup database
pnpm --filter api db:push

# Run application
pnpm dev

# Access:
# Web: http://localhost:3000
# API: http://localhost:4000/trpc

Production Architecture

code
Internet

Next.js Frontend (Port 3000)

tRPC Router

Fastify API Server (Port 4000)

PostgreSQL Database

Multi-Tenancy

The system supports multiple tenants with:

  • Isolated data per tenant
  • Custom branding (logo, colors)
  • Custom domain configuration
  • Role-based access (Developer, Admin, User)
  • Tenant-specific subscriptions

Security Features

  • Password hashing for user accounts
  • JWT-based authentication
  • Role-based route protection
  • Audit logging for all actions
  • Share token protection for reports

Lessons Learned and Best Practices

What Worked Well

  1. Type-Safe Monorepo: tRPC provides excellent type safety between frontend and backend
  2. Shared Validation: Zod schemas in packages ensure consistent validation
  3. Unit-Tested Logic: Core numerology functions tested with Vitest
  4. Component Library: Reusable React components accelerate development

Areas for Enhancement

  1. Real-time Updates: Could add WebSocket for live chart updates
  2. Mobile App: React Native wrapper for broader accessibility
  3. Payment Integration: Stripe integration for subscription management
  4. Expert Marketplace: Connect users with numerology experts

Conclusion

The Vedic Numerology Calculator represents a sophisticated blend of ancient wisdom and modern technology. The platform successfully translates complex Vedic numerology calculations into accessible, visually appealing digital experiences.

With its comprehensive feature set—from basic number calculations to advanced Mahadasha analysis, compatibility matching, and AI-enhanced reports—the platform serves as a complete solution for both individual users seeking self-knowledge and businesses offering numerology services.

The production-ready architecture with multi-tenant support, tiered subscriptions, and expert content management provides a solid foundation for a thriving numerology SaaS ecosystem.

Architecture Feedback

Spotted a potential optimization or antipattern? Let me know.

Submit a Technical Suggestion