cargo-x402 0.5.1

Scaffold x402 projects from templates.
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
<h1 align="center">
  <br>
    <img
      src="https://github.com/xForth/cargo-x402/blob/main/img/cargo-x402-logo.png"
      alt="cargo-x402"
      width="200"
    />
  <br>
  cargo-x402
  <br>
</h1>

<h4 align="center">
  Scaffold production-ready Rust projects instantly with
  <a href="https://github.com/topics/x402-template" target="_blank">
    community templates</a>.</h4>

<p align="center">
  <a href="https://crates.io/crates/cargo-x402" target="_blank">
    <img src="https://img.shields.io/crates/v/cargo-x402.svg" alt="Crates.io"/>
  </a>
  <a href="https://crates.io/crates/cargo-x402" target="_blank">
    <img src="https://img.shields.io/crates/d/cargo-x402.svg" alt="Downloads"/>
  </a>
  <a href="https://github.com/cryptopatrick/cargo-x402/actions" target="_blank">
    <img src="https://img.shields.io/github/actions/workflow/status/cryptopatrick/cargo-x402/test.yml" alt="CI Status"/>
  </a>
  <a href="https://docs.rs/cargo-x402" target="_blank">
    <img src="https://docs.rs/cargo-x402/badge.svg" alt="Documentation"/>
  </a>
  <a href="LICENSE" target="_blank">
    <img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License"/>
  </a>
</p>

<b>Author:</b> πŸ‘‹ Hi, I'm <a href="https://x.com/cryptopatrick">CryptoPatrick</a>! I create tools and frameworks for the Rust ecosystem. If you have questions or want to connect, reach out on <a href="https://x.com/cryptopatrick">X/Twitter</a>.

---

<p align="center">
  <a href="#-what-is-cargo-x402">What is cargo-x402</a> β€’
  <a href="#-features">Features</a> β€’
  <a href="#-quick-start">Quick Start</a> β€’
  <a href="#-templates">Templates</a> β€’
  <a href="#-documentation">Documentation</a> β€’
  <a href="#-license">License</a>
</p>

## πŸ›Ž Status

* **v1.0.0** - Production-ready release
* **208+ tests** passing across all platforms
* **5 official templates** included and maintained
* **Multi-platform support** - macOS, Linux, Windows
* Fully **open-source** and community-driven

<!-- TABLE OF CONTENTS -->
<h2 id="table-of-contents"> :pushpin: Table of Contents</h2>

<details open="open">
  <summary>Table of Contents</summary>
  <ol>
    <li><a href="#-what-is-cargo-x402"> What is cargo-x402</a>
      <ul>
        <li><a href="#use-cases"> Use Cases</a></li>
      </ul>
    </li>
    <li><a href="#-features"> Features</a>
      <ul>
        <li><a href="#-core-capabilities"> Core Capabilities</a></li>
        <li><a href="#-template-system">Template System</a></li>
        <li><a href="#-developer-experience">Developer Experience</a></li>
      </ul>
    </li>
    <li><a href="#-architecture"> Architecture</a></li>
    <li><a href="#-quick-start"> Quick Start</a></li>
    <li><a href="#-templates"> Official Templates</a></li>
    <li><a href="#-documentation"> Documentation</a></li>
    <li><a href="#-roadmap"> Roadmap</a></li>
    <li><a href="#-author"> Author</a></li>
    <li><a href="#-support"> Support</a></li>
    <li><a href="#-contributing"> Contributing</a></li>
    <li><a href="#-license">License</a></li>
  </ol>
</details>

## πŸ€” What is cargo-x402

`cargo-x402` is a template scaffolding tool that helps you create production-ready Rust projects in seconds. It automatically discovers templates from GitHub repositories tagged with `x402-template` and provides an interactive CLI for creating projects with custom parameters.

Instead of manually setting up boilerplate code, copying files, and configuring projects, cargo-x402 handles it all instantlyβ€”and it's customizable for your needs.

### Use Cases

- **Rapid Prototyping**: Start API projects in seconds with batteries included
- **Standardized Architecture**: Enforce consistent project structure across teams
- **Best Practices**: Include production-grade patterns (logging, observability, database)
- **Full-Stack Development**: Scaffold complete applications (frontend + backend)
- **CLI Tools**: Create command-line utilities with proper argument parsing
- **Microservices**: Deploy production-ready services with observability built-in

## πŸ“ Architecture

