prax-orm 0.11.0

A next-generation, type-safe ORM for Rust inspired by Prisma
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
---
import DocsLayout from '../layouts/DocsLayout.astro';
import CodeBlock from '../components/CodeBlock.astro';

// Helper to create env var syntax without Angular interpretation issues
const env = (name: string): string => '$' + '{' + name + '}';

// Minimal config example
const minimalConfig = `# prax.toml - Minimal configuration
[database]
provider = "postgresql"
url = "${env('DATABASE_URL')}"`;

// Full config example
const fullConfig = `# =============================================================================
# Prax Configuration File
# =============================================================================
# This file configures database connections, code generation, migrations,
# and runtime behavior for your Prax ORM project.

# =============================================================================
# Database Configuration
# =============================================================================
[database]
# Database provider: "postgresql", "mysql", "sqlite", "mongodb"
provider = "postgresql"

# Connection URL - supports environment variable interpolation with ${env('VAR_NAME')}
url = "${env('DATABASE_URL')}"

# Connection pool settings
[database.pool]
min_connections = 2        # Minimum idle connections to maintain
max_connections = 10       # Maximum connections in the pool
connect_timeout = "30s"    # Timeout for new connections
idle_timeout = "10m"       # Close idle connections after this duration
max_lifetime = "30m"       # Maximum connection lifetime

# =============================================================================
# Schema Configuration
# =============================================================================
[schema]
# Path to the schema file (relative to project root)
path = "prax/schema.prax"

# =============================================================================
# Generator Configuration
# =============================================================================
[generator.client]
# Output directory for generated code
output = "./src/generated"

# Generate async client (default: true)
async_client = true

# Enable tracing instrumentation for query observability
tracing = true

# Model generation style: "standard" (default) or "graphql"
# "graphql" adds async-graphql derives (SimpleObject, InputObject, etc.)
model_style = "standard"

# Free-form metadata list of preview feature names
# (not validated, no wired behavior in v0.11)
preview_features = ["full_text_search", "multi_schema"]

# =============================================================================
# Migration Configuration
# =============================================================================
[migrations]
# Directory for migration files
directory = "./prax/migrations"

# Auto-apply migrations in development (default: false)
auto_migrate = false

# Migration history table name
table_name = "_prax_migrations"

# =============================================================================
# Seeding Configuration
# =============================================================================
[seed]
# Seed script path (Rust or shell script)
script = "./seed.rs"

# Run seed after migrations (default: false)
auto_seed = false

# Environment-specific seeding
[seed.environments]
development = true
staging = false
production = false

# =============================================================================
# Debug/Logging Configuration
# =============================================================================
[debug]
# Log all SQL queries (default: false)
log_queries = false

# Pretty print SQL in logs (default: true)
pretty_sql = true

# Slow query threshold in milliseconds (default: 1000)
slow_query_threshold = 1000

# =============================================================================
# Environment-Specific Overrides
# =============================================================================
# Override any configuration for specific environments

[environments.development]
[environments.development.database]
url = "${env('DEV_DATABASE_URL')}"

[environments.development.debug]
log_queries = true
slow_query_threshold = 500

[environments.production]
[environments.production.database.pool]
min_connections = 5
max_connections = 50

[environments.production.debug]
log_queries = false`;

// Database section
const databaseConfig = `[database]
# Required: Database provider
# Options: "postgresql", "postgres", "mysql", "sqlite", "sqlite3", "mongodb", "mongo"
provider = "postgresql"

# Required: Database connection URL
# Supports environment variable interpolation: ${env('VAR_NAME')}
url = "${env('DATABASE_URL')}"

# Optional: Connection pool settings
[database.pool]
min_connections = 2        # Default: 2
max_connections = 10       # Default: 10
connect_timeout = "30s"    # Default: "30s"
idle_timeout = "10m"       # Default: "10m"
max_lifetime = "30m"       # Default: "30m"`;

// Connection URL examples
const connectionUrls = `# PostgreSQL
url = "postgresql://user:password@localhost:5432/mydb"
url = "postgres://user:password@host:5432/db?sslmode=require"

# MySQL
url = "mysql://user:password@localhost:3306/mydb"
url = "mysql://user:password@host:3306/db?ssl-mode=REQUIRED"

# SQLite
url = "sqlite:./data/myapp.db"
url = "sqlite::memory:"   # In-memory database

# MongoDB
url = "mongodb://user:password@localhost:27017/mydb"
url = "mongodb+srv://user:password@cluster.mongodb.net/mydb"`;

// Environment variable examples
const envVarConfig = `# Environment variable interpolation
# Use ${env('VAR_NAME')} syntax to reference environment variables

[database]
url = "${env('DATABASE_URL')}"

# With fallback in your .env file
# DATABASE_URL=postgresql://localhost/myapp

# Multiple variables
[database]
url = "postgresql://${env('DB_USER')}:${env('DB_PASSWORD')}@${env('DB_HOST')}:${env('DB_PORT')}/${env('DB_NAME')}"`;

