# primer/figma architecture

> Architecture diagram of the GitHub repository primer/figma, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/primer/figma
- Repository: https://github.com/primer/figma

## Overview

##### Main Components
a. Version Control & Repository:
- GitHub repository as the foundation of the project’s lifecycle.
- It includes configuration files (.gitignore, CODEOWNERS) and the root README that documents usage and guides.
b. CI/CD Automation via GitHub Actions:
- Clearly denote the CI/CD pipelines, showing two distinct workflows (docgen-brand and docgen-web) that trigger on changes.
- These pipelines automate documentation generation or other related tasks.
c. Monorepo Structure – Packages:
- The “brand” package: Contains its own package.json, CHANGELOG, and a “generated” directory for components.json.
- The “web” package: Similarly structured with its own assets and documentation.
- Each package is a self-contained module that contributes to the overall Primer for Figma system.
d. External References & Documentation:
- Connection to external design documentation sources, such as Primer.style and Figma community files.
- These links show how the design assets integrate into broader design guidelines and community usage.

##### Relationships and Data Flow
- From developers editing the source code within the monorepo (both packages and CI configuration) to GitHub where commits trigger the CI/CD workflows.
- From GitHub Actions workflows (docgen-brand and docgen-web) to the generation of assets (stored under “generated” folders within each package).
- From the output of these pipelines to the external displays (Primer.style documentation, internal and community Figma files).

##### Highlighting Architectural Patterns
- Monorepo Architecture: Emphasize that multiple packages (brand and web) are managed within a single repository.
- Continuous Integration/Continuous Deployment (CI/CD): Underline how GitHub Actions is configured for automated documentation generation.
- Modularity: Indicate that the two packages, while sharing a common repository, serve distinct aspects of the design system.

##### Technologies, Frameworks, and Tools
- GitHub and GitHub Actions (for version control and automation).
- Node.js ecosystems (as seen by package.json files, possibly indicating dependency management and script execution).
- Figma (with various internal and community design files that are integrated with the documented design guidelines).
- Optional: Documentation generation scripts (referenced in the workflow files) and how they interact with the JSON files in the “generated” folders.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Developer("Developer"):::actor
    Repository("Primer for Figma Repository"):::repo
    CICD("CI/CD Workflows"):::ci
    DocgenBrand("docgen-brand"):::ciWorkflow
    DocgenWeb("docgen-web"):::ciWorkflow
    Brand("Brand Package"):::package
    Web("Web Package"):::package
    External("External Documentation & Community"):::external

    Developer -->|"commits"| Repository
    Repository -->|"triggers"| CICD
    CICD -->|"executes"| DocgenBrand
    CICD -->|"executes"| DocgenWeb
    DocgenBrand -->|"generates"| Brand
    DocgenWeb -->|"generates"| Web
    Brand -->|"publishes"| External
    Web -->|"publishes"| External

    click Repository "https://github.com/primer/figma/tree/main/Root directory"
    click CICD "https://github.com/primer/figma/tree/main/.github/workflows"
    click DocgenBrand "https://github.com/primer/figma/blob/main/.github/workflows/docgen-brand.yml"
    click DocgenWeb "https://github.com/primer/figma/blob/main/.github/workflows/docgen-web.yml"
    click Brand "https://github.com/primer/figma/tree/main/packages/brand"
    click Web "https://github.com/primer/figma/tree/main/packages/web"

    classDef actor fill:#bbf,stroke:#333,stroke-width:2px;
    classDef repo fill:#f96,stroke:#333,stroke-width:2px;
    classDef ci fill:#afc,stroke:#333,stroke-width:2px;
    classDef ciWorkflow fill:#afa,stroke:#333,stroke-width:2px;
    classDef package fill:#cff,stroke:#333,stroke-width:2px;
    classDef external fill:#f9c,stroke:#333,stroke-width:2px;
```
