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) ││
│ │ ││
│ │ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ││
│ │ │ PDL │ │Generator│ │ N-gram │ │ Package │ │ Locale │ ││
│ │ │ Schema │ │ Types │ │ Models │ │ Format │ │ System │ ││
│ │ └─────────┘ └─────────┘ └─────────┘ └─────────┘ └─────────┘ ││
│ │ ││
│ │ → Declarative schema language for data generation ││
│ │ → Portable .phony packages 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.
| Component | Description |
|---|---|
| Generator Types | Four unified abstractions: Logic, List, Model, Template |
| N-gram Models | Statistical text generation using Markov chains |
| PDL Specification | Declarative JSON schema language |
| Expression Language | Template syntax (PEL) for composition |
| Package Format | Portable, self-contained .phony packages |
| Locale System | Multi-layer inheritance for i18n |
| Execution Model | OSS 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.
| Component | Description |
|---|---|
| Database Sync | Secure anonymization and sync of production databases |
| Mock API | Dynamic REST API generation from PDL schemas |
| Snapshots | Point-in-time database captures with instant restore |
| Package Registry | Community hub for sharing .phony packages |
Key Insight: Cloud features are things OSS cannot provide - secure tunnels, hosted infrastructure, search indexes, and global CDN.
Core Philosophy
┌─────────────────────────────────────────────────────────────────────────┐
│ THE PHONY PHILOSOPHY │
├─────────────────────────────────────────────────────────────────────────┤
│ │
│ ANALOGY: │
│ ════════ │
│ Terraform → Infrastructure as Code │
│ Prisma → Database Schema as Code │
│ PDL → Data Generation as Code │
│ │
│ ───────────────────────────────────────────────────────────────────── │
│ │
│ CORE PRINCIPLES: │
│ ════════════════ │
│ │
│ 1. DECLARATIVE │
│ Define WHAT data you need, not HOW to generate it │
│ │
│ 2. PORTABLE │
│ Same .phony package runs 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 PDL schema demonstrating all generator types:
{
"$schema": "https://phony.cloud/schemas/pdl-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.pdl.json')->generate(1000)(10-50K/sec) - Python:
Phony.from_schema('schema.pdl.json').generate(1000)(10-50K/sec) - Cloud:
phony generate --schema schema.pdl.json -c 1000(5M/sec)