// Pool config explained
const poolConfig = `[database.pool]
# Minimum connections to keep in the pool
# Higher = faster queries (no wait for connection)
# Lower = less resource usage
min_connections = 2

# Maximum connections allowed
# Set based on your database's max_connections setting
# Rule of thumb: (database max_connections - 10) / number_of_app_instances
max_connections = 10

# How long to wait when establishing a new connection
# Increase if your database server is slow or remote
connect_timeout = "30s"

# Close connections that have been idle for this long
# Helps release database resources
idle_timeout = "10m"

# Maximum lifetime of any connection
# Prevents issues with stale connections
# Should be less than database's wait_timeout
max_lifetime = "30m"`;

// Schema configuration
const schemaConfig = `[schema]
# Path to your schema file (relative to project root)
# Default: "schema.prax"
path = "prax/schema.prax"

# Prax looks for schema files in these locations (in order):
# 1. Path specified in prax.toml
# 2. prax/schema.prax (default)
# 3. schema.prax
# 4. prisma/schema.prax`;

// Generator configuration
const generatorConfig = `[generator.client]
# Where to output generated Rust code
# Default: "./src/generated"
output = "./src/generated"

# Generate async client (using tokio)
# Default: true
# Set to false only for sync-only applications
async_client = true

# Enable tracing instrumentation
# Adds #[tracing::instrument] to generated functions
# Default: false
tracing = true

# Model generation style
# "standard" (default): plain Rust structs with Serde derives
# "graphql": adds async-graphql derives (SimpleObject, InputObject, etc.)
#            requires the async-graphql crate as a dependency
model_style = "standard"

# Preview features (free-form metadata)
# A free-form list of names — no validation and no wired behavior in v0.11
preview_features = []`;

// Migration configuration
const migrationConfig = `[migrations]
# Directory for migration files
# Default: "./migrations"
directory = "./prax/migrations"

# Auto-apply pending migrations on startup (development only!)
# Default: false
# WARNING: Never enable in production
auto_migrate = false

# Name of the migration history table
# Default: "_prax_migrations"
table_name = "_prax_migrations"`;

// Seed configuration
const seedConfig = `[seed]
# Path to seed script - supports multiple formats:
# - .rs   - Rust seed script (compiled and executed)
# - .sql  - Raw SQL file (executed directly)
# - .json - JSON data file (declarative seeding)
# - .toml - TOML data file (declarative seeding)
script = "./seed.rs"

# Automatically run seed after migrations
# Default: false
auto_seed = false

# Control seeding per environment
# Prevents accidental seeding in production
[seed.environments]
development = true    # ✓ Seed in development
test = true           # ✓ Seed in test
staging = false       # ✗ Don't seed in staging
production = false    # ✗ Never seed in production`;

// Seed script example
const seedScriptExample = `// seed.rs - Example seed script
use prax::prelude::*;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = PraxClient::new().await?;

    // Create admin user
    client.user().create(
        data! {
            email: "admin@example.com",
            name: "Administrator",
            role: Role::Admin
        }
    ).exec().await?;

    // Create sample data
    for i in 1..=10 {
        client.post().create(
            data! {
                title: format!("Sample Post {}", i),
                content: "Lorem ipsum...",
                published: true
            }
        ).exec().await?;
    }

    println!("✓ Database seeded successfully");
    Ok(())
}`;

// Debug configuration
const debugConfig = `[debug]
# Log all executed SQL queries
# Useful for debugging, but verbose in production
# Default: false
log_queries = false

# Pretty-print SQL in logs (with indentation)
# Default: true
pretty_sql = true

# Warn about queries taking longer than this (milliseconds)
# Default: 1000 (1 second)
slow_query_threshold = 1000`;

// Debug output example
const debugOutput = `# With log_queries = true and pretty_sql = true:

[PRAX] Executing query:
    SELECT
        "users"."id",
        "users"."email",
        "users"."name"
    FROM "users"
    WHERE "users"."email" = $1
    LIMIT 1
[PRAX] Query completed in 3ms

# With slow_query_threshold = 500:
[PRAX] ⚠️ Slow query detected (523ms):
    SELECT * FROM "posts" WHERE "published" = true`;

