Skip to content

Phony Architecture ​

Phony's architecture is designed around two core principles: Data Generation as Code and Cloud-Native Infrastructure. The system consists of two major components that work together seamlessly.

Architecture Overview ​

┌─────────────────────────────────────────────────────────────────────────┐
│                    PHONY ARCHITECTURE                                    │
├─────────────────────────────────────────────────────────────────────────┤
│                                                                          │
│  ┌─────────────────────────────────────────────────────────────────────┐│
│  │              DATA GENERATION CORE                                   ││
│  │              (OSS - MIT Licensed)                                   ││
│  │                                                                      ││
│  │  ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐      ││
│  │  │  PGDL    │ │Generator│ │ N-gram  │ │ Package │ │ Locale  │      ││
│  │  │ Schema  │ │  Types  │ │ Models  │ │ Format  │ │ System  │      ││
│  │  └─────────┘ └─────────┘ └─────────┘ └─────────┘ └─────────┘      ││
│  │                                                                      ││
│  │  → Declarative schema language for data generation                 ││
│  │  → Portable packages (git-based) run everywhere                     ││
│  │  → Statistical N-gram models for realistic output                  ││
│  │                                                                      ││
│  └─────────────────────────────────────────────────────────────────────┘│
│                                    │                                    │
│                                    ▼                                    │
│  ┌─────────────────────────────────────────────────────────────────────┐│
│  │              CLOUD PLATFORM                                         ││
│  │              (Phony Cloud - Paid)                                   ││
│  │                                                                      ││
│  │  ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐                   ││
│  │  │Database │ │ Mock    │ │Snapshots│ │ Package │                   ││
│  │  │  Sync   │ │  API    │ │         │ │Registry │                   ││
│  │  └─────────┘ └─────────┘ └─────────┘ └─────────┘                   ││
│  │                                                                      ││
│  │  → Enterprise features requiring infrastructure                    ││
│  │  → Secure database anonymization                                   ││
│  │  → Hosted mock APIs from schemas                                   ││
│  │  → Community package ecosystem                                     ││
│  │                                                                      ││
│  └─────────────────────────────────────────────────────────────────────┘│
│                                                                          │
└─────────────────────────────────────────────────────────────────────────┘

Data Generation Core ​

The open-source foundation that powers all Phony functionality. This is where the "Terraform for Test Data" magic happens.

ComponentDescription
Generator TypesSeven unified abstractions: 4 core (Logic, List, Model, Template) + 3 advanced (Statistical, Linked, Event Sequence). In the built engine: five core generators (Logic, List, Model, Statistical, Event Sequence) + composition — Template and Linked are folded into composition.
N-gram ModelsStatistical text generation using Markov chains
PGDL SpecificationDeclarative JSON schema language
Expression LanguageTemplate syntax (PEL) for composition
Package ManagerGit-based distribution — packages are git repos (MVS resolution, content-addressed store); no hosted registry
Locale SystemMulti-layer inheritance for i18n
Execution ModelOSS vs Cloud runtime architecture

Key Innovation: All data generation is treated as code - declarative, version-controlled, and reproducible.

→ Data Generation Architecture


Cloud Platform ​

Enterprise-grade features that require infrastructure, persistence, and coordination. These features justify the paid tiers.

ComponentDescription
Database SyncSecure anonymization and sync of production databases
Mock APIDynamic REST API generation from PGDL schemas
SnapshotsPoint-in-time database captures with instant restore
Package RegistrySuperseded — distribution is git-based (see Package Manager); page kept as historical design

Key Insight: Cloud value is the control plane around your local data plane — orchestration, PII visibility, audit, and compliance reports. Production data stays in your infrastructure.

→ Cloud Platform Architecture


Core Philosophy ​

┌─────────────────────────────────────────────────────────────────────────┐
│                    THE PHONY PHILOSOPHY                                  │
├─────────────────────────────────────────────────────────────────────────┤
│                                                                          │
│  ANALOGY:                                                                │
│  ════════                                                                │
│  Terraform  → Infrastructure as Code                                     │
│  Prisma     → Database Schema as Code                                    │
│  PGDL        → Data Generation as Code                                    │
│                                                                          │
│  ─────────────────────────────────────────────────────────────────────  │
│                                                                          │
│  CORE PRINCIPLES:                                                        │
│  ════════════════                                                        │
│                                                                          │
│  1. DECLARATIVE                                                          │
│     Define WHAT data you need, not HOW to generate it                   │
│                                                                          │
│  2. PORTABLE                                                             │
│     Same package + seed → the same data on CLI, PHP, Python, Cloud      │
│                                                                          │
│  3. COMPOSABLE                                                           │
│     Mix N-gram models + templates + lists + logic seamlessly            │
│                                                                          │
│  4. DETERMINISTIC                                                        │
│     Same seed produces identical output across all runtimes             │
│                                                                          │
│  5. OPEN CORE                                                            │
│     OSS generation with MIT license, Cloud for enterprise features      │
│                                                                          │
└─────────────────────────────────────────────────────────────────────────┘

Quick Example ​

A complete PGDL schema demonstrating all generator types:

json
{
  "$schema": "https://phony.cloud/schemas/pgdl-1.0.json",
  "version": "1.0",
  "locale": "tr_TR",
  "name": "Turkish E-Commerce",

  "generators": {
    "user_id": {
      "type": "logic",
      "algorithm": "uuid_v7"
    },
    "city": {
      "type": "list",
      "source": "lists/geo/cities.json"
    },
    "first_name": {
      "type": "model",
      "source": "models/person/first_names.ngram",
      "generation": { "mode": "word" }
    },
    "last_name": {
      "type": "model",
      "source": "models/person/last_names.ngram",
      "generation": { "mode": "word" }
    },
    "email": {
      "type": "template",
      "pattern": "{{lowercase(first_name)}}.{{lowercase(last_name)}}@{{pick(['gmail.com', 'hotmail.com', 'outlook.com'])}}",
      "unique": true
    }
  },

  "entities": {
    "User": {
      "fields": {
        "id": { "generator": "user_id", "primary_key": true },
        "first_name": { "generator": "first_name" },
        "last_name": { "generator": "last_name" },
        "email": { "generator": "email" },
        "city": { "generator": "city" }
      }
    }
  }
}

This schema can run on:

  • PHP: Phony::fromSchema('schema.pgdl.json')->generate(1000) (10-50K/sec)
  • Python: Phony.from_schema('schema.pgdl.json').generate(1000) (10-50K/sec)
  • Cloud: phony generate --schema schema.pgdl.json -c 1000 (5M/sec)

Phony Cloud — Documentation & Specification