1. πŸ”„ **Overall Workflow**

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚         User Command: cargo-x402 create                  β”‚
β”‚              (Interactive or Direct)                      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚             Discovery Module                             β”‚
β”‚  β€’ Check local cache (< 1 hour)                          β”‚
β”‚  β€’ If stale, query GitHub API for x402-template topic   β”‚
β”‚  β€’ Cache results locally                                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β”‚
         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         β”‚   Interactive Selection      β”‚
         β”‚   (or use --template flag)   β”‚
         β”‚   User chooses template      β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β”‚
         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         β”‚   Parameter Input            β”‚
         β”‚   (Project name, options)    β”‚
         β”‚   Validation & prompts       β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β”‚
         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         β”‚   Download & Extract         β”‚
         β”‚   Template from GitHub       β”‚
         β”‚   Clone to temp directory    β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β”‚
         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         β”‚   Validate x402.toml         β”‚
         β”‚   Schema validation          β”‚
         β”‚   Parameter verification     β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β”‚
         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         β”‚   Liquid Rendering           β”‚
         β”‚   Substitute parameters      β”‚
         β”‚   Process conditionals       β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β”‚
         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         β”‚   Project Creation           β”‚
         β”‚   Copy files to destination  β”‚
         β”‚   Clean up .git directory    β”‚
         β”‚   Initialize git repo        β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β”‚
         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         β”‚   Success! βœ“                 β”‚
         β”‚   Ready to develop           β”‚
         β”‚   Next steps displayed       β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

2. πŸ” **Discovery & Caching Flow**

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚         cargo-x402 list (or discover templates)          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚  Check Local    β”‚
              β”‚  Cache (1hr)    β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β”‚
           β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
           β”‚                       β”‚
    β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”
    β”‚ Cache Valid β”‚         β”‚Cache Stale  β”‚
    β”‚ Return!     β”‚         β”‚or Missing   β”‚
    β”‚ (Fast)      β”‚         β”‚             β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                       β”‚  Query GitHub β”‚
                       β”‚  API (topic)  β”‚
                       β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚  Parse Results β”‚
                    β”‚  Extract Metadata
                    β”‚  (name, description,
                    β”‚   owner, stars)  β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚  Update Cache  β”‚
                    β”‚  + timestamp   β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚  Display List  β”‚
                    β”‚  to User       β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

3. πŸ“ **Template Creation Flow**

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚         Selected Template Details                         β”‚
β”‚  β€’ Name, description, URL                                β”‚
β”‚  β€’ x402.toml manifest                                    β”‚
β”‚  β€’ Parameters (string, boolean, enum)                    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β”‚
         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         β”‚  1. Download Template        β”‚
         β”‚  β€’ Clone from GitHub         β”‚
         β”‚  β€’ Temporary directory       β”‚
         β”‚  β€’ Extract files             β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β”‚
         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         β”‚  2. Parse x402.toml          β”‚
         β”‚  β€’ Read manifest             β”‚
         β”‚  β€’ Extract parameters        β”‚
         β”‚  β€’ Validate schema           β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β”‚
         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         β”‚  3. Prompt for Parameters    β”‚
         β”‚  (or use defaults)           β”‚
         β”‚  β€’ Validate input            β”‚
         β”‚  β€’ Type checking             β”‚
         β”‚  β€’ Regex patterns            β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β”‚
         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         β”‚  4. Render with Liquid       β”‚
         β”‚  β€’ Variable substitution     β”‚
         β”‚  β€’ Conditionals              β”‚
         β”‚  β€’ File processing           β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β”‚
         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         β”‚  5. Create Project Directory β”‚
         β”‚  β€’ Create output folder      β”‚
         β”‚  β€’ Check for collisions      β”‚
         β”‚  β€’ Copy rendered files       β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β”‚
         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         β”‚  6. Finalization             β”‚
         β”‚  β€’ Remove .git (template)    β”‚
         β”‚  β€’ Initialize new .git       β”‚
         β”‚  β€’ First commit              β”‚
         β”‚  β€’ Display success           β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

