# easypanel-io/templates architecture

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

- Interactive diagram: https://gitdiagram.com/easypanel-io/templates
- Repository: https://github.com/easypanel-io/templates

## Overview

This project is a Next.js–based application built to host and manage a large collection of Easypanel templates. Its primary purpose is to provide a playground where developers can duplicate, customize, and test their template configurations before contributing a pull request. In other words, it serves as both a template repository and a live-testing front end for Easypanel templates.

##### Main Components
- Frontend Application: The “pages” directory (including pages/index.tsx, pages/[slug].tsx, and pages/_app.tsx) implements the Next.js-based frontend. This component is responsible for routing (rendering the home page, individual template pages via [slug]), and displaying the testing playground.
- Template Library: The extensive “templates” directory forms the heart of the project. It organizes numerous template folders (such as “2fauth”, “ackee”, “activepieces”, and many more) where each template contains key files (index.ts, meta.yaml, assets). This is the repository of template definitions.
- Build & Automation Scripts: The “scripts” directory contains automation scripts (e.g., build-docs.ts, build-templates.ts, check-for-updates.ts, etc.) that are used to generate documentation, compile the templates list, and update the project. These scripts automate the overall CI/CD and development workflow.
- Utility Modules: The “utils” folder (with index.ts and schema.ts) holds shared utility functions and schema definitions that support both the frontend and script-based build processes.
- Configuration & Tooling: Files like .eslintrc.json, next.config.js, nodemon.json, tsconfig.json, and others provide code quality, TypeScript configuration, and environment settings that tie the project together.

##### Relationships and Data Flows
- The frontend accesses and displays template data by reading the meta information and assets from the Templates Library. For instance, when a user navigates to a specific template’s page (via [slug].tsx), the page retrieves and renders information from the corresponding template folder.
- The Build & Automation Scripts act upon the Templates Library and Utilities to generate documentation and update template listings. They form a pipeline that ensures the frontend always displays up-to-date content.
- Configuration files and tool settings work as supporting infrastructure, ensuring that code formatting, linting, and build processes are executed correctly.

##### Architectural Patterns & Key Design Principles
- Modular Separation: The project clearly separates core concerns – frontend rendering (Next.js “pages”), template definitions (under “templates”), and build automation (in “scripts”). This modular design makes extension and maintenance easier.
- File-Based Routing: Utilization of Next.js’s file-based routing system simplifies URL mapping (evidenced by the dynamic route [slug].tsx) and helps in directly linking templates to their display pages.
- Build-Time Automation: Automated scripts and utility functions ensure that template metadata remains in sync with the frontend, following best practices for continuous integration and delivery.
- Consistency & Standardization: Each template folder has a consistent structure (meta.yaml, index.ts, assets), simplifying processing by the automation scripts and ensuring uniform behavior in the testing playground.

##### Relevant Technologies, Frameworks, and Libraries
- Next.js for the frontend application (routing, rendering, and server-side capabilities).
- TypeScript (files like next-env.d.ts, tsconfig.json) for static typing.
- ESLint and Prettier for code linting and formatting.
- Node.js scripts (in “scripts”) that use automation frameworks to build docs and update templates.
- YAML for defining template meta-information in meta.yaml files.

##### Be Detailed Yet Concise
- Every high-level component and make sure to list important subcomponents like dynamic routing on the frontend or the standardized structure inside each template folder.
- Don’t shy away from illustrating even supporting elements—every configuration file has its role.

Happy diagramming!

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        FE1["pages/index.tsx"]:::frontend
        FE2["pages/[slug].tsx"]:::frontend
        FE3["pages/_app.tsx"]:::frontend
    end

    %% Template Library
    subgraph "Template Library"
        TL["templates (all template folders)"]:::library
    end

    %% Build & Automation Scripts
    subgraph "Build & Automation Scripts"
        BS1["build-docs.ts"]:::script
        BS2["build-templates.ts"]:::script
        BS3["check-for-updates.ts"]:::script
    end

    %% Utility Functions & Schema
    subgraph "Utility Functions & Schema"
        U1["index.ts"]:::utils
        U2["schema.ts"]:::utils
    end

    %% Configuration & Tooling
    subgraph "Configuration & Tooling"
        C1[".eslintrc.json"]:::config
        C2["next.config.js"]:::config
        C3["nodemon.json"]:::config
        C4["tsconfig.json"]:::config
    end

    %% Relationships
    TL -->|"provides_meta"| FE1

    BS1 -->|"processes"| TL
    BS2 -->|"processes"| TL
    BS3 -->|"processes"| TL

    BS1 -->|"updates_UI"| FE1
    BS2 -->|"updates_UI"| FE1
    BS3 -->|"updates_UI"| FE1

    U1 -->|"shared_util"| FE1
    U2 -->|"shared_schema"| FE1

    U1 -->|"supports_script"| BS1
    U1 -->|"supports_script"| BS2
    U1 -->|"supports_script"| BS3

    C1 -->|"configures"| FE1
    C2 -->|"configures"| FE1
    C3 -->|"configures"| BS1
    C4 -->|"configures"| BS1

    %% Click Events
    click FE1 "https://github.com/easypanel-io/templates/blob/main/pages/index.tsx"
    click FE2 "https://github.com/easypanel-io/templates/blob/main/pages/[slug].tsx"
    click FE3 "https://github.com/easypanel-io/templates/blob/main/pages/_app.tsx"
    click TL "https://github.com/easypanel-io/templates/tree/main/templates"
    click BS1 "https://github.com/easypanel-io/templates/blob/main/scripts/build-docs.ts"
    click BS2 "https://github.com/easypanel-io/templates/blob/main/scripts/build-templates.ts"
    click BS3 "https://github.com/easypanel-io/templates/blob/main/scripts/check-for-updates.ts"
    click U1 "https://github.com/easypanel-io/templates/blob/main/utils/index.ts"
    click U2 "https://github.com/easypanel-io/templates/blob/main/utils/schema.ts"
    click C1 "https://github.com/easypanel-io/templates/blob/main/.eslintrc.json"
    click C2 "https://github.com/easypanel-io/templates/blob/main/next.config.js"
    click C3 "https://github.com/easypanel-io/templates/blob/main/nodemon.json"
    click C4 "https://github.com/easypanel-io/templates/blob/main/tsconfig.json"

    %% Styles
    classDef frontend fill:#AEDFF7,stroke:#1F77B4,stroke-width:2px;
    classDef library fill:#D5F5E3,stroke:#28B463,stroke-width:2px;
    classDef script fill:#F9E79F,stroke:#D4AC0D,stroke-width:2px;
    classDef utils fill:#FADBD8,stroke:#E74C3C,stroke-width:2px;
    classDef config fill:#E8DAEF,stroke:#8E44AD,stroke-width:2px;
```
