This file provides context for AI assistants and LLMs working with this codebase. Format follows the emerging CONTEXT.md convention for vendor-agnostic AI context.
- Name: Astrologer Studio
- Type: Professional astrology workspace web application
- License: AGPLv3 (GNU Affero General Public License v3)
- Primary Language: TypeScript
- Repository: https://github.com/g-battaglia/AstrologerStudio
- Live Instance: https://astrologerstudio.com
An open-source web application for professional astrologers to:
- Generate precise astrological charts (natal, transit, synastry, composite, solar/lunar returns)
- Manage client/subject databases with birth data
- Explore ephemeris and transit timelines
- Get optional AI-powered interpretations
| Layer | Technology |
|---|---|
| Framework | Next.js 16 (App Router) |
| Runtime | Bun / Node.js |
| Language | TypeScript 5.x |
| UI | React 19, Tailwind CSS, Shadcn UI |
| Database | PostgreSQL + Prisma ORM |
| State | TanStack React Query, Zustand |
| Auth | Custom JWT sessions, optional Google OAuth |
| Astrology Engine | Kerykeion via Astrologer API |
| AI | OpenRouter with AI SDK |
| Payments | Dodo Payments (optional) |
├── src/
│ ├── app/ # Next.js App Router pages
│ │ ├── (protected)/ # Authenticated routes (dashboard, charts)
│ │ ├── (public)/ # Public pages (landing, auth)
│ │ ├── admin/ # Admin dashboard (separate auth)
│ │ └── api/ # API routes
│ ├── actions/ # Server Actions (auth, subjects, astrology)
│ ├── components/ # React components (UI, charts, forms)
│ ├── hooks/ # React Query hooks and view-models
│ ├── lib/ # Utilities, API clients, helpers
│ │ ├── astrologer-api.ts # Astrology calculation API client
│ │ ├── session.ts # JWT session management
│ │ └── security/ # Security utilities (CSRF, rate limiting)
│ ├── stores/ # Zustand stores (UI state)
│ └── types/ # TypeScript type definitions
├── prisma/
│ ├── schema.prisma # Database schema
│ └── migrations/ # Database migrations
├── docs/ # User-facing documentation
├── LIBDOCS/ # Internal technical documentation
├── scripts/ # CLI utilities (create users, import)
└── public/ # Static assets
package.json- Dependencies and scripts.env.example- Environment variables templateprisma/schema.prisma- Database modelsnext.config.mjs- Next.js configuration with CSP headers
src/app/layout.tsx- Root layout with providerssrc/app/(protected)/layout.tsx- Authenticated layout with sidebarsrc/app/(protected)/page.tsx- Main dashboard (Now Chart)
src/lib/astrologer-api.ts- Astrologer API client (chart calculations)src/actions/astrology.ts- Server actions for chart generationsrc/actions/subjects.ts- Subject/client CRUD operationssrc/actions/auth.ts- Authentication logic
User- User accounts with subscription infoSubject- Birth chart subjects (clients)ChartPreferences- User chart rendering preferencesSavedChart- Saved chart configurationsAdminUser- Separate admin authentication
# Development
bun install # Install dependencies
bun run dev # Start dev server (localhost:3000)
# Database
bun run db:up # Start PostgreSQL via Docker
bun run db:generate # Generate Prisma client
bun run db:migrate # Run migrations
bun run db:studio # Open Prisma Studio
# User Management
bun run user:create -- <username> <password>
# Code Quality
bun run lint # ESLint
bun run type-check # TypeScript check
bun run format # Prettier- Client → React Query hooks (
src/hooks/) - Hooks → Server Actions (
src/actions/) - Actions → Prisma (DB) or Astrologer API (calculations)
- Custom credentials auth with bcrypt password hashing
- Optional Google OAuth (feature-flagged)
- JWT sessions stored in encrypted cookies
- Separate admin authentication system
- All astrological calculations via external Astrologer API
- API client:
src/lib/astrologer-api.ts - Server actions merge user preferences with API requests
- Charts rendered as interactive SVGs
- React Query for client-side data caching
- Custom localStorage caches for ephemeris and transits
- Server-side AI interpretation caching in PostgreSQL
Key variables (see .env.example for complete list):
# Required
DATABASE_URL=postgresql://...
SESSION_SECRET=<random-32-chars>
ASTROLOGER_API_KEY=<astrologer-api-key>
# Optional Features
NEXT_PUBLIC_ENABLE_AI_INTERPRETATION=true
NEXT_PUBLIC_ENABLE_GOOGLE_OAUTH=false
NEXT_PUBLIC_ENABLE_EMAIL_REGISTRATION=true- Components: PascalCase, co-located with page or in
src/components/ - Hooks:
useprefix, insrc/hooks/ - Server Actions: Exported async functions in
src/actions/ - Types: Centralized in
src/types/, Zod schemas for validation - Styling: Tailwind CSS with Shadcn UI components
- Create route in
src/app/(protected)/your-page/page.tsx - Add navigation link in
src/components/SidebarNav.tsx
- Add API method in
src/lib/astrologer-api.ts - Create server action in
src/actions/astrology.ts - Create view component in
src/app/(protected)/_components/
- Edit
prisma/schema.prisma - Run
bun run db:migrate(creates migration) - Run
bun run db:generate(updates client)
- README.md - Project overview and quick start
- DEVELOPMENT.md - Detailed development guide
- docs/DATABASE.md - Database setup and migrations
- docs/SELF_HOSTING.md - Self-hosting guide
- LIBDOCS/CORE_FUNCTIONALITIES.md - Feature deep-dive
- Astrologer API: Chart calculations (requires RapidAPI key or self-hosted)
- GeoNames: Location lookup for birth data
- OpenRouter: AI interpretations (optional)
- Dodo Payments: Subscription billing (optional)
Last updated: 2026-01-15