// Environment overrides
const environmentOverrides = `# Base configuration
[database]
url = "postgresql://localhost/myapp_dev"

[database.pool]
max_connections = 10

[debug]
log_queries = false

# =============================================================================
# Development environment overrides
# =============================================================================
[environments.development]
[environments.development.database]
url = "${env('DEV_DATABASE_URL')}"

[environments.development.debug]
log_queries = true
pretty_sql = true
slow_query_threshold = 100

# =============================================================================
# Test environment overrides
# =============================================================================
[environments.test]
[environments.test.database]
url = "postgresql://localhost/myapp_test"

[environments.test.database.pool]
min_connections = 1
max_connections = 5

# =============================================================================
# Production environment overrides
# =============================================================================
[environments.production]
[environments.production.database]
url = "${env('PRODUCTION_DATABASE_URL')}"

[environments.production.database.pool]
min_connections = 10
max_connections = 100
connect_timeout = "10s"

[environments.production.debug]
log_queries = false
slow_query_threshold = 5000`;

// Usage in code
const loadingConfig = `use prax_schema::config::PraxConfig;

// Load configuration from file
let config = PraxConfig::from_file("prax.toml")?;

// Apply environment-specific overrides
let config = config.with_environment("production");

// Access configuration values
let db_url = config.database_url();
let pool_size = config.database.pool.max_connections;
let output_dir = config.generator.client.output;`;

// Environment variable setup
const envFileExample = `# .env file example
DATABASE_URL=postgresql://user:password@localhost:5432/myapp

# Development
DEV_DATABASE_URL=postgresql://localhost/myapp_dev

# Production (set in your deployment environment)
PRODUCTION_DATABASE_URL=postgresql://produser:secret@prod.db.server:5432/myapp`;

// Common configurations
const webAppConfig = `# prax.toml for a typical web application

[database]
provider = "postgresql"
url = "${env('DATABASE_URL')}"

[database.pool]
min_connections = 5
max_connections = 20
connect_timeout = "30s"
idle_timeout = "10m"
max_lifetime = "30m"

[schema]
path = "prax/schema.prax"

[generator.client]
output = "./src/db"
tracing = true

[migrations]
directory = "./prax/migrations"

[debug]
log_queries = false
slow_query_threshold = 1000

[environments.development]
[environments.development.debug]
log_queries = true`;

const cliAppConfig = `# prax.toml for a CLI application

[database]
provider = "sqlite"
url = "sqlite:./data/app.db"

[database.pool]
min_connections = 1
max_connections = 1

[schema]
path = "prax/schema.prax"

[generator.client]
output = "./src/generated"
async_client = true

[migrations]
directory = "./prax/migrations"
auto_migrate = true   # OK for CLI apps with local database`;

const microserviceConfig = `# prax.toml for a microservice

[database]
provider = "postgresql"
url = "${env('DATABASE_URL')}"

[database.pool]
min_connections = 2
max_connections = 10
connect_timeout = "10s"
idle_timeout = "5m"
max_lifetime = "15m"

[schema]
path = "prax/schema.prax"

[generator.client]
output = "./src/db"
tracing = true

[migrations]
directory = "./prax/migrations"
table_name = "_prax_migrations_orders_svc"

[debug]
slow_query_threshold = 500

[environments.production]
[environments.production.database.pool]
min_connections = 5
max_connections = 25`;

// File location
const fileStructure = `my-project/
├── prax.toml              # ← Configuration file (project root)
├── .env                   # Environment variables
├── prax/
│   ├── schema.prax        # Schema definition
│   └── migrations/        # Migration files
├── src/
│   ├── generated/         # Generated code (from generator.client.output)
│   └── main.rs
└── Cargo.toml`;

// Validation errors
const validationErrors = `# Common configuration errors and fixes

# ❌ Error: Unknown field 'databse'
[databse]   # Typo!
url = "..."
# ✅ Fix: Use correct spelling
[database]
url = "..."

# ❌ Error: Invalid provider 'postgre'
[database]
provider = "postgre"   # Invalid
# ✅ Fix: Use valid provider name
provider = "postgresql"  # or "postgres"

# ❌ Error: Environment variable not found
url = "${env('UNDEFINED_VAR')}"
# ✅ Fix: Set the environment variable or use a default
# In your .env: UNDEFINED_VAR=postgresql://localhost/db

# ❌ Error: Invalid duration format
connect_timeout = 30   # Missing unit
# ✅ Fix: Include time unit
connect_timeout = "30s"  # seconds
idle_timeout = "10m"     # minutes
max_lifetime = "1h"      # hours`;
---

