How geeky-biz/strapi-plugin-components-usage-info works
1. What this repository is
- This is a Strapi v5 plugin named strapi-plugin-components-usage-info.
- Its job is to help an operator find where a given component is actually used with data across the CMS, including nested component usage and locales.
2. Top-level split: admin UI vs server logic
- The repo is divided into two clear halves:
- admin/ for the Strapi admin panel extension.
- server/ for the plugin backend inside the Strapi runtime.
- This is the main architectural boundary: the admin side is presentation and interaction; the server side owns schema inspection and data lookup.
3. Admin subsystem
- admin/src/pages/App.jsx and admin/src/pages/HomePage.jsx appear to define the plugin’s screen(s) in the Strapi admin.
- admin/src/components/Initializer.jsx and Loader.jsx suggest a lightweight bootstrap/loading experience while plugin state or data is being prepared.
- PluginIcon.jsx and TooltipIconButton.jsx are UI affordances used to integrate into the Strapi admin experience.
- admin/src/translations/en.json and utils/getTranslation.js show the UI is localized and likely uses Strapi’s translation hooks.
4. Admin runtime boundary
- The admin code is a React-based extension of the Strapi dashboard, not a standalone app.
- It likely renders a component selector and results view, but does not directly compute usage itself; instead it calls the plugin backend.
5. Server subsystem
- The backend plugin entry points are server/src/index.js, register.js, bootstrap.js, and destroy.js.
- These files match Strapi plugin lifecycle hooks:
- register for plugin registration/wiring,
- bootstrap for startup initialization,
- destroy for cleanup.
- server/src/config/index.js, middlewares/index.js, policies/index.js, routes/index.js, controllers/index.js, and services/index.js are the standard Strapi plugin module registries.
6. Core business logic boundary
- server/src/services/service.js is the most likely place where the actual component-usage discovery logic lives.
- server/src/controllers/componentsInfoController.js is the API layer that exposes that logic to the admin UI.
- This separation implies a classic Strapi pattern:
- controller = request/response handling,
- service = domain logic and data traversal.
7. Expected data flow
- The admin UI likely:
1. loads the available components,
2. lets the user select one,
3. calls a backend route,
4. receives collections/records where that component is populated.
- The backend likely inspects Strapi schemas/content types and queries entries to determine usage.
- The README confirms the backend considers:
- nested components recursively,
- locales,
- only published records.
8. Strapi metadata and content model access
- server/src/content-types/index.js indicates the plugin may define or expose plugin-specific content types, or it may simply follow Strapi’s expected plugin structure with no substantial models.
- More importantly, the server must have access to Strapi’s content-type registry to resolve where components appear across collections and nested structures.
9. Routing and access control
- server/src/routes/index.js and server/src/policies/index.js imply the backend API is gated through Strapi’s routing/policy system.
- server/src/middlewares/index.js exists as part of the plugin scaffold, suggesting request processing can be extended, though nothing in the file tree suggests heavy middleware use.
10. Plugin identity and integration
- admin/src/pluginId.js is the admin-side plugin identifier used to bind the UI into Strapi’s plugin system.
- server/src/config/index.js likely supplies the plugin’s server-side configuration defaults.
- Together they let the plugin be enabled in config/plugin.js as described in the README.
11. Static assets and packaging
- images/ contains documentation/screenshot assets, not runtime logic.
- Root-level package.json and package-lock.json show this is packaged as an npm-distributable Strapi plugin.
- The presence of .prettierrc, .eslintrc-style ignore files, and jsconfig.json files indicates a JavaScript/React/Node codebase with editor tooling support.
12. Architectural summary for diagramming
- Draw this as a Strapi plugin with two major planes:
- Admin UI plane: React pages/components in admin/ rendering the component-selection experience.
- Backend API plane: Strapi plugin routes/controllers/services in server/ performing schema traversal and published-entry lookup.
- The key interaction is: admin UI → plugin API → Strapi content metadata/data → response back to admin UI.
- The plugin’s distinguishing logic is the recursive detection of component usage across nested components and localized published content.
Main entry points: HomePage.jsx Home page · src/index.js Server entry · routes/index.js Routes · service.js Usage service
Components 21
Admin UI
React-based Strapi admin extension for selecting a component and viewing usage results.
- Plugin entry · Registers the admin extension inside Strapi.
admin/src/index.js - App shell · Top-level admin page wrapper for the plugin UI.
admin/src/pages/App.jsx - Home page · Main screen where component usage is explored.
admin/src/pages/HomePage.jsx - Initializer · Prepares plugin state before the main view renders.
admin/src/components/Initializer.jsx - Loader · Loading state shown while data or plugin state is being prepared.
admin/src/components/Loader.jsx - Plugin icon · Visual identity for the plugin in the Strapi admin.
admin/src/components/PluginIcon.jsx - Tooltip button · Reusable admin button with tooltip behavior.
admin/src/components/TooltipIconButton.jsx - Translations · Admin-side translation catalog for UI text.
admin/src/translations/en.json - Translate util · Helper for resolving localized admin strings.
admin/src/utils/getTranslation.js - Plugin ID · Admin-side identifier used to bind the extension into Strapi.
admin/src/pluginId.js
Backend API
Strapi plugin runtime that registers routes and resolves component usage from content data.
- Server entry · Main backend plugin export and wiring point.
server/src/index.js - Register · Plugin registration and runtime wiring.
server/src/register.js - Bootstrap · Startup initialization for the plugin runtime.
server/src/bootstrap.js - Destroy · Cleanup hook for plugin shutdown.
server/src/destroy.js - Routes · HTTP route definitions for the plugin API.
server/src/routes/index.js - Usage controller · Handles requests from the admin UI and returns usage results.
server/src/controllers/componentsInfoController.js - Usage service · Core logic for finding where components are used in content.
server/src/services/service.js - Config · Server-side plugin configuration defaults.
server/src/config/index.js - Policies · Policy registry protecting plugin routes.
server/src/policies/index.js - Content types · Plugin content-type registry scaffold or definitions.
server/src/content-types/index.js - Middlewares · Optional plugin middleware registry.
server/src/middlewares/index.js
Connections 20
- Plugin entry → App shell: mounts · The admin entry mounts the plugin UI shell.
- App shell → Initializer: initializes · The app shell prepares state before showing content.
- Initializer → Home page: renders · Initializer leads into the primary home screen.
- Home page → Loader: uses · Home view shows loading feedback during fetches.
- Home page → Tooltip button: uses · Home view reuses icon button controls.
- Home page → Plugin icon: brands · The plugin icon provides admin-side identity.
- Home page → Translate util: localizes · Home UI resolves translated strings.
- Translate util → Translations: reads · Translation helper reads the locale catalog.
- Plugin entry → Plugin ID: identifies · The plugin entry uses the shared plugin identifier.
- Home page → Routes: calls API · The admin screen fetches component-usage data from the backend.
- Server entry → Register: wires · Backend plugin entry exposes lifecycle hooks.
- Server entry → Bootstrap: wires · Backend plugin entry exposes startup initialization.
- Server entry → Destroy: wires · Backend plugin entry exposes shutdown cleanup.
- Server entry → Routes: exposes · Backend plugin registers its HTTP routes.
- Routes → Policies: guards · Routes are protected by plugin policies.
- Routes → Usage controller: dispatches · Route handlers forward requests to the controller.
- Usage controller → Usage service: delegates · Controller delegates component-usage discovery to the service.
- Usage service → Content types: inspects · Service resolves component placement against content model metadata.
- Usage service → Config: uses · Service can read plugin configuration during lookup.
- Server entry → Middlewares: includes · Backend plugin includes the middleware registry scaffold.