Skip to content

Architecture

This document outlines the architecture and design decisions behind the GT Design System, providing insights for contributors and maintainers.

System Overview

The GT Design System follows atomic design principles and is structured as a monorepo containing design tokens, React components, and supporting packages.

text
gt-design-system/
├── packages/
│   ├── tokens/           # Design tokens (Style Dictionary)
│   ├── react/            # React components
│   ├── eslint/           # ESLint configurations
│   └── typescript/       # TypeScript configurations
├── apps/
│   ├── docs/             # VitePress documentation
│   └── storybook/        # Component playground
└── tools/                # Build and development tools

Design Principles

1. Token-Driven Design

All visual properties stem from design tokens, ensuring consistency and maintainability.

typescript
// Components use tokens, not hard-coded values
const buttonStyles = {
  backgroundColor: GtColorPrimaryGold,
  padding: `${GtSpacing3} ${GtSpacing6}`,
  borderRadius: GtBorderRadiusBase,
};

2. Component Composition

Components are designed to be composable and flexible:

typescript
// Base component with extensible props
interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
  variant?: 'primary' | 'secondary' | 'outline';
  size?: 'sm' | 'md' | 'lg';
}

3. Progressive Enhancement

Components work without JavaScript and enhance with interactivity:

  • Semantic HTML foundation
  • CSS-only base styling
  • JavaScript for enhanced behavior

Package Architecture

Design Tokens (@gtalumni-la/tokens)

Technology Stack:

  • Style Dictionary for token generation
  • JSON source files for token definitions
  • Multiple output formats (CSS, SCSS, JS, TS, JSON)

Structure:

text
packages/tokens/
├── src/
│   ├── tokens.ts         # Generated TypeScript exports
│   └── tokens.d.ts       # Type definitions
├── tokens/               # Source JSON files
│   ├── colors.json
│   ├── spacing.json
│   └── typography.json
├── dist/                 # Generated outputs
│   ├── css/
│   ├── scss/
│   ├── js/
│   ├── ts/
│   └── json/
└── config.js            # Style Dictionary configuration

Token Generation Flow:

  1. JSON source files define raw token values
  2. Style Dictionary processes and transforms tokens
  3. Multiple format outputs generated automatically
  4. TypeScript types generated for type safety

React Components (@gtalumni-la/react)

Technology Stack:

  • React 18+ with TypeScript
  • Rollup for bundling
  • Vitest for testing
  • ESLint and Prettier for code quality

Structure:

text
packages/react/
├── src/
│   ├── Button.tsx        # Component implementation
│   ├── Button.stories.tsx # Storybook stories
│   ├── __test__/         # Component tests
│   └── index.ts          # Package exports
├── dist/                 # Built outputs
└── rollup.config.js      # Build configuration

Component Design Patterns:

  • Compound components for complex UI
  • Render props for flexible composition
  • Forward refs for DOM access
  • Generic types for reusable patterns

Build System

Monorepo Management

Turborepo orchestrates builds across packages:

json
{
  "pipeline": {
    "build": {
      "dependsOn": ["^build"],
      "outputs": ["dist/**"]
    },
    "test": {
      "dependsOn": ["build"]
    }
  }
}

Benefits:

  • Intelligent caching of build outputs
  • Parallel execution of independent tasks
  • Dependency-aware build ordering
  • Remote caching for CI/CD

Package Bundling

Rollup Configuration:

  • ES modules and CommonJS outputs
  • TypeScript compilation
  • Tree-shaking optimization
  • Source map generation
javascript
export default {
  input: 'src/index.ts',
  output: [
    { file: 'dist/index.esm.js', format: 'es' },
    { file: 'dist/index.cjs.js', format: 'cjs' },
  ],
  external: ['react', 'react-dom'],
  plugins: [typescript(), resolve(), commonjs()],
};

Type Safety

Design Token Types

Tokens are strongly typed for better developer experience:

typescript
// Generated types from Style Dictionary
export type GTColorKey =
  | 'GT_COLOR_PRIMARY_GOLD'
  | 'GT_COLOR_PRIMARY_NAVY'
  | 'GT_COLOR_SECONDARY_BLUE';

export const getGTColor = (key: GTColorKey): string => {
  return GT_COLORS[key];
};

Component Props

All components have comprehensive TypeScript interfaces:

typescript
export interface ButtonProps
  extends React.ButtonHTMLAttributes<HTMLButtonElement> {
  children?: React.ReactNode;
  variant?: ButtonVariant;
  size?: ButtonSize;
}

