Skip to main content

System Architecture

LatentGEO is a production-ready, full-stack SaaS platform for SEO/GEO audits built with modern technologies and best practices.

Technology Stack

Backend

FastAPI + SQLAlchemy + Celery

Frontend

Next.js 16 (App Router)

Real-time

Server-Sent Events (SSE)

Infrastructure Components

ComponentTechnologyPurpose
DatabaseSupabase PostgresPrimary data store with pooling
Cache & QueueRedisReal-time events, caching, Celery broker
StorageSupabase StorageFile uploads and artifacts
Task QueueCeleryBackground job processing
MonitoringSentryError tracking and performance

System Architecture Diagram

┌─────────────────────────────────────────────────────────────┐
│                        CLIENT LAYER                          │
│  ┌──────────────────────────────────────────────────────┐   │
│  │          Next.js Frontend (Port 3000)                │   │
│  │  • React 19 + App Router                             │   │
│  │  • TanStack Query (data fetching)                    │   │
│  │  • Radix UI + Tailwind CSS                           │   │
│  │  • SSE Client (useAuditSSE hook)                     │   │
│  └──────────────────────────────────────────────────────┘   │
└─────────────────────────────────────────────────────────────┘
                            ↕ HTTP/SSE
┌─────────────────────────────────────────────────────────────┐
│                       API LAYER                              │
│  ┌──────────────────────────────────────────────────────┐   │
│  │        FastAPI Backend (Port 8000)                   │   │
│  │  • API Versioning (/api/v1)                          │   │
│  │  • CORS & Auth Middleware                            │   │
│  │  • Rate Limiting (Redis-backed)                      │   │
│  │  • SSE Endpoints                                     │   │
│  │  • OpenAPI Documentation                             │   │
│  └──────────────────────────────────────────────────────┘   │
└─────────────────────────────────────────────────────────────┘

┌─────────────────────────────────────────────────────────────┐
│                    SERVICE LAYER                             │
│  ┌──────────────┐  ┌──────────────┐  ┌──────────────┐      │
│  │   Audit      │  │    AI/LLM    │  │   Content    │      │
│  │   Service    │  │   Service    │  │   Service    │      │
│  └──────────────┘  └──────────────┘  └──────────────┘      │
│  ┌──────────────┐  ┌──────────────┐  ┌──────────────┐      │
│  │   SEO/GEO    │  │  Analytics   │  │  Backlinks   │      │
│  │   Services   │  │   Service    │  │   Service    │      │
│  └──────────────┘  └──────────────┘  └──────────────┘      │
└─────────────────────────────────────────────────────────────┘

┌─────────────────────────────────────────────────────────────┐
│                     DATA LAYER                               │
│  ┌──────────────┐  ┌──────────────┐  ┌──────────────┐      │
│  │   Supabase   │  │    Redis     │  │   Supabase   │      │
│  │   Postgres   │  │   (Cache +   │  │   Storage    │      │
│  │              │  │    Queue)    │  │   (Files)    │      │
│  └──────────────┘  └──────────────┘  └──────────────┘      │
└─────────────────────────────────────────────────────────────┘

┌─────────────────────────────────────────────────────────────┐
│                   WORKER LAYER                               │
│  ┌──────────────────────────────────────────────────────┐   │
│  │              Celery Workers                          │   │
│  │  • Audit processing                                  │   │
│  │  • SEO analysis                                      │   │
│  │  • AI content generation                            │   │
│  │  • Report generation (PDF)                          │   │
│  └──────────────────────────────────────────────────────┘   │
└─────────────────────────────────────────────────────────────┘

Deployment Modes

LatentGEO supports two canonical Docker deployment modes:

1. Standard Mode (docker-compose.yml)

Production-ready configuration:
docker compose up --build -d
Characteristics:
  • Backend/worker containers without code mounts
  • Frontend in production mode (optimized build)
  • Server-side API URL: http://backend:8000
  • Client-side API URL: http://localhost:8000
  • Suitable for staging and production environments

2. Development Mode (docker-compose.dev.yml)

Hot-reload development configuration:
docker compose -f docker-compose.dev.yml up --build
Characteristics:
  • Hot reload for both backend and frontend
  • Code mounted as volumes for instant updates
  • Debug mode enabled
  • Ideal for local development

Key Environment Variables

Backend Configuration

# SSE Real-time Configuration
SSE_SOURCE=redis                      # redis|db
SSE_FALLBACK_DB_INTERVAL_SECONDS=10   # Fallback polling interval
SSE_HEARTBEAT_SECONDS=30              # Keep-alive heartbeat
SSE_RETRY_MS=5000                     # Client retry interval

# Database Configuration
DB_POOL_PRE_PING=false                # Recommended for Supabase pooler

Frontend Configuration

# Server-side (internal Docker network)
API_URL=http://backend:8000

# Client-side (browser)
NEXT_PUBLIC_API_URL=http://localhost:8000
NEXT_PUBLIC_BACKEND_URL=http://localhost:8000

Service URLs

When running locally:
ServiceURLPurpose
Frontendhttp://localhost:3000User interface
Backend APIhttp://localhost:8000REST API
API Docshttp://localhost:8000/docsSwagger UI
ReDochttp://localhost:8000/redocAlternative API docs
OpenAPI JSONhttp://localhost:8000/openapi.jsonOpenAPI schema

Real-time Communication

SSE vs Webhooks

LatentGEO uses both SSE and webhooks for different purposes:
  • SSE (Server-Sent Events): Real-time progress updates for the UI dashboard
  • Webhooks: External integrations (GitHub, HubSpot, etc.)
These are complementary, not exclusive:
  • SSE solves real-time UX for audit progress
  • Webhooks solve external automation and integrations

Security Features

Authentication

Auth0 integration with JWT bearer tokens

Rate Limiting

Redis-backed distributed rate limiting

CORS

Configurable CORS with credential support

Security Headers

CSP, HSTS, X-Frame-Options, etc.

Next Steps

Backend Details

Explore the FastAPI backend architecture

Frontend Details

Explore the Next.js frontend architecture

Real-time System

Deep dive into SSE implementation

Build docs developers (and LLMs) love