<DocsLayout title="Configuration Reference - Prax ORM">
  <article class="max-w-4xl mx-auto px-6 py-12">
    <header class="mb-12">
      <h1 class="text-4xl font-bold mb-4">Configuration Reference</h1>
      <p class="text-xl text-muted">
        Complete guide to the <code class="px-2 py-1 bg-surface-elevated rounded">prax.toml</code> configuration file.
      </p>
    </header>

    <div class="space-y-12">
      <!-- Overview -->
      <section>
        <h2 class="text-2xl font-semibold mb-4">Overview</h2>
        <p class="text-muted mb-4">
          The <code class="px-2 py-1 bg-surface-elevated rounded">prax.toml</code> file is the central configuration
          for your Prax ORM project. It controls database connections, code generation, migrations, seeding,
          and debugging behavior.
        </p>
        <div class="bg-info-500/10 border border-info-500/30 rounded-lg p-4 mb-6">
          <p class="text-info-400 text-sm">
            <strong>📍 Location:</strong> Place <code>prax.toml</code> in your project's root directory.
          </p>
        </div>
        <div class="bg-warning-500/10 border border-warning-500/30 rounded-lg p-4 mb-6">
          <p class="text-warning-400 text-sm">
            <strong>⚠️ CLI vs library config:</strong> the <code>prax</code> CLI binary reads its own
            smaller config struct and ignores <code>[database.pool]</code>, <code>[debug]</code>, and
            <code>[environments]</code> — those sections affect library-side <code>PraxConfig</code>
            consumers (e.g. your application's runtime), not CLI commands.
          </p>
        </div>
        <CodeBlock code={fileStructure} lang="text" filename="Project Structure" />
      </section>

      <!-- Minimal Config -->
      <section>
        <h2 class="text-2xl font-semibold mb-4">Minimal Configuration</h2>
        <p class="text-muted mb-4">
          At minimum, you only need to specify your database provider and connection URL:
        </p>
        <CodeBlock code={minimalConfig} lang="toml" filename="prax.toml" />
      </section>

      <!-- Full Example -->
      <section>
        <h2 class="text-2xl font-semibold mb-4">Complete Example</h2>
        <p class="text-muted mb-4">
          Here's a fully-documented configuration file showing all available options:
        </p>
        <CodeBlock code={fullConfig} lang="toml" filename="prax.toml" />
      </section>

      <!-- Database Section -->
      <section>
        <h2 class="text-2xl font-semibold mb-6 pb-2 border-b border-border">Database Configuration</h2>

        <h3 class="text-xl font-semibold mb-4">[database]</h3>
        <p class="text-muted mb-4">
          Configure your database connection and connection pool settings.
        </p>
        <CodeBlock code={databaseConfig} lang="toml" filename="prax.toml" />

        <!-- Database options table -->
        <div class="overflow-x-auto mt-6 mb-8">
          <table class="w-full text-sm">
            <thead>
              <tr class="border-b border-border">
                <th class="text-left py-2 px-3 text-muted">Option</th>
                <th class="text-left py-2 px-3 text-muted">Type</th>
                <th class="text-left py-2 px-3 text-muted">Default</th>
                <th class="text-left py-2 px-3 text-muted">Description</th>
              </tr>
            </thead>
            <tbody class="text-muted">
              <tr class="border-b border-border/50">
                <td class="py-2 px-3"><code class="text-primary-400">provider</code></td>
                <td class="py-2 px-3">string</td>
                <td class="py-2 px-3"><code>"postgresql"</code></td>
                <td class="py-2 px-3">Database provider (see supported providers below)</td>
              </tr>
              <tr class="border-b border-border/50">
                <td class="py-2 px-3"><code class="text-primary-400">url</code></td>
                <td class="py-2 px-3">string</td>
                <td class="py-2 px-3">—</td>
                <td class="py-2 px-3">Connection URL (supports <code>&#36;{'{'}VAR{'}'}</code> interpolation)</td>
              </tr>
            </tbody>
          </table>
        </div>

        <!-- Supported Providers -->
        <h3 class="text-xl font-semibold mb-4">Supported Database Providers</h3>
        <div class="overflow-x-auto mb-8">
          <table class="w-full text-sm">
            <thead>
              <tr class="border-b border-border">
                <th class="text-left py-2 px-3 text-muted">Provider</th>
                <th class="text-left py-2 px-3 text-muted">Aliases</th>
                <th class="text-left py-2 px-3 text-muted">URL Format</th>
              </tr>
            </thead>
            <tbody class="text-muted">
              <tr class="border-b border-border/50">
                <td class="py-2 px-3"><code class="text-primary-400">"postgresql"</code></td>
                <td class="py-2 px-3"><code>"postgres"</code></td>
                <td class="py-2 px-3"><code>postgresql://user:pass&#64;host:5432/db</code></td>
              </tr>
              <tr class="border-b border-border/50">
                <td class="py-2 px-3"><code class="text-primary-400">"mysql"</code></td>
                <td class="py-2 px-3">—</td>
                <td class="py-2 px-3"><code>mysql://user:pass&#64;host:3306/db</code></td>
              </tr>
              <tr class="border-b border-border/50">
                <td class="py-2 px-3"><code class="text-primary-400">"sqlite"</code></td>
                <td class="py-2 px-3"><code>"sqlite3"</code></td>
                <td class="py-2 px-3"><code>sqlite:./path/to/db.sqlite</code></td>
              </tr>
              <tr class="border-b border-border/50">
                <td class="py-2 px-3"><code class="text-primary-400">"mongodb"</code></td>
                <td class="py-2 px-3"><code>"mongo"</code></td>
                <td class="py-2 px-3"><code>mongodb://user:pass&#64;host:27017/db</code></td>
              </tr>
            </tbody>
          </table>
        </div>

        <!-- Connection URLs -->
        <h3 class="text-xl font-semibold mb-4">Connection URL Examples</h3>
        <CodeBlock code={connectionUrls} lang="toml" />
      </section>

      <!-- Pool Configuration -->
      <section>
        <h2 class="text-2xl font-semibold mb-6 pb-2 border-b border-border">Connection Pool</h2>

        <h3 class="text-xl font-semibold mb-4">[database.pool]</h3>
        <p class="text-muted mb-4">
          Fine-tune connection pool behavior for optimal performance.
        </p>
        <CodeBlock code={poolConfig} lang="toml" filename="prax.toml" />

        <!-- Pool options table -->
        <div class="overflow-x-auto mt-6">
          <table class="w-full text-sm">
            <thead>
              <tr class="border-b border-border">
                <th class="text-left py-2 px-3 text-muted">Option</th>
                <th class="text-left py-2 px-3 text-muted">Type</th>
                <th class="text-left py-2 px-3 text-muted">Default</th>
                <th class="text-left py-2 px-3 text-muted">Description</th>
              </tr>
            </thead>
            <tbody class="text-muted">
              <tr class="border-b border-border/50">
                <td class="py-2 px-3"><code class="text-primary-400">min_connections</code></td>
                <td class="py-2 px-3">integer</td>
                <td class="py-2 px-3"><code>2</code></td>
                <td class="py-2 px-3">Minimum idle connections to maintain</td>
              </tr>
              <tr class="border-b border-border/50">
                <td class="py-2 px-3"><code class="text-primary-400">max_connections</code></td>
                <td class="py-2 px-3">integer</td>
                <td class="py-2 px-3"><code>10</code></td>
                <td class="py-2 px-3">Maximum connections in the pool</td>
              </tr>
              <tr class="border-b border-border/50">
                <td class="py-2 px-3"><code class="text-primary-400">connect_timeout</code></td>
                <td class="py-2 px-3">duration</td>
                <td class="py-2 px-3"><code>"30s"</code></td>
                <td class="py-2 px-3">Timeout for establishing new connections</td>
              </tr>
              <tr class="border-b border-border/50">
                <td class="py-2 px-3"><code class="text-primary-400">idle_timeout</code></td>
                <td class="py-2 px-3">duration</td>
                <td class="py-2 px-3"><code>"10m"</code></td>
                <td class="py-2 px-3">Close connections idle longer than this</td>
              </tr>
              <tr class="border-b border-border/50">
                <td class="py-2 px-3"><code class="text-primary-400">max_lifetime</code></td>
                <td class="py-2 px-3">duration</td>
                <td class="py-2 px-3"><code>"30m"</code></td>
                <td class="py-2 px-3">Maximum lifetime of any connection</td>
              </tr>
            </tbody>
          </table>
        </div>

        <div class="bg-warning-500/10 border border-warning-500/30 rounded-lg p-4 mt-6">
          <p class="text-warning-400 text-sm">
            <strong>⚠️ Duration Format:</strong> Use strings with units: <code>"30s"</code> (seconds),
            <code>"10m"</code> (minutes), <code>"1h"</code> (hours). Numbers without units will cause errors.
          </p>
        </div>
      </section>

      <!-- Environment Variables -->
      <section>
        <h2 class="text-2xl font-semibold mb-6 pb-2 border-b border-border">Environment Variables</h2>

        <p class="text-muted mb-4">
          Prax supports environment variable interpolation using the <code>&#36;{'{'}VAR_NAME{'}'}</code> syntax.
          This is the recommended way to manage sensitive values like database credentials.
        </p>
        <CodeBlock code={envVarConfig} lang="toml" filename="prax.toml" />

        <h3 class="text-xl font-semibold mt-8 mb-4">.env File Example</h3>
        <CodeBlock code={envFileExample} lang="bash" filename=".env" />

        <div class="bg-error-500/10 border border-error-500/30 rounded-lg p-4 mt-6">
          <p class="text-error-400 text-sm">
            <strong>🔒 Security:</strong> Never commit your <code>.env</code> file to version control.
            Add it to <code>.gitignore</code>.
          </p>
        </div>
      </section>

      <!-- Schema Configuration -->
      <section>
        <h2 class="text-2xl font-semibold mb-6 pb-2 border-b border-border">Schema Configuration</h2>

        <h3 class="text-xl font-semibold mb-4">[schema]</h3>
        <p class="text-muted mb-4">
          Configure where your schema file is located.
        </p>
        <CodeBlock code={schemaConfig} lang="toml" filename="prax.toml" />

        <div class="overflow-x-auto mt-6">
          <table class="w-full text-sm">
            <thead>
              <tr class="border-b border-border">
                <th class="text-left py-2 px-3 text-muted">Option</th>
                <th class="text-left py-2 px-3 text-muted">Type</th>
                <th class="text-left py-2 px-3 text-muted">Default</th>
                <th class="text-left py-2 px-3 text-muted">Description</th>
              </tr>
            </thead>
            <tbody class="text-muted">
              <tr class="border-b border-border/50">
                <td class="py-2 px-3"><code class="text-primary-400">path</code></td>
                <td class="py-2 px-3">string</td>
                <td class="py-2 px-3"><code>"schema.prax"</code></td>
                <td class="py-2 px-3">Path to your schema file (relative to project root)</td>
              </tr>
            </tbody>
          </table>
        </div>
      </section>

      <!-- Generator Configuration -->
      <section>
        <h2 class="text-2xl font-semibold mb-6 pb-2 border-b border-border">Generator Configuration</h2>

        <h3 class="text-xl font-semibold mb-4">[generator.client]</h3>
        <p class="text-muted mb-4">
          Control how Prax generates your Rust client code.
        </p>
        <CodeBlock code={generatorConfig} lang="toml" filename="prax.toml" />

        <div class="overflow-x-auto mt-6">
          <table class="w-full text-sm">
            <thead>
              <tr class="border-b border-border">
                <th class="text-left py-2 px-3 text-muted">Option</th>
                <th class="text-left py-2 px-3 text-muted">Type</th>
                <th class="text-left py-2 px-3 text-muted">Default</th>
                <th class="text-left py-2 px-3 text-muted">Description</th>
              </tr>
            </thead>
            <tbody class="text-muted">
              <tr class="border-b border-border/50">
                <td class="py-2 px-3"><code class="text-primary-400">output</code></td>
                <td class="py-2 px-3">string</td>
                <td class="py-2 px-3"><code>"./src/generated"</code></td>
                <td class="py-2 px-3">Output directory for generated code</td>
              </tr>
              <tr class="border-b border-border/50">
                <td class="py-2 px-3"><code class="text-primary-400">async_client</code></td>
                <td class="py-2 px-3">boolean</td>
                <td class="py-2 px-3"><code>true</code></td>
                <td class="py-2 px-3">Generate async client (using tokio)</td>
              </tr>
              <tr class="border-b border-border/50">
                <td class="py-2 px-3"><code class="text-primary-400">tracing</code></td>
                <td class="py-2 px-3">boolean</td>
                <td class="py-2 px-3"><code>false</code></td>
                <td class="py-2 px-3">Add tracing instrumentation to generated code</td>
              </tr>
              <tr class="border-b border-border/50">
                <td class="py-2 px-3"><code class="text-primary-400">model_style</code></td>
                <td class="py-2 px-3">string</td>
                <td class="py-2 px-3"><code>"standard"</code></td>
                <td class="py-2 px-3">Model codegen style: <code>"standard"</code> or <code>"graphql"</code> (adds async-graphql derives)</td>
              </tr>
              <tr class="border-b border-border/50">
                <td class="py-2 px-3"><code class="text-primary-400">preview_features</code></td>
                <td class="py-2 px-3">array</td>
                <td class="py-2 px-3"><code>[]</code></td>
                <td class="py-2 px-3">Free-form metadata list (no validation, no wired behavior in v0.11)</td>
              </tr>
            </tbody>
          </table>
        </div>

        <h3 class="text-xl font-semibold mt-8 mb-4">Model Style</h3>
        <p class="text-muted mb-4">
          <code class="px-2 py-1 bg-surface-elevated rounded">model_style</code> controls the derives
          added to generated models. It is the actual switch for GraphQL codegen:
        </p>
        <div class="overflow-x-auto">
          <table class="w-full text-sm">
            <thead>
              <tr class="border-b border-border">
                <th class="text-left py-2 px-3 text-muted">Value</th>
                <th class="text-left py-2 px-3 text-muted">Description</th>
              </tr>
            </thead>
            <tbody class="text-muted">
              <tr class="border-b border-border/50">
                <td class="py-2 px-3"><code class="text-primary-400">"standard"</code></td>
                <td class="py-2 px-3">Plain Rust structs with Serde derives (default)</td>
              </tr>
              <tr class="border-b border-border/50">
                <td class="py-2 px-3"><code class="text-primary-400">"graphql"</code></td>
                <td class="py-2 px-3">Adds async-graphql derives (<code>SimpleObject</code>, <code>InputObject</code>, etc.); requires the <code>async-graphql</code> crate. Alias: <code>"async-graphql"</code></td>
              </tr>
            </tbody>
          </table>
        </div>

        <h3 class="text-xl font-semibold mt-8 mb-4">About Preview Features</h3>
        <p class="text-muted mb-4">
          <code class="px-2 py-1 bg-surface-elevated rounded">preview_features</code> is a free-form
          list of strings: it is <strong>not validated</strong> against any known feature set and has
          <strong>no wired behavior</strong> in v0.11. It exists as forward-compatible metadata —
          setting names like <code>"full_text_search"</code> or <code>"multi_schema"</code> will not
          change any generated code or runtime behavior.
        </p>
      </section>

      <!-- Migration Configuration -->
      <section>
        <h2 class="text-2xl font-semibold mb-6 pb-2 border-b border-border">Migration Configuration</h2>

        <h3 class="text-xl font-semibold mb-4">[migrations]</h3>
        <p class="text-muted mb-4">
          Configure database migration behavior.
        </p>
        <CodeBlock code={migrationConfig} lang="toml" filename="prax.toml" />

        <div class="overflow-x-auto mt-6">
          <table class="w-full text-sm">
            <thead>
              <tr class="border-b border-border">
                <th class="text-left py-2 px-3 text-muted">Option</th>
                <th class="text-left py-2 px-3 text-muted">Type</th>
                <th class="text-left py-2 px-3 text-muted">Default</th>
                <th class="text-left py-2 px-3 text-muted">Description</th>
              </tr>
            </thead>
            <tbody class="text-muted">
              <tr class="border-b border-border/50">
                <td class="py-2 px-3"><code class="text-primary-400">directory</code></td>
                <td class="py-2 px-3">string</td>
                <td class="py-2 px-3"><code>"./migrations"</code></td>
                <td class="py-2 px-3">Directory for migration files</td>
              </tr>
              <tr class="border-b border-border/50">
                <td class="py-2 px-3"><code class="text-primary-400">auto_migrate</code></td>
                <td class="py-2 px-3">boolean</td>
                <td class="py-2 px-3"><code>false</code></td>
                <td class="py-2 px-3">Auto-apply migrations on startup</td>
              </tr>
              <tr class="border-b border-border/50">
                <td class="py-2 px-3"><code class="text-primary-400">table_name</code></td>
                <td class="py-2 px-3">string</td>
                <td class="py-2 px-3"><code>"_prax_migrations"</code></td>
                <td class="py-2 px-3">Name of migration history table</td>
              </tr>
            </tbody>
          </table>
        </div>

        <div class="bg-error-500/10 border border-error-500/30 rounded-lg p-4 mt-6">
          <p class="text-error-400 text-sm">
            <strong>🚫 Warning:</strong> Never enable <code>auto_migrate = true</code> in production.
            Always run migrations manually after review.
          </p>
        </div>
      </section>

      <!-- Seed Configuration -->
      <section>
        <h2 class="text-2xl font-semibold mb-6 pb-2 border-b border-border">Seeding Configuration</h2>

        <h3 class="text-xl font-semibold mb-4">[seed]</h3>
        <p class="text-muted mb-4">
          Configure database seeding for development and testing.
        </p>
        <CodeBlock code={seedConfig} lang="toml" filename="prax.toml" />

        <div class="overflow-x-auto mt-6">
          <table class="w-full text-sm">
            <thead>
              <tr class="border-b border-border">
                <th class="text-left py-2 px-3 text-muted">Option</th>
                <th class="text-left py-2 px-3 text-muted">Type</th>
                <th class="text-left py-2 px-3 text-muted">Default</th>
                <th class="text-left py-2 px-3 text-muted">Description</th>
              </tr>
            </thead>
            <tbody class="text-muted">
              <tr class="border-b border-border/50">
                <td class="py-2 px-3"><code class="text-primary-400">script</code></td>
                <td class="py-2 px-3">string</td>
                <td class="py-2 px-3">—</td>
                <td class="py-2 px-3">Path to seed script</td>
              </tr>
              <tr class="border-b border-border/50">
                <td class="py-2 px-3"><code class="text-primary-400">auto_seed</code></td>
                <td class="py-2 px-3">boolean</td>
                <td class="py-2 px-3"><code>false</code></td>
                <td class="py-2 px-3">Automatically seed after migrations</td>
              </tr>
              <tr class="border-b border-border/50">
                <td class="py-2 px-3"><code class="text-primary-400">environments</code></td>
                <td class="py-2 px-3">table</td>
                <td class="py-2 px-3"><code>{'{'}{'}'}</code></td>
                <td class="py-2 px-3">Enable/disable seeding per environment</td>
              </tr>
            </tbody>
          </table>
        </div>

        <h3 class="text-xl font-semibold mt-8 mb-4">Seed Script Example</h3>
        <CodeBlock code={seedScriptExample} lang="rust" filename="seed.rs" />
      </section>

      <!-- Debug Configuration -->
      <section>
        <h2 class="text-2xl font-semibold mb-6 pb-2 border-b border-border">Debug Configuration</h2>

        <h3 class="text-xl font-semibold mb-4">[debug]</h3>
        <p class="text-muted mb-4">
          Configure query logging and debugging features.
        </p>
        <CodeBlock code={debugConfig} lang="toml" filename="prax.toml" />

        <div class="overflow-x-auto mt-6 mb-8">
          <table class="w-full text-sm">
            <thead>
              <tr class="border-b border-border">
                <th class="text-left py-2 px-3 text-muted">Option</th>
                <th class="text-left py-2 px-3 text-muted">Type</th>
                <th class="text-left py-2 px-3 text-muted">Default</th>
                <th class="text-left py-2 px-3 text-muted">Description</th>
              </tr>
            </thead>
            <tbody class="text-muted">
              <tr class="border-b border-border/50">
                <td class="py-2 px-3"><code class="text-primary-400">log_queries</code></td>
                <td class="py-2 px-3">boolean</td>
                <td class="py-2 px-3"><code>false</code></td>
                <td class="py-2 px-3">Log all executed SQL queries</td>
              </tr>
              <tr class="border-b border-border/50">
                <td class="py-2 px-3"><code class="text-primary-400">pretty_sql</code></td>
                <td class="py-2 px-3">boolean</td>
                <td class="py-2 px-3"><code>true</code></td>
                <td class="py-2 px-3">Pretty-print SQL in logs</td>
              </tr>
              <tr class="border-b border-border/50">
                <td class="py-2 px-3"><code class="text-primary-400">slow_query_threshold</code></td>
                <td class="py-2 px-3">integer</td>
                <td class="py-2 px-3"><code>1000</code></td>
                <td class="py-2 px-3">Warn about queries slower than this (ms)</td>
              </tr>
            </tbody>
          </table>
        </div>

        <h3 class="text-xl font-semibold mb-4">Debug Output Example</h3>
        <CodeBlock code={debugOutput} lang="text" />
      </section>

      <!-- Environment Overrides -->
      <section>
        <h2 class="text-2xl font-semibold mb-6 pb-2 border-b border-border">Environment-Specific Overrides</h2>

        <h3 class="text-xl font-semibold mb-4">[environments.&lt;name&gt;]</h3>
        <p class="text-muted mb-4">
          Override any configuration value for specific environments (development, test, staging, production).
          Use <code>config.with_environment("name")</code> to apply overrides.
        </p>
        <CodeBlock code={environmentOverrides} lang="toml" filename="prax.toml" />

        <h3 class="text-xl font-semibold mt-8 mb-4">Loading Environment Config</h3>
        <CodeBlock code={loadingConfig} lang="rust" />
      </section>

      <!-- Common Configurations -->
      <section>
        <h2 class="text-2xl font-semibold mb-6 pb-2 border-b border-border">Common Configuration Patterns</h2>

        <h3 class="text-xl font-semibold mb-4">Web Application</h3>
        <p class="text-muted mb-4">
          Typical configuration for a web server with connection pooling and tracing:
        </p>
        <CodeBlock code={webAppConfig} lang="toml" filename="prax.toml" />

        <h3 class="text-xl font-semibold mt-8 mb-4">CLI Application</h3>
        <p class="text-muted mb-4">
          Configuration for a command-line tool with SQLite:
        </p>
        <CodeBlock code={cliAppConfig} lang="toml" filename="prax.toml" />

        <h3 class="text-xl font-semibold mt-8 mb-4">Microservice</h3>
        <p class="text-muted mb-4">
          Configuration for a microservice with custom migration table:
        </p>
        <CodeBlock code={microserviceConfig} lang="toml" filename="prax.toml" />
      </section>

      <!-- Validation Errors -->
      <section>
        <h2 class="text-2xl font-semibold mb-6 pb-2 border-b border-border">Troubleshooting</h2>

        <p class="text-muted mb-4">
          Common configuration errors and how to fix them:
        </p>
        <CodeBlock code={validationErrors} lang="toml" />
      </section>

      <!-- Navigation -->
      <section class="mt-12 pt-8 border-t border-border">
        <div class="flex justify-between items-center">
          <a href="/quickstart" class="text-primary-400 hover:text-primary-300 flex items-center gap-2">
            ← Quick Start
          </a>
          <a href="/schema/overview" class="text-primary-400 hover:text-primary-300 flex items-center gap-2">
            Schema Overview →
          </a>
        </div>
      </section>
    </div>
  </article>
</DocsLayout>