How segmentio/evergreen works
Project type and purpose
• This is a monorepo React UI component library and design system (“Evergreen”) maintained by Segment.
• It ships polished, enterprise-grade React components, a theming layer, codemods for migrations, a Storybook and a Next.js-based documentation site, plus an SSR example.
File structure
• Top-level modules:
• src/… → dozens of component packages (alert, button, dialog, etc.) each with source, tests, and Storybook stories
• themes/ & src/theme → default theme tokens, ThemeContext, theme tools
• codemods/ → jscodeshift scripts for automated version migrations
• docs/ → Next.js documentation site, MDX content, static assets, custom UI components
• examples/ssr-next → Next.js example demonstrating SSR/hydration
• rollup.config.js, tsconfig*.json, package.json → bundling and monorepo configuration
• CI/CD: GitHub Actions (ci.yml) runs tests, linting, build, Storybook deploys.
README insights
• Encourages contributions, has detailed docs, uses Storybook and Next.js.
• Monorepo Root
• Build & Tooling
• Rollup bundler
• TypeScript compiler
• Code generators (tools/)
• Component Layer
• Evergreen components (src/**)
• Theme library (src/theme & themes/)
• Hooks & utils (src/hooks, src/lib)
• Migration Layer
• Codemods (codemods/)
• Documentation Layer
• Storybook (src/**/stories & .storybook/)
• Next.js site (docs/)
• Example Applications
• SSR Next.js example (examples/ssr-next)
• CI/CD & Publishing
• GitHub Actions (ci.yml)
• NPM registry (evergreen-ui package)
• GitHub Pages / Vercel for docs
• Source → Build & Tooling → lib/ (CJS/ESM/UMD outputs)
• lib/ → NPM Registry (publish)
• src/** → Storybook renderer → .storybook UI
• docs/ imports built components → Next.js → static site generation
• examples/ssr-next imports evergreen-ui → demonstrates SSR
• codemods consume source code → output transformed code for migrations
• CI pipeline triggered on push → runs tests (src/** & codemods), lints, builds, deploys docs
c. Architectural patterns & principles:
• Monorepo multi-package with a shared build pipeline
• Theming via React context & CSS-in-JS
• Automated migrations via codemods
• Documentation as first-class (Storybook + Next.js + MDX)
• CI/CD for quality and publishing
d. Key technologies & frameworks:
• Rollup, TypeScript
• jscodeshift (codemods)
• Storybook, Next.js, MDX
• Jest + Testing Library
• GitHub Actions