Technology Stack
| Layer | Technology | Version/Details |
|---|---|---|
| Frontend | Next.js | 16.1.1 |
| Backend Framework | Fastify | 4.26.1 |
| API Layer | tRPC | 10.45.1 |
| Database | PostgreSQL | 15 Alpine |
| ORM | Prisma | 5.10.2 |
| Styling | Tailwind CSS | 4.x |
| Animations | Framer Motion | 12.23.26 |
| State Management | TanStack Query | 4.36.1 |
| Validation | Zod | 3.22.4 |
| Monorepo | Turborepo | Latest |
| Package Manager | pnpm | 8+ |
| Deployment | Docker | Latest |
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
- 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.
- Visual Excellence: The "Dark/Gold" Glassmorphism aesthetic provides a premium feel appropriate for spiritual/astrology applications. Animated transitions and interactive elements enhance user engagement.
- Tiered Access Model: The freemium model allows users to explore basic features while premium tiers unlock advanced reports, AI interpretations, and personalized remedies.
- Multi-Tenant Architecture: The database schema supports multiple tenants (different astrology businesses) on a single platform, enabling white-label deployments.
- Expert Content Ecosystem: Expert numerologists can contribute interpretations, remedies, and generate premium reports for clients.
Architecture Deep Dive
Monorepo Structure
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 configCore Numerology Calculations
The utility package implements fundamental Vedic numerology algorithms:
// 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:
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:
// 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:
| Tier | Features |
|---|---|
| Free | Basic calculations, Natal Grid |
| Premium | Full reports, AI interpretations, Remedies |
| Plus | Extended compatibility, Unlimited calculations |
| Professional | Expert tools, White-label |
| Business | Multi-tenant, Custom domain |
| Enterprise | Full 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:
// 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): PremiumRemedyDevelopment and Operations
Local Development
# 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/trpcProduction Architecture
Internet
↓
Next.js Frontend (Port 3000)
↓
tRPC Router
↓
Fastify API Server (Port 4000)
↓
PostgreSQL DatabaseMulti-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
- Type-Safe Monorepo: tRPC provides excellent type safety between frontend and backend
- Shared Validation: Zod schemas in packages ensure consistent validation
- Unit-Tested Logic: Core numerology functions tested with Vitest
- Component Library: Reusable React components accelerate development
Areas for Enhancement
- Real-time Updates: Could add WebSocket for live chart updates
- Mobile App: React Native wrapper for broader accessibility
- Payment Integration: Stripe integration for subscription management
- 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.