4. βš™οΈ **Module Architecture**

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        cargo-x402 CLI                          β”‚
β”‚                      (src/main.rs)                             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                         β”‚
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚                β”‚                β”‚
   β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”
   β”‚ Discoveryβ”‚  β”‚   Schema    β”‚  β”‚  Template  β”‚
   β”‚  Module  β”‚  β”‚  Validation β”‚  β”‚   Render   β”‚
   β”‚          β”‚  β”‚             β”‚  β”‚            β”‚
   β”‚ β€’ GitHub β”‚  β”‚ β€’ x402.toml β”‚  β”‚ β€’ Liquid   β”‚
   β”‚ β€’ Cache  β”‚  β”‚ β€’ Validator β”‚  β”‚ β€’ File     β”‚
   β”‚ β€’ Topics β”‚  β”‚ β€’ Parameter β”‚  β”‚   copy     β”‚
   β”‚          β”‚  β”‚   types     β”‚  β”‚            β”‚
   β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
        β”‚                β”‚                β”‚
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                         β”‚
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚                β”‚                β”‚
   β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”
   β”‚ Commands  β”‚  β”‚ Interactive β”‚  β”‚    Error   β”‚
   β”‚           β”‚  β”‚   Prompts   β”‚  β”‚  Handling  β”‚
   β”‚ β€’ list    β”‚  β”‚             β”‚  β”‚            β”‚
   β”‚ β€’ create  β”‚  β”‚ β€’ Dialoguer β”‚  β”‚ β€’ Error    β”‚
   β”‚           β”‚  β”‚ β€’ Colored   β”‚  β”‚   types    β”‚
   β”‚           β”‚  β”‚   output    β”‚  β”‚ β€’ Helpful  β”‚
   β”‚           β”‚  β”‚ β€’ Validationβ”‚  β”‚   messages β”‚
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

## πŸ“· Features

###  Core Capabilities

- **Template Discovery**: Automatic discovery from GitHub via `x402-template` topic
- **Interactive CLI**: User-friendly terminal interface with colored output
- **Smart Caching**: 1-hour cache with manual refresh option
- **Parameter Handling**: Support for string, boolean, and enum parameters
- **Schema Validation**: Comprehensive validation of template configuration
- **Liquid Templating**: Safe variable substitution with conditionals and loops

###  **Template System**

- **x402.toml Schema**: Declarative template configuration
- **File Rules**: Include/exclude patterns for flexible file management
- **Version Constraints**: Specify minimum Rust and cargo-x402 versions
- **Parameter Validation**: Regex patterns and enum options for user input
- **Metadata Support**: Template name, description, authors, and tags
- **GitHub Integration**: Seamless discovery and download from GitHub

###  **Developer Experience**

- **Zero Configuration**: Works out of the box
- **Progress Indicators**: Visual feedback for all operations
- **Helpful Error Messages**: Clear guidance when something goes wrong
- **Smart Defaults**: Sensible defaults reduce the number of prompts
- **Git Integration**: Automatic git repository initialization
- **Template Examples**: 5 official templates to get started

## πŸš™ Quick Start

### Installation

Install from crates.io:

```bash
cargo install cargo-x402
```

Or build from source:

```bash
git clone https://github.com/cryptopatrick/cargo-x402.git
cd cargo-x402
cargo install --path .
```

### Your First Project (30 seconds)

**Option 1: Interactive Mode**

```bash
# Start interactive menu
cargo-x402

# Follow prompts to:
# 1. Browse available templates
# 2. Select template
# 3. Enter project name and options
# 4. Confirm and create
```

**Option 2: Direct Command**

```bash
# Create project directly
cargo-x402 create --template xForth/x402-template-basic-api --name my-api

# Skips template selection and uses defaults
```

**Option 3: List Templates First**

```bash
# See all available templates
cargo-x402 list

# Show templates matching tags
cargo-x402 list --tags rust,api
```

### What You Get

After running `cargo-x402 create`, you'll have:

```
my-awesome-api/
β”œβ”€β”€ src/
β”‚   └── main.rs              # Ready-to-run code
β”œβ”€β”€ Cargo.toml               # Configured dependencies
β”œβ”€β”€ README.md                # Project documentation
β”œβ”€β”€ .gitignore               # Git configuration
β”œβ”€β”€ .env.example             # Environment template
β”œβ”€β”€ Dockerfile               # Container support
└── .git/                    # Initialized git repo
```

Everything is ready to build and run:

```bash
cd my-awesome-api
cargo build
cargo run
```

## πŸ“¦ Templates

### Official Templates (v0.2.0)

#### 1. **Basic Axum API**
Production-ready REST API with Axum framework

**Features:**
- Health check endpoints
- Request/response handling
- Structured logging
- Error handling

**Use for:** Quick API prototypes, microservices, REST backends

#### 2. **Axum + PostgreSQL**
Full-featured API with database support

**Features:**
- SQLx with Postgres
- Database migrations
- Connection pooling
- CRUD operations

**Use for:** Data-driven applications, persistent storage requirements

#### 3. **Full-Stack (Axum + React)**
Complete web application with backend and frontend

