Project Overview
Reportr is a white-label SEO reporting SaaS platform built for digital marketing agencies. The platform automates the collection of data from Google Search Console, Google Analytics 4, and PageSpeed Insights APIs, generates AI-powered insights using Claude API, and produces branded PDF reports. Current Development Status: 35% complete - foundation is built, core business logic implementation in progress.Technology Stack
Core Framework
- Next.js 14 - React framework with App Router for server and client rendering
- TypeScript - Strict mode enabled with comprehensive type checking
- React 18 - Latest React features including Server Components
Database & ORM
- PostgreSQL - Primary relational database
- Prisma ORM - Type-safe database client with schema migrations
- Connection Pooling - Managed via Prisma with direct URL support
Authentication & Authorization
- NextAuth.js - Authentication framework with Google OAuth
- JWT Strategy - Token-based session management
- Google OAuth - Primary authentication provider with API token storage
Styling & UI
- Tailwind CSS - Utility-first CSS framework
- Atomic Design System - Component architecture (atoms → organisms → templates)
- CSS Custom Properties - Dynamic theming for white-label branding
- Lucide React - Icon library
AI & Processing
- Anthropic Claude API - AI-powered report insights generation
- React-PDF - PDF generation and rendering
- Vercel Blob - Cloud storage for generated PDF files
- Upstash Redis - Background job queue for report processing
API Integrations
- Google Search Console API - SEO performance metrics
- Google Analytics 4 API - Website analytics data
- PageSpeed Insights API - Performance metrics
- PayPal API - Subscription billing integration
Development Tools
- ESLint - Code linting with TypeScript rules
- Prettier - Code formatting with Tailwind plugin
- Zod - Runtime schema validation
- Git - Version control
Architecture Principles
1. Strict TypeScript
All code uses TypeScript strict mode with:noImplicitAny: truestrictNullChecks: truenoUncheckedIndexedAccess: true- Target: ES2020 with DOM libraries
2. Atomic Design Pattern
Components are organized hierarchically:- Atoms - Basic UI elements (Button, Input, Typography)
- Molecules - Simple combinations (MetricCard, UserMenu)
- Organisms - Complex components (DashboardSidebar, ClientTable)
- Templates - Page layouts (DashboardLayout)
- Pages - Complete application pages
3. API-First Design
Next.js API routes provide RESTful endpoints with:- Zod schema validation
- Authentication middleware
- Error handling with proper HTTP status codes
- Resource-based routing structure
4. White-Label Architecture
Supports multi-tenant branding through:- CSS custom properties for dynamic theming
- User-specific branding settings (colors, logos, company names)
- PDF template customization per user
- Domain-agnostic design system
Project Structure
Core Business Logic
Authentication Flow
- User clicks “Sign in with Google”
- NextAuth.js initiates OAuth flow
- Google returns access/refresh tokens
- Tokens stored in JWT session for API access
- User record created/updated in database
- Session maintained via JWT strategy
Report Generation Pipeline (Planned)
- User triggers report generation
- Job queued in Redis with client/date parameters
- Worker fetches data from Google APIs in parallel:
- Search Console metrics
- Analytics 4 data
- PageSpeed Insights
- Data processed and cross-referenced
- Claude API generates insights from data
- React-PDF creates branded PDF with user’s branding
- PDF uploaded to Vercel Blob storage
- Database updated with report metadata and PDF URL
- User notified of completion
White-Label Branding System
Users customize their agency branding:- Company Name - Defaults to “‘s Agency”
- Primary Color - Hex color (default: #8B5CF6)
- Logo Upload - Stored in Vercel Blob
- PDF Templates - Dynamically branded with user settings
- CSS Variables - Updated per user session
Performance Targets
- Report Generation - < 3 minutes end-to-end
- API Responses - < 2 seconds
- PDF Creation - < 30 seconds
- UI Interactions - < 500ms
- Database Queries - Optimized with indexes and eager loading
Path Aliases
Configured intsconfig.json for cleaner imports:
Environment Configuration
Required environment variables:Security Considerations
Data Protection
- All API tokens encrypted before database storage
- Google refresh tokens stored securely per client
- JWT tokens for session management
- CSRF protection via NextAuth.js
Rate Limiting
- Google API rate limits handled with retry logic
- Exponential backoff for failed requests
- API usage tracked in
ApiUsagemodel
Authentication
- Protected routes require valid session
- API endpoints validate user ownership of resources
- Email verification required for core features
- Plan-based feature access control
Development Workflow
Setup
Development
Database Management
Production Build
Next Steps
See related architecture documentation:- Database Schema - Detailed Prisma models
- Atomic Design System - Component hierarchy
- API Structure - API route organization