@advantacode/brander 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.
@@ -0,0 +1,780 @@
1
+ # AdvantaCode Brander — Technical Overview
2
+
3
+ ## Overview
4
+
5
+ AdvantaCode Brander is a **design token generation engine** designed to produce consistent branding outputs for modern web applications.
6
+
7
+ The tool converts a simple configuration into multiple outputs used across:
8
+
9
+ * frontend frameworks
10
+ * component libraries
11
+ * CSS systems
12
+ * design tools
13
+
14
+ The goal is to provide a **single source of truth for brand tokens** while supporting multiple frameworks and environments.
15
+
16
+ Brander is intentionally **framework-agnostic** and designed to integrate with ecosystems such as Vue, React, Laravel, Quasar, and Tailwind.
17
+
18
+ ---
19
+
20
+ ## Branding Note
21
+
22
+ This document describes the software architecture and maintainer workflow for AdvantaCode Brander.
23
+
24
+ Use of the software is governed by the MIT license. Use of the AdvantaCode name, logos, and branding is governed separately by [TRADEMARKS.md](TRADEMARKS.md).
25
+
26
+ ---
27
+
28
+ # Core Architecture
29
+
30
+ AdvantaCode Brander is built around a **token pipeline**.
31
+
32
+ ```
33
+ brand.config.ts
34
+
35
+ token engine
36
+
37
+ primitive tokens
38
+
39
+ semantic tokens
40
+
41
+ framework outputs
42
+ ```
43
+
44
+ This layered architecture allows tokens to remain reusable across different platforms.
45
+
46
+ ---
47
+
48
+ # Token Layers
49
+
50
+ The system uses three token layers.
51
+
52
+ ## 1. Primitive Tokens
53
+
54
+ Primitive tokens represent raw color values and palette scales.
55
+
56
+ Example:
57
+
58
+ ```
59
+ primary-50
60
+ primary-100
61
+ primary-200
62
+ ...
63
+ primary-950
64
+ ```
65
+
66
+ These are generated from the base color using OKLCH lightness scaling.
67
+
68
+ Example CSS output:
69
+
70
+ ```
71
+ --primary-50
72
+ --primary-100
73
+ --primary-200
74
+ ```
75
+
76
+ Primitive tokens should **never be used directly by components**.
77
+
78
+ ---
79
+
80
+ ## 2. Semantic Tokens
81
+
82
+ Semantic tokens describe **UI meaning rather than color values**.
83
+
84
+ Examples:
85
+
86
+ ```
87
+ background
88
+ surface
89
+ text
90
+ border
91
+ primary
92
+ primary-foreground
93
+ muted
94
+ success
95
+ warning
96
+ danger
97
+ info
98
+ ```
99
+
100
+ Example output:
101
+
102
+ ```
103
+ --background
104
+ --text
105
+ --primary
106
+ ```
107
+
108
+ Components reference semantic tokens rather than primitives.
109
+
110
+ ---
111
+
112
+ ## 3. Framework Tokens
113
+
114
+ Framework tokens convert semantic tokens into framework-specific formats.
115
+
116
+ Examples include:
117
+
118
+ ```
119
+ Tailwind preset
120
+ Quasar SCSS variables
121
+ Figma tokens
122
+ TypeScript tokens
123
+ ```
124
+
125
+ ---
126
+
127
+ # Color Engine
128
+
129
+ Brander uses the **OKLCH color space** for palette generation.
130
+
131
+ OKLCH separates color into:
132
+
133
+ ```
134
+ L = Lightness
135
+ C = Chroma
136
+ H = Hue
137
+ ```
138
+
139
+ This makes it easier to create perceptually consistent color scales.
140
+
141
+ Example scale generation:
142
+
143
+ ```
144
+ primary-50
145
+ primary-100
146
+ primary-200
147
+ ...
148
+ primary-950
149
+ ```
150
+
151
+ The lightness values are adjusted while preserving chroma and hue.
152
+
153
+ Example:
154
+
155
+ ```
156
+ oklch(0.97 0.2 45)
157
+ oklch(0.93 0.2 45)
158
+ oklch(0.87 0.2 45)
159
+ ...
160
+ ```
161
+
162
+ Color conversion is handled using the Culori library.
163
+
164
+ ---
165
+
166
+ # Light and Dark Theme Generation
167
+
168
+ The token engine generates **both light and dark themes automatically**.
169
+
170
+ Themes are implemented using CSS custom properties.
171
+
172
+ Example output:
173
+
174
+ ```
175
+ :root {
176
+ --background: oklch(0.99 0.02 95);
177
+ --text: oklch(0.20 0.02 95);
178
+ }
179
+
180
+ [data-theme="dark"] {
181
+ --background: oklch(0.14 0.02 95);
182
+ --text: oklch(0.95 0.02 95);
183
+ }
184
+ ```
185
+
186
+ Applications can toggle themes using a `data-theme` attribute.
187
+
188
+ Example:
189
+
190
+ ```
191
+ <html data-theme="dark">
192
+ ```
193
+
194
+ ---
195
+
196
+ # CLI Architecture
197
+
198
+ Brander is implemented as a Node CLI tool.
199
+
200
+ The entry point is defined in `package.json`.
201
+
202
+ ```
203
+ "bin": {
204
+ "advantacode-brander": "./dist/index.js"
205
+ }
206
+ ```
207
+
208
+ CLI flow:
209
+
210
+ ```
211
+ CLI entry
212
+
213
+ command parsing
214
+
215
+ generate | setup | init
216
+
217
+ project setup helpers
218
+
219
+ load configuration
220
+
221
+ generate token palette
222
+
223
+ generate semantic tokens
224
+
225
+ write platform outputs
226
+ ```
227
+
228
+ Command roles:
229
+
230
+ * default generate command writes token artifacts only
231
+ * `setup` configures an existing app by creating `brand.config.ts`, adding a package script, patching stylesheet imports, and then generating tokens
232
+ * `init` uses the same setup flow but is intended to be called by a higher-level scaffolding tool such as `advantacode-init`
233
+
234
+ ---
235
+
236
+ # Package Structure
237
+
238
+ ```
239
+ advantacode-brander
240
+
241
+ ├─ src
242
+ │ ├─ index.ts
243
+ │ ├─ generate-tokens.ts
244
+ │ ├─ setup.ts
245
+ │ ├─ engine/
246
+ │ ├─ adapters/
247
+ │ └─ culori.d.ts
248
+
249
+ ├─ dist
250
+
251
+ ├─ brand.config.ts
252
+ ├─ tsconfig.json
253
+ ├─ package.json
254
+ └─ README.md
255
+ ```
256
+
257
+ ---
258
+
259
+ # Source Directory
260
+
261
+ ```
262
+ src/
263
+ ```
264
+
265
+ Contains the CLI entry point, token engine, and output adapters.
266
+
267
+ ```
268
+ src/index.ts
269
+ ```
270
+
271
+ CLI entry script.
272
+
273
+ ```
274
+ src/generate-tokens.ts
275
+ ```
276
+
277
+ Generation orchestration and output writing.
278
+
279
+ ```
280
+ src/setup.ts
281
+ ```
282
+
283
+ Project setup helpers for `setup` and `init`.
284
+
285
+ ```
286
+ src/engine/
287
+ ```
288
+
289
+ Color parsing, palette generation, semantic mapping, and theme assembly.
290
+
291
+ ```
292
+ src/adapters/
293
+ ```
294
+
295
+ Output adapters for CSS, SCSS, Tailwind, TypeScript, JSON, and Figma.
296
+
297
+ ```
298
+ src/culori.d.ts
299
+ ```
300
+
301
+ Type definitions for Culori.
302
+
303
+ ---
304
+
305
+ # Token Source Files
306
+
307
+ ```
308
+ brand.config.ts
309
+ ```
310
+
311
+ Defines the user-provided color inputs.
312
+
313
+ Example:
314
+
315
+ ```ts
316
+ export default {
317
+ css: {
318
+ prefix: ""
319
+ },
320
+ colors: {
321
+ primary: "amber-500",
322
+ secondary: "zinc-700",
323
+ info: "sky-500"
324
+ }
325
+ };
326
+ ```
327
+
328
+ Environment variables can override these values at runtime.
329
+
330
+ ---
331
+
332
+ # Output Structure
333
+
334
+ The generator produces multiple outputs.
335
+
336
+ ```
337
+ dist/brander/
338
+ tokens.css
339
+ tokens.scss
340
+ tokens.ts
341
+ tokens.json
342
+ metadata.json
343
+
344
+ dist/brander/themes/
345
+ light.css
346
+ dark.css
347
+
348
+ dist/brander/adapters/
349
+ tailwind.preset.ts
350
+ bootstrap.variables.scss
351
+ figma.tokens.json
352
+ ```
353
+
354
+ Each output targets a different platform.
355
+
356
+ ---
357
+
358
+ # CSS Token Output
359
+
360
+ Example:
361
+
362
+ ```
363
+ :root {
364
+ --primary: oklch(0.65 0.2 45);
365
+ }
366
+ ```
367
+
368
+ These tokens can be used directly in CSS.
369
+
370
+ ---
371
+
372
+ # Tailwind Integration
373
+
374
+ The generator produces a Tailwind preset.
375
+
376
+ ```
377
+ dist/brander/adapters/tailwind.preset.ts
378
+ ```
379
+
380
+ Example:
381
+
382
+ ```
383
+ export default {
384
+ theme: {
385
+ extend: {
386
+ colors: {
387
+ primary: "var(--primary)"
388
+ }
389
+ }
390
+ }
391
+ }
392
+ ```
393
+
394
+ ---
395
+
396
+ # SCSS / Bootstrap Integration
397
+
398
+ SCSS-based frameworks can use native Sass variables.
399
+
400
+ Generated file:
401
+
402
+ ```
403
+ dist/brander/tokens.scss
404
+ dist/brander/adapters/bootstrap.variables.scss
405
+ ```
406
+
407
+ Example:
408
+
409
+ ```
410
+ @use "../tokens.scss" as tokens;
411
+
412
+ $primary: tokens.$primary;
413
+ $secondary: tokens.$secondary;
414
+ $info: tokens.$info;
415
+ ```
416
+
417
+ ---
418
+
419
+ # Figma Token Export
420
+
421
+ Design tokens can be exported to JSON for use in design tools.
422
+
423
+ ```
424
+ dist/brander/adapters/figma.tokens.json
425
+ ```
426
+
427
+ Example:
428
+
429
+ ```
430
+ {
431
+ "color": {
432
+ "primary": {
433
+ "value": "oklch(0.65 0.2 45)"
434
+ }
435
+ }
436
+ }
437
+ ```
438
+
439
+ ---
440
+
441
+ # Configuration
442
+
443
+ User configuration is defined in:
444
+
445
+ ```
446
+ brand.config.ts
447
+ ```
448
+
449
+ Example:
450
+
451
+ ```
452
+ export default {
453
+ name: "My Company",
454
+
455
+ colors: {
456
+ primary: "amber-500",
457
+ secondary: "zinc-700"
458
+ }
459
+ }
460
+ ```
461
+
462
+ Environment variables can override these values.
463
+
464
+ ---
465
+
466
+ # Development Workflow
467
+
468
+ Contributor setup starts with a local clone of the repository.
469
+
470
+ ```
471
+ git clone https://github.com/advantacode/advantacode-brander.git
472
+ cd advantacode-brander
473
+ npm install
474
+ ```
475
+
476
+ ---
477
+
478
+ # Build Process
479
+
480
+ TypeScript is compiled using:
481
+
482
+ ```
483
+ npm run build
484
+ ```
485
+
486
+ Output is placed in:
487
+
488
+ ```
489
+ dist/
490
+ ```
491
+
492
+ ---
493
+
494
+ # Lint
495
+
496
+ Lint the repository source and tests with:
497
+
498
+ ```
499
+ npm run lint
500
+ ```
501
+
502
+ Generated output folders such as `dist/brander` or `src/brander` are intentionally excluded.
503
+
504
+ ---
505
+
506
+ # Test
507
+
508
+ Run the integration suite against the built CLI:
509
+
510
+ ```
511
+ npm test
512
+ ```
513
+
514
+ The current test coverage includes:
515
+
516
+ * `--help` CLI output
517
+ * token generation into the default `dist/brander` folder
518
+ * `setup` creating config, scripts, and stylesheet imports for `src/brander`
519
+ * invalid config failures returning clean error messages
520
+
521
+ ---
522
+
523
+ # Run Token Generator
524
+
525
+ For local repository development, you can execute the generator directly with:
526
+
527
+ ```
528
+ npm run tokens
529
+ ```
530
+
531
+ This is useful for validating output changes while working inside the package itself.
532
+
533
+ ---
534
+
535
+ # Local CLI Development
536
+
537
+ You can run the compiled CLI locally without publishing:
538
+
539
+ ```
540
+ npm run build
541
+ npm run cli
542
+ ```
543
+
544
+ Preferred consumer-flow testing uses `npm pack`, because it validates the same package contents npm consumers will install.
545
+
546
+ ---
547
+
548
+ # Testing In Another Project
549
+
550
+ The recommended real-world QA flow is to install Brander as a `devDependency` in another app using a packed tarball.
551
+
552
+ Why `devDependency`:
553
+
554
+ * Brander is a build-time code generation tool
555
+ * the consuming app needs the generated token files at runtime, not the generator itself
556
+
557
+ Build and pack Brander:
558
+
559
+ ```
560
+ npm run build
561
+ npm pack --pack-destination /tmp
562
+ ```
563
+
564
+ Then install it into another project such as `advantacode-starter`:
565
+
566
+ ```
567
+ cd ../advantacode-starter
568
+ npm i -D /tmp/advantacode-brander-0.1.0.tgz
569
+ ```
570
+
571
+ Add a script to the app:
572
+
573
+ ```json
574
+ {
575
+ "scripts": {
576
+ "brand:generate": "advantacode-brander --out src/brander --format css,json,typescript --theme both"
577
+ }
578
+ }
579
+ ```
580
+
581
+ Or let Brander do that setup explicitly:
582
+
583
+ ```
584
+ npx --package @advantacode/brander advantacode-brander setup --out src/brander --style src/style.css
585
+ ```
586
+
587
+ That command:
588
+
589
+ * creates `brand.config.ts` if it does not exist
590
+ * adds `brand:generate` to `package.json` if it is missing
591
+ * adds token CSS imports to the chosen stylesheet
592
+ * runs token generation
593
+
594
+ What to validate:
595
+
596
+ * the package installs cleanly as a `devDependency`
597
+ * `advantacode-brander` resolves correctly from npm scripts
598
+ * `brand.config.ts` is detected automatically
599
+ * generated files land in the expected folder
600
+ * rerunning generation replaces old outputs cleanly
601
+ * the app builds after importing the generated CSS
602
+ * light and dark theme variables resolve correctly
603
+ * changing a color in `brand.config.ts` produces a visible change after regeneration
604
+
605
+ Starter app note:
606
+
607
+ * if the starter already defines overlapping theme variables, remove or replace that handwritten theme layer so the generated tokens become the single source of truth
608
+ * `setup` is intended for an existing app repository, while `init` is intended for use by an outer scaffolding tool that already knows the app structure
609
+
610
+ ---
611
+
612
+ # Publishing Notes
613
+
614
+ Brander should be published with compiled `dist/` files included in the npm package, but local generated token output does not need to be committed.
615
+
616
+ Current package behavior:
617
+
618
+ * `dist/` stays in `.gitignore`
619
+ * `npm run build` cleans and rebuilds compiled CLI files
620
+ * `package.json` limits publish contents to compiled JavaScript plus docs and license
621
+ * generated sample token artifacts are not published
622
+
623
+ Verify what npm will publish:
624
+
625
+ ```
626
+ npm run release:check
627
+ ```
628
+
629
+ `release:check` runs linting, the test suite, and then the npm pack dry run. The tarball output should list compiled files such as `dist/index.js`, `dist/generate-tokens.js`, adapter modules, `README.md`, and `LICENSE`, without shipping any local `dist/brander` output.
630
+
631
+ ---
632
+
633
+ # Recommended Consumer Project Structure
634
+
635
+ One common consumer layout looks like this:
636
+
637
+ ```
638
+ my-app
639
+
640
+ ├─ brand.config.ts
641
+ ├─ .env
642
+
643
+ ├─ dist
644
+ │ └─ brander
645
+ │ ├─ tokens.css
646
+ │ ├─ tokens.scss
647
+ │ ├─ tokens.ts
648
+ │ ├─ tokens.json
649
+ │ ├─ metadata.json
650
+ │ ├─ themes
651
+ │ │ ├─ light.css
652
+ │ │ └─ dark.css
653
+ │ └─ adapters
654
+ │ ├─ tailwind.preset.ts
655
+ │ ├─ bootstrap.variables.scss
656
+ │ └─ figma.tokens.json
657
+
658
+ └─ src
659
+ └─ assets
660
+ └─ styles.css
661
+ ```
662
+
663
+ ---
664
+
665
+ # Dependencies
666
+
667
+ Runtime dependencies:
668
+
669
+ ```
670
+ culori
671
+ dotenv
672
+ tsx
673
+ ```
674
+
675
+ These are used for color conversions, environment loading, and executing the TypeScript-based CLI entry.
676
+
677
+ Development dependencies:
678
+
679
+ ```
680
+ typescript
681
+ eslint
682
+ @typescript-eslint/parser
683
+ @typescript-eslint/eslint-plugin
684
+ @types/node
685
+ ```
686
+
687
+ ---
688
+
689
+ # TypeScript Configuration
690
+
691
+ The project compiles TypeScript using:
692
+
693
+ ```json
694
+ {
695
+ "compilerOptions": {
696
+ "target": "ES2022",
697
+ "module": "ESNext",
698
+ "moduleResolution": "Node",
699
+ "outDir": "dist",
700
+ "rootDir": "src",
701
+ "esModuleInterop": true,
702
+ "strict": true
703
+ },
704
+ "include": ["src"]
705
+ }
706
+ ```
707
+
708
+ ---
709
+
710
+ # CLI Entry Point
711
+
712
+ The source CLI entry point lives at:
713
+
714
+ ```
715
+ src/index.ts
716
+ ```
717
+
718
+ It uses this executable header during development:
719
+
720
+ ```ts
721
+ #!/usr/bin/env -S node --import tsx/esm
722
+ ```
723
+
724
+ The published binary entry in `package.json` points to the compiled output:
725
+
726
+ ```json
727
+ {
728
+ "bin": {
729
+ "advantacode-brander": "./dist/index.js"
730
+ }
731
+ }
732
+ ```
733
+
734
+ ---
735
+
736
+ # Future Architecture Goals
737
+
738
+ Planned improvements include:
739
+
740
+ * automatic accessible color contrast generation
741
+ * dark mode optimization
742
+ * design token specification support
743
+ * plugin architecture
744
+ * framework adapters
745
+ * optional semantic packs for charts, dashboards, or app shells
746
+
747
+ ---
748
+
749
+ # Ecosystem Integration
750
+
751
+ Brander is designed to integrate into the larger AdvantaCode ecosystem.
752
+
753
+ ```
754
+ @advantacode/brander
755
+ advantacode-init
756
+ advantacode-starter
757
+ @advantacode/ui
758
+ ```
759
+
760
+ This allows developers to scaffold fully branded applications with a single command.
761
+
762
+ ---
763
+
764
+ # Design Philosophy
765
+
766
+ AdvantaCode Brander follows several key principles:
767
+
768
+ 1. **Single source of truth**
769
+ 2. **Framework independence**
770
+ 3. **Semantic token design**
771
+ 4. **Accessibility-friendly color systems**
772
+ 5. **Extensible architecture**
773
+
774
+ ---
775
+
776
+ # Summary
777
+
778
+ AdvantaCode Brander acts as the **token engine for the AdvantaCode ecosystem**, enabling consistent branding across applications, frameworks, and design tools.
779
+
780
+ By separating primitives, semantics, and framework outputs, the system provides both flexibility and long-term maintainability.