**Features:**
- Axum REST API backend
- React 18 frontend with TypeScript
- Vite build system
- CORS configuration
- Docker Compose setup

**Use for:** Web applications, SPA + API combos, full-stack projects

#### 4. **Microservice with Observability**
Production-grade microservice with tracing and metrics

**Features:**
- Jaeger distributed tracing
- Prometheus metrics
- Structured logging
- JSON output
- Health checks

**Use for:** Cloud deployments, observability needs, production services

#### 5. **CLI Tool**
Professional command-line tool template

**Features:**
- Clap argument parsing
- Colored output
- Progress indicators
- File operations
- Error handling

**Use for:** CLI utilities, scripts, command-line tools

### Create Your Own Template

See [TEMPLATE_AUTHOR_GUIDE.md](./TEMPLATE_AUTHOR_GUIDE.md) for:
- Template structure and format
- Parameter configuration
- Publishing on GitHub
- Best practices

## πŸ“š Documentation

### For Users

- **[QUICKSTART.md]./_dev/QUICKSTART.md** - Get started in 10 minutes
  - Installation methods
  - Your first project
  - Common customizations
  - FAQs and troubleshooting

### For Template Authors

- **[TEMPLATE_AUTHOR_GUIDE.md]./_dev/TEMPLATE_AUTHOR_GUIDE.md** - Create custom templates
  - Complete template structure guide
  - x402.toml manifest specification
  - Liquid templating syntax and examples
  - Parameter validation and file handling
  - Publishing and GitHub discovery
  - Best practices and troubleshooting

### For Developers

- **[API Documentation]https://docs.rs/cargo-x402** - Full Rustdoc reference
- **GitHub Repository** - [cryptopatrick/cargo-x402]https://github.com/cryptopatrick/cargo-x402
- **Official Templates** - [xForth Templates]https://github.com/xForth

## πŸ—ΊοΈ Roadmap

### v0.5.0 βœ… (Current : Production Ready)
- [x] Stable public API
- [x] 5 official maintained templates
- [x] Comprehensive test coverage (208+ tests)
- [x] Full documentation and guides
- [x] Multi-platform support (macOS, Linux, Windows)

### v0.6.0 (Work on this will start in december)
- [ ] Enhanced template caching and offline mode
- [ ] Template repository metadata indexing
- [ ] Improved parameter validation with custom validators
- [ ] Template dependency resolution

### v0.7.0
- [ ] Local template support (non-GitHub templates)
- [ ] Custom template hooks (pre/post generation)
- [ ] Private repository template support
- [ ] Performance profiling and optimization

### v0.8.0
- [ ] Official template marketplace/registry
- [ ] IDE integrations (VS Code, IntelliJ)
- [ ] Template signing and verification
- [ ] Advanced dependency management

## πŸ–Š Author

<a href="https://x.com/cryptopatrick">CryptoPatrick</a> - Rust ecosystem tools & frameworks

## 🐣 Support

**Star** ⭐ this project if you find it useful!

### Report Issues
- [Open GitHub Issue]https://github.com/cryptopatrick/cargo-x402/issues
- Include: command, error message, OS/Rust version

### Get Help
- Check [QUICKSTART.md]./_dev/QUICKSTART.md for common questions
- Review [TEMPLATE_AUTHOR_GUIDE.md]./_dev/TEMPLATE_AUTHOR_GUIDE.md for template creation
- Search existing [GitHub Issues]https://github.com/xForth/cargo-x402/issues

## 🀝 Contributing

Found a bug? Want a feature? Have a template idea?

Contributions are welcome! Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for:
- Code style and standards
- Testing requirements
- Submitting PRs
- Development setup

### Ways to Contribute

1. **Report Bugs** - Found an issue? Open a GitHub issue
2. **Suggest Features** - Have an idea? Share it in discussions
3. **Create Templates** - Build and publish templates to GitHub
4. **Improve Docs** - Help improve guides and documentation
5. **Submit Code** - Fix bugs or implement features

## πŸ—„ License

This project is licensed under the **MIT License**. See [LICENSE](LICENSE) for details.

---

<p align="center">
  Made with ❀️ by <a href="https://x.com/cryptopatrick">CryptoPatrick</a> & <a href="https://github.com/xForth">xForth</a>
  <br>
  <a href="https://github.com/cryptopatrick/cargo-x402">GitHub</a> β€’
  <a href="https://crates.io/crates/cargo-x402">Crates.io</a> β€’
  <a href="https://docs.rs/cargo-x402">Docs.rs</a>
</p>