Skip to main content

Architecture Overview

This document provides a high-level overview of the SEO Platform architecture.

System Architecture

┌─────────────────────────────────────────────────────────────┐
│ Frontend (React) │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────┐ │
│ │ Pages │ │ Components │ │ API Client │ │
│ │ (TanStack │ │ (Tailwind) │ │ (TanStack Query) │ │
│ │ Router) │ │ │ │ │ │
│ └─────────────┘ └─────────────┘ └─────────────────────┘ │
└─────────────────────────────────────────────────────────────┘


┌─────────────────────────────────────────────────────────────┐
│ Backend (FastAPI) │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────┐ │
│ │ API Routes │ │ Services │ │ Models │ │
│ │ (REST) │ │ (Business │ │ (SQLAlchemy) │ │
│ │ │ │ Logic) │ │ │ │
│ └─────────────┘ └─────────────┘ └─────────────────────┘ │
└─────────────────────────────────────────────────────────────┘

┌───────────────┼───────────────┐
▼ ▼ ▼
┌───────────┐ ┌───────────┐ ┌───────────┐
│ PostgreSQL│ │ OpenAI │ │ Redis │
│ (Primary │ │ API │ │ (Cache) │
│ Storage) │ │ │ │ │
└───────────┘ └───────────┘ └───────────┘

Technology Stack

Frontend

TechnologyPurpose
React 19UI framework
TypeScript 5.9Type safety
ViteBuild tool
TanStack Query 5Server state management
TanStack RouterClient-side routing
Tailwind CSS 4Styling
Lucide ReactIcons

Backend

TechnologyPurpose
Python 3.13Runtime
FastAPIWeb framework
SQLAlchemy 2.0ORM
PydanticValidation
AlembicMigrations
asyncpgPostgreSQL driver

Infrastructure

TechnologyPurpose
PostgreSQL 15+Primary database
RedisCaching (optional)
DockerContainerization
VercelFrontend hosting

Backend Modules

Core Modules

backend/app/
├── api/v1/ # REST endpoints
│ ├── auth.py # Authentication
│ ├── users.py # User management
│ ├── jobs.py # Job operations
│ ├── dedupe.py # Deduplication
│ ├── taxonomies.py # Taxonomy management
│ └── usage.py # Usage/billing
├── models/ # SQLAlchemy models
│ ├── tenancy.py # User/tenant models
│ ├── keywords.py # Keyword models
│ ├── taxonomy.py # Taxonomy models
│ ├── dedupe.py # Dedupe models
│ └── billing.py # Billing models
├── services/ # Business logic
│ ├── workflow/ # Classification, dedupe
│ ├── ingest/ # File parsing
│ └── metering_service.py
└── core/ # Config, security, DB

Module Responsibilities

ModuleResponsibility
Auth + TenancyUser authentication, multi-tenant isolation
JobsKeyword job lifecycle management
IngestCSV parsing, normalization
DedupeDuplicate detection and resolution
ClassificationAI-powered keyword categorization
TaxonomyCategory hierarchy management
BillingUsage tracking, budget enforcement

Frontend Structure

frontend/src/
├── pages/ # Route components
│ ├── LoginPage.tsx
│ ├── JobsPage.tsx
│ ├── JobDetailPage.tsx
│ └── ...
├── components/ # Reusable UI
│ ├── ui/ # Base components
│ └── ...
├── api/ # API client
│ └── client.ts
├── hooks/ # Custom hooks
└── lib/ # Utilities

Data Flow

Keyword Classification Flow

1. Upload CSV → Job created
2. Parse → Keywords extracted & normalized
3. Dedupe → Duplicates identified
4. Review → User resolves duplicates
5. Classify → AI assigns categories
6. Export → Download results

Request Flow

Browser → React → API Client → FastAPI → Service → Database

OpenAI API (for classification)

Multi-Tenancy

The platform uses row-level tenant isolation:

  • All tenant-specific tables include tenant_id
  • API endpoints filter by authenticated user's tenant
  • Database indexes include tenant_id for performance

Security Model

  • Authentication: JWT tokens (30-minute expiry)
  • Authorization: Role-based (user/admin)
  • Data Isolation: Tenant-scoped queries
  • API Security: CORS, rate limiting