// Union types for strict prop validation
export type ButtonVariant = 'primary' | 'secondary' | 'outline';
export type ButtonSize = 'sm' | 'md' | 'lg';

Testing Strategy

Unit Testing

Vitest + Testing Library:

  • Component behavior testing
  • Accessibility compliance
  • Props validation
  • Event handling
typescript
test('Button renders with correct variant styles', () => {
  render(<Button variant="primary">Test</Button>)
  const button = screen.getByRole('button')
  expect(button).toHaveClass('button--primary')
})

Visual Regression Testing

Storybook + Chromatic:

  • Automated visual testing
  • Cross-browser compatibility
  • Responsive design validation
  • Component state coverage

Integration Testing

Cypress (Future):

  • End-to-end workflows
  • Real browser testing
  • Accessibility auditing
  • Performance monitoring

Performance Considerations

Bundle Optimization

  • Tree Shaking: Components can be imported individually
  • Code Splitting: Lazy loading for non-critical components
  • Bundle Analysis: Regular monitoring of package sizes
typescript
// Tree-shakeable imports
import { Button } from '@gtalumni-la/react';
// Not: import * as GTDesign from '@gtalumni-la/react'

Runtime Performance

  • Minimal Re-renders: Optimized component updates
  • CSS-in-CSS: No runtime style computation
  • Lazy Loading: Deferred loading of heavy components

Build Performance

  • Turborepo Caching: Aggressive caching strategy
  • Parallel Builds: Independent package building
  • Incremental Builds: Only rebuild changed packages

Accessibility Architecture

WCAG 2.1 AA Compliance

All components meet accessibility standards:

  • Semantic HTML: Proper element usage
  • ARIA Support: Comprehensive labeling
  • Keyboard Navigation: Full keyboard operability
  • Screen Reader: Compatible with assistive technology

Testing Integration

Accessibility testing is built into the development workflow:

typescript
// Automated a11y testing
test('Button is accessible', async () => {
  const { container } = render(<Button>Test</Button>)
  const results = await axe(container)
  expect(results).toHaveNoViolations()
})

Documentation Architecture

VitePress Setup

Static site generation with:

  • Markdown-based: Easy content authoring
  • Vue Components: Interactive examples
  • Version Management: Support for multiple versions
  • GitHub Pages: Automated deployment

Component Documentation

Each component includes:

  • API Reference: Complete prop documentation
  • Usage Examples: Practical implementation patterns
  • Accessibility Notes: WCAG compliance details
  • Design Guidelines: When and how to use

CI/CD Pipeline

GitHub Actions Workflow

yaml
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - name: Install & Test
        run: |
          pnpm install
          pnpm test
          pnpm build

Pipeline Stages:

  1. Lint & Type Check: Code quality validation
  2. Unit Tests: Component functionality testing
  3. Build: Package compilation and bundling
  4. Visual Tests: Storybook visual regression
  5. Deploy: Documentation and Storybook deployment

Release Management

Changesets for version management:

  • Semantic versioning
  • Automated changelog generation
  • NPM publishing automation
  • GitHub release creation

Security Considerations

Dependency Management

  • Audit: Regular dependency vulnerability scanning
  • Updates: Automated dependency updates via Dependabot
  • Minimal Dependencies: Keep external dependencies minimal

Build Security

  • Supply Chain: Verify package integrity
  • Permissions: Minimal required permissions
  • Secrets: Secure handling of API keys and tokens

Future Architecture

Planned Improvements

  • Web Components: Framework-agnostic components
  • CSS Variables: Enhanced theming capabilities
  • Performance Monitoring: Real-time performance tracking
  • Multi-Framework: Support for Vue, Angular, Svelte

Scalability Considerations

  • Micro-frontends: Support for distributed teams
  • Plugin Architecture: Extensible component system
  • Theme Engine: Advanced customization capabilities
  • Internationalization: Multi-language support

Development Workflow

Local Development

bash
# Install dependencies
pnpm install

# Start development
pnpm dev          # All packages in watch mode
pnpm storybook    # Component playground
pnpm docs:dev     # Documentation site

# Testing
pnpm test         # Run all tests
pnpm test:watch   # Watch mode testing
pnpm test:coverage # Coverage reporting

Contributing Process

  1. Issue Creation: Bug reports or feature requests
  2. Branch Creation: Feature or fix branches
  3. Development: Local development with testing
  4. PR Creation: Pull request with description
  5. Review Process: Code review and CI checks
  6. Merge: Automated testing and deployment

This architecture provides a solid foundation for scaling the design system while maintaining quality, performance, and developer experience.

Released under the MIT License.