# wgr-sa/strapi-plugin-collection-tree architecture

> Architecture diagram of the GitHub repository wgr-sa/strapi-plugin-collection-tree, 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/wgr-sa/strapi-plugin-collection-tree
- Repository: https://github.com/wgr-sa/strapi-plugin-collection-tree

## Overview

##### Project Type & Purpose
- This is a Strapi plugin designed to add a collection tree functionality that allows users to drag and drop and sort their collections.
- The plugin is split between an Admin UI portion (the “admin” folder with React components, pages, translations, etc.) and a backend portion (the “server” folder with controllers, routes, services, configurations, and utilities).

##### File Structure
- Admin Frontend:
- The “admin” directory contains the src folder with its own subdirectories:
– api (for API configuration files),
– components (reusable React components like Initializer, PluginIcon, SortElement, etc.),
– pages (pages for settings, sorting views, and related interfaces),
– translations (for language support, e.g., en.json, fr.json),
– utils (auxiliary modules such as axiosInstance, getTrad, and a serverRestartWatcher).
- Backend Server:
– config (for various plugin configurations),
– controllers (with business logic for model, settings, and sort actions),
– routes (defining API endpoints to interact with the plugin’s features),
– services (which implement operations like retrieving and updating collections, sorting elements),
– middlewares and policies (for request handling, security checks, etc.),
– utilities (for actions such as schema update and tree transformation).
- Additional Files:
- Files such as “strapi-admin.js” and “strapi-server.js” indicate integration with the Strapi ecosystem.
- The presence of TypeScript configuration files (tsconfig.json, tsconfig.server.json) suggests that strong typing and a build process are used.

- Main Components:
- Frontend Admin UI: Built with React (components, pages, translations, API interactions).
- Backend API: Comprises controllers, routes, and services that handle business logic (sorting, settings, data manipulation).
- Configuration & Integration: Configuration files and bootstrap scripts ensure the plugin is integrated with Strapi.
- Relationships:
- The Admin UI communicates with the backend by issuing API calls (using the axiosInstance utility).
- The server routes direct requests to appropriate controllers which, in turn, communicate with services to perform operations on the data.
- Utility modules (both on the admin and server) assist in tasks such as schema updates, tree transformations, and internationalization.
- The configuration files and bootstrap scripts initialize server settings for the plugin upon startup.
- Architectural Patterns/Design Principles:
- Separation of concerns: Clear division between client (admin UI) and server handling.
- MVC-like organization on the server side: Routes (as the entry point), Controllers (business logic), and Services (data manipulation).
- Plugin modularity: The design encapsulates its own API, admin interface, and configuration, adhering to a modular plugin architecture for Strapi.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Admin UI Section
    subgraph "Admin UI"
        A1("Admin UI - React Frontend"):::admin
        A2("API Config"):::admin
        A3("Components"):::admin
        A4("Pages"):::admin
        A5("Translations"):::admin
        A6("Utilities"):::admin
    end

    %% Backend API Section
    subgraph "Backend API"
        B1("Backend API - Server Code"):::backend
        B2("Configurations"):::backend
        B3("Controllers"):::backend
        B4("Routes"):::backend
        B5("Services"):::backend
        B6("Middlewares & Policies"):::backend
        B7("Utilities"):::backend
        B8("Built Server Code"):::backend
    end

    %% Strapi Integration Section
    subgraph "Strapi Integration"
        SI1("strapi-admin.js"):::integration
        SI2("strapi-server.js"):::integration
    end

    %% Relationships between Admin and Backend
    A1 -->|"APIcalls"| B1
    A6 -->|"axiosCall"| B4
    B2 -->|"configures"| B4
    B4 -->|"calls"| B3
    B3 -->|"invokes"| B5
    B1 -->|"buildsTo"| B8
    SI1 -->|"integrates"| A1
    SI2 -->|"integrates"| B1

    %% Styles
    classDef admin fill:#fcb,stroke:#000,stroke-width:2px;
    classDef backend fill:#ccf,stroke:#000,stroke-width:2px;
    classDef integration fill:#cfc,stroke:#000,stroke-width:2px;

    %% Click Events for Admin UI Components
    click A1 "https://github.com/wgr-sa/strapi-plugin-collection-tree/tree/main/admin/src"
    click A2 "https://github.com/wgr-sa/strapi-plugin-collection-tree/tree/main/admin/src/api"
    click A3 "https://github.com/wgr-sa/strapi-plugin-collection-tree/tree/main/admin/src/components"
    click A4 "https://github.com/wgr-sa/strapi-plugin-collection-tree/tree/main/admin/src/pages"
    click A5 "https://github.com/wgr-sa/strapi-plugin-collection-tree/tree/main/admin/src/translations"
    click A6 "https://github.com/wgr-sa/strapi-plugin-collection-tree/tree/main/admin/src/utils"

    %% Click Events for Backend API Components
    click B1 "https://github.com/wgr-sa/strapi-plugin-collection-tree/tree/main/server"
    click B2 "https://github.com/wgr-sa/strapi-plugin-collection-tree/tree/main/server/config"
    click B3 "https://github.com/wgr-sa/strapi-plugin-collection-tree/tree/main/server/controllers"
    click B4 "https://github.com/wgr-sa/strapi-plugin-collection-tree/tree/main/server/routes"
    click B5 "https://github.com/wgr-sa/strapi-plugin-collection-tree/tree/main/server/services"
    click B6 "https://github.com/wgr-sa/strapi-plugin-collection-tree/tree/main/server/middlewares"
    click B7 "https://github.com/wgr-sa/strapi-plugin-collection-tree/tree/main/server/utils"
    click B8 "https://github.com/wgr-sa/strapi-plugin-collection-tree/tree/main/dist/server"

    %% Click Events for Strapi Integration Files
    click SI1 "https://github.com/wgr-sa/strapi-plugin-collection-tree/blob/main/strapi-admin.js"
    click SI2 "https://github.com/wgr-sa/strapi-plugin-collection-tree/blob/main/strapi-server.js"
```
