This is the Next.js version of Project Artha, migrated from FastAPI/Python to provide a modern, performant web application for browsing ancient Indian texts.
- Node.js 18+
- PostgreSQL database (same as original project)
- Redis (optional, for caching)
# Install dependencies (already done)
npm install
# Start development server
npm run dev
# Open http://localhost:3000 in your browser# Build for production
npm run build
# Start production server
npm start
# Check types
npm run type-check
# Run linter
npm run lint# Generate database migrations
npm run db:generate
# Push schema to database
npm run db:push
# Open Drizzle Studio (database GUI)
npm run db:studiosrc/
├── app/ # Next.js App Router
│ ├── page.tsx # Main SPA entry point (Server Component)
│ ├── layout.tsx # Root layout
│ └── api/ # API routes (minimal - only for client interactions)
│ └── search/route.ts # Search endpoint for client components
├── components/ # React components
│ ├── ArthaSPA.tsx # Main SPA logic (Client Component)
│ ├── SearchBar.tsx # Search with results (Client Component)
│ ├── EntryView.tsx # Entry display (Client Component)
│ └── ShlokaView.tsx # Shloka display (Client Component)
├── lib/ # Utilities and database
│ ├── db/ # Database configuration
│ │ ├── index.ts # Database connection
│ │ └── schema.ts # Drizzle schema
│ ├── data.ts # Server-side data functions
│ ├── language.ts # Transliteration logic
│ └── cache.ts # Caching utilities (future)
├── types/ # TypeScript type definitions
│ └── index.ts # All type definitions
└── styles/ # Global styles
# Database Configuration - Use your actual database credentials
ARTHA_DB_URL="postgresql://username:password@localhost:5432/artha"
# Fallback database URLs (for compatibility)
DATABASE_URL="postgresql://username:password@localhost:5432/artha"
POSTGRES_URL="postgresql://username:password@localhost:5432/artha"
# Redis (for caching) - Optional
REDIS_URL="redis://localhost:6379"
# App Configuration
NEXT_PUBLIC_APP_URL="http://localhost:3000"
ARTHA_CACHE_TTL_TOTAL_SHLOKA=300
ARTHA_CACHE_TTL_TOTAL_ENTRY=300
ARTHA_CACHE_SIZE_SEARCH=500
ARTHA_CACHE_SIZE_ENTRY=1000
ARTHA_CACHE_SIZE_SHLOKA=1000
# Production settings
ARTHA_PROD=falseNote: The primary database connection uses ARTHA_DB_URL. The system will automatically set POSTGRES_URL (used by Vercel Postgres) from ARTHA_DB_URL if needed.
- Use your existing PostgreSQL database
- The schema is defined in
src/lib/db/schema.ts - Run migrations:
npm run db:push
- Next.js project setup with TypeScript
- TailwindCSS configuration with custom colors
- Database schema definition with Drizzle ORM
- Basic project structure
- Environment configuration
- Static assets migration
- Basic home page layout
- Search bar component
- Complete API routes implementation
- Entry and Shloka page components
- Language/transliteration utilities
- Caching implementation
- Navigation components
- Flag/reporting functionality
- Error handling and loading states
- SEO optimization
- Performance optimization
- Mobile responsiveness
- Testing setup
Your existing Python database loading scripts are preserved in the python-scripts/ directory. You can continue using them to populate the PostgreSQL database:
# From the project root, you can still run your Python scripts
cd python-scripts
python main.py # or whatever your data loading script is# Install Vercel CLI
npm i -g vercel
# Deploy to Vercel
vercel
# Set environment variables in Vercel dashboard
# DATABASE_URL, REDIS_URL, etc.The app is configured to work with any platform that supports Node.js:
- Railway
- Render
- AWS Lambda
- Digital Ocean App Platform
- Framework: FastAPI → Next.js App Router (SPA)
- Templates: Jinja2 → React/JSX components
- Interactivity: HTMX → React state management
- Database: SQLAlchemy → Drizzle ORM
- Data Loading: API routes → Server Components + direct database calls
- Architecture: Multi-page → Single-page application
- Server Components for initial data loading (statistics, etc.)
- Client Components only where interactivity is needed
- Direct database calls in server functions instead of unnecessary API routes
- Minimal API surface - only
/api/searchfor client-side search - Server-side data fetching for better performance and SEO
- Type safety throughout the application
This is a migration of the original Project Artha. The goal is to maintain feature parity while leveraging modern web technologies for better performance and developer experience.