Skip to content

Refactor: Auto-Discovery Plugin System for Tool Registration#62

Closed
Suvam-paul145 wants to merge 15 commits intobetterbugs:developfrom
Suvam-paul145:44
Closed

Refactor: Auto-Discovery Plugin System for Tool Registration#62
Suvam-paul145 wants to merge 15 commits intobetterbugs:developfrom
Suvam-paul145:44

Conversation

@Suvam-paul145
Copy link

@Suvam-paul145 Suvam-paul145 commented Mar 2, 2026

Problem Description

The existing tool registration system relied on a monolithic manual registry pattern:

  • A 77KB constants.tsx file containing hardcoded tool definitions.
  • Manual metadata management inside developmentToolsConstant.tsx.
  • Tight coupling between route constants and tool configuration.
  • Circular dependency issues between registry and shared constants.
  • All 174+ tools were eagerly imported, preventing proper Next.js code splitting.
  • Poor scalability — every new tool required manual edits in multiple places.

This architecture caused:

  • Large bundle size on initial load.
  • Reduced maintainability.
  • Increased risk of developer error.
  • Slower build-time module evaluation.
  • Poor extensibility.

Solution Overview

The system has been refactored into a build-time auto-discovery plugin architecture.

The new model:

  • Each tool owns its own metadata.
  • A build script auto-aggregates all metadata.
  • A registry is generated automatically.
  • Dynamic imports enable proper code splitting.
  • Circular dependencies are eliminated.

This creates a scalable and modular plugin-based tool system.


Architecture After Refactor

::contentReference[oaicite:0]{index=0}


Key Changes Made

1. Isolated PATHS Constant

Problem

PATHS was embedded inside the registry system, creating circular dependency issues.

Solution

Extracted PATHS into a standalone module.

New File

app/libs/paths.ts

This ensures:

  • No registry-to-metadata coupling
  • Clean dependency graph
  • Predictable import order

2. Automated Tool Registry (Build-Time Generated)

Problem

Manual tool registration inside:

constants.tsx
developmentToolsConstant.tsx

This required:

  • Manual edits for every new tool
  • Duplicate metadata definitions
  • Increased bundle size

Solution

Created an auto-generated registry:

New File

developmentToolsRegistry.tsx (Auto-generated)

Modified Files

constants.tsx (Now re-exports registry)
developmentToolsConstant.tsx (Now re-exports registry)

The registry is now generated at build-time using metadata discovered from tool directories.


3. Co-Located Metadata Plugin Model

Each tool now manages its own metadata.

New Pattern

app/components/developmentToolsComponent/
 ├── ToolA.tsx
 ├── ToolA.meta.tsx
 ├── ToolB.tsx
 ├── ToolB.meta.tsx

Each .meta.tsx file exports structured metadata only.

Benefits

  • Encapsulation
  • Decentralized configuration
  • Easier onboarding
  • No global registry editing
  • Reduced merge conflicts

4. Build-Time Registry Generator

A script aggregates all .meta.tsx files and generates a typed registry.

New File

scripts/generateRegistry.js

Modified

package.json

Added pre-build hooks:

"scripts": {
  "predev": "node scripts/generateRegistry.js",
  "prebuild": "node scripts/generateRegistry.js"
}

Build Flow

node scripts/generateRegistry.js
↓
Aggregates all *.meta.tsx
↓
Generates developmentToolsRegistry.tsx
↓
Next.js build executes
↓
Dynamic imports enable code splitting

closes #44

What Changed (File-Level Summary)

New Files

  • app/libs/paths.ts
  • developmentToolsRegistry.tsx (auto-generated)
  • scripts/generateRegistry.js
  • app/components/developmentToolsComponent/*.meta.tsx

Modified Files

  • constants.tsx
  • developmentToolsConstant.tsx
  • package.json

Removed Responsibilities

  • Manual registry management
  • Manual metadata duplication
  • Tight coupling between constants and tool config

Performance Improvements

Before

  • 174+ tools eagerly imported
  • Large initial JS bundle
  • Registry loaded on home page
  • Transitive dependency bloat (antd, bcryptjs, etc.)

After

  • Tools imported via next/dynamic
  • True route-based code splitting
  • Metadata stripped of heavy dependencies
  • Faster module evaluation
  • Reduced home page bundle size

Automated Build Verification

node scripts/generateRegistry.js && next build

Result:

  • Successful compilation
  • No circular dependency warnings
  • Static pages generated successfully
  • Clean dependency graph

Workflow Diagram (What This GPT Performs)

::contentReference[oaicite:1]{index=1}

Step-by-Step Workflow

Developer Adds Tool
        ↓
Create ToolName.tsx
        ↓
Create ToolName.meta.tsx
        ↓
Run npm run dev / build
        ↓
generateRegistry.js scans filesystem
        ↓
Aggregates metadata
        ↓
Generates developmentToolsRegistry.tsx
        ↓
Next.js builds with dynamic imports
        ↓
Tool becomes automatically registered

How to Add a New Tool

  1. Create component:
app/components/developmentToolsComponent/ToolName.tsx
  1. Create metadata:
app/components/developmentToolsComponent/ToolName.meta.tsx
  1. Use PATHS from:
app/libs/paths.ts
  1. Run:
npm run dev

No manual registry edits required.


Architectural Impact

Area Before After
Registration Manual Auto-generated
Metadata Centralized Co-located
Code Splitting Ineffective Fully dynamic
Circular Dependencies Present Eliminated
Scalability Limited Horizontal
DX High friction Seamless

Final Outcome

  • 174+ tools fully modularized
  • Zero manual registry updates
  • Proper Next.js code splitting
  • Clean dependency graph
  • Plugin-style extensibility
  • Improved developer experience
  • Reduced bundle size
  • Production-safe build automation

The tool system is now modular, scalable, and future-proof.

Suvam-paul145 and others added 7 commits February 27, 2026 21:31
- Created passwordStrengthMeter.tsx component with advanced password analysis
- Uses zxcvbn library for realistic entropy-based strength assessment
- Displays color-coded strength meter (Very Weak to Very Strong)
- Shows detailed crack time estimates for different attack scenarios
- Provides warnings and suggestions for password improvement
- Includes visibility toggle, copy, and clear functionality
- Added comprehensive component configuration to developmentToolsConstant.tsx
- Registered component and routes in constants.tsx
- Added zxcvbn and @types/zxcvbn dependencies to package.json
- Full TypeScript typing with proper null checks
- Matches project styling and UI patterns

Closes betterbugs#19
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
….tsx

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Moves development tool routes and category content to a separate registry module and introduces a pre-build script to generate the registry before starting or building the app.

Improves code structure and maintainability by reducing file size and centralizing registry logic.
Copilot AI review requested due to automatic review settings March 2, 2026 16:17
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors the development tools system toward a build-time, auto-discovered plugin model by introducing per-tool metadata modules that can be aggregated into a generated registry.

Changes:

  • Added many co-located *.meta.tsx files exporting structured meta objects for each tool.
  • Standardized tool routes to reference shared PATHS constants within metadata.
  • Expanded tool page content metadata (hero/about/steps/SEO) to support registry generation and dynamic loading.

Reviewed changes

Copilot reviewed 176 out of 192 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
app/components/developmentToolsComponent/yamlFormatterAndBeautifier.meta.tsx Adds metadata for the YAML formatter tool
app/components/developmentToolsComponent/xorCalculator.meta.tsx Adds metadata for the XOR calculator tool
app/components/developmentToolsComponent/xmlToJsonConverter.meta.tsx Adds metadata for the XML→JSON converter tool
app/components/developmentToolsComponent/xmlEscape.meta.tsx Adds metadata for the XML escape tool
app/components/developmentToolsComponent/xmlCompare.meta.tsx Adds metadata for the XML compare tool
app/components/developmentToolsComponent/whatsMyBrowserSize.meta.tsx Adds metadata for the “What’s my browser size?” tool
app/components/developmentToolsComponent/whatVersionOfSafariDoIHave.meta.tsx Adds metadata for the Safari version tool
app/components/developmentToolsComponent/whatVersionOfMacOSDoIHave.meta.tsx Adds metadata for the macOS version tool
app/components/developmentToolsComponent/whatVersionOfJavaDoIHave.meta.tsx Adds metadata for the Java version tool
app/components/developmentToolsComponent/whatVersionOfIOSDoIHave.meta.tsx Adds metadata for the iOS version tool
app/components/developmentToolsComponent/whatVersionOfFlashDoIHave.meta.tsx Adds metadata for the Flash version info tool
app/components/developmentToolsComponent/whatVersionOfFirefoxDoIHave.meta.tsx Adds metadata for the Firefox version tool
app/components/developmentToolsComponent/whatVersionOfChromeDoIHave.meta.tsx Adds metadata for the Chrome version tool
app/components/developmentToolsComponent/whatVersionOfAndroidDoIHave.meta.tsx Adds metadata for the Android version tool
app/components/developmentToolsComponent/whatIsMyLocalIPAddress.meta.tsx Adds metadata for the local IP address tool
app/components/developmentToolsComponent/urlEncode.meta.tsx Adds metadata for the URL encode tool
app/components/developmentToolsComponent/unicodeToAsciiConverter.meta.tsx Adds metadata for the Unicode→ASCII tool
app/components/developmentToolsComponent/typescriptFormatter.meta.tsx Adds metadata for the TypeScript formatter tool
app/components/developmentToolsComponent/textToCsv.meta.tsx Adds metadata for the Text→CSV tool
app/components/developmentToolsComponent/textRepeater.meta.tsx Adds metadata for the Text Repeater tool
app/components/developmentToolsComponent/textCompare.meta.tsx Adds metadata for the Text Compare tool
app/components/developmentToolsComponent/stripHTML.meta.tsx Adds metadata for the Strip HTML tool
app/components/developmentToolsComponent/stringDiffrenceChecker.meta.tsx Adds metadata for the String Difference Checker tool
app/components/developmentToolsComponent/sqlToJson.meta.tsx Adds metadata for the SQL→JSON tool
app/components/developmentToolsComponent/sqlToCsvConverter.meta.tsx Adds metadata for the SQL→CSV tool
app/components/developmentToolsComponent/sqlMinify.meta.tsx Adds metadata for the SQL minify tool
app/components/developmentToolsComponent/sqlFormatterAndBeautifier.meta.tsx Adds metadata for the SQL formatter tool
app/components/developmentToolsComponent/sortingList.meta.tsx Adds metadata for the Sorting List tool
app/components/developmentToolsComponent/shuffleTextLines.meta.tsx Adds metadata for the Shuffle Text Lines tool
app/components/developmentToolsComponent/shuffleLetters.meta.tsx Adds metadata for the Shuffle Letters tool
app/components/developmentToolsComponent/rotationCalculatorComponent.meta.tsx Adds metadata for the Rotation Calculator tool
app/components/developmentToolsComponent/rotateImageTool.meta.tsx Adds metadata for the Rotate Image tool
app/components/developmentToolsComponent/rot13EncoderDecoderComponent.meta.tsx Adds metadata for the ROT13 tool
app/components/developmentToolsComponent/rgbToHexConverter.meta.tsx Adds metadata for the RGB→HEX tool
app/components/developmentToolsComponent/rgbToCmykConverter.meta.tsx Adds metadata for the RGB→CMYK tool
app/components/developmentToolsComponent/remToPxConverter.meta.tsx Adds metadata for the REM→PX tool
app/components/developmentToolsComponent/randomXMLGenerator.meta.tsx Adds metadata for the Random XML Generator tool
app/components/developmentToolsComponent/randomTextFromRegEX.meta.tsx Adds metadata for the Random Text From Regex tool
app/components/developmentToolsComponent/randomIPGenerator.meta.tsx Adds metadata for the Random IP Generator tool
app/components/developmentToolsComponent/randomGUIDGenerator.meta.tsx Adds metadata for the Random GUID generator tool
app/components/developmentToolsComponent/randomCharacterGenerator.meta.tsx Adds metadata for the Random Character Generator tool
app/components/developmentToolsComponent/randomAddressGenerator.meta.tsx Adds metadata for the Random Address Generator tool
app/components/developmentToolsComponent/qrCodeGenerator.meta.tsx Adds metadata for the QR Code Generator tool
app/components/developmentToolsComponent/pythonFormatter.meta.tsx Adds metadata for the Python formatter tool
app/components/developmentToolsComponent/pxToRemConverter.meta.tsx Adds metadata for the PX→REM tool
app/components/developmentToolsComponent/placeholderImageGenerator.meta.tsx Adds metadata for the Placeholder Image Generator tool
app/components/developmentToolsComponent/phpFormatter.meta.tsx Adds metadata for the PHP formatter tool
app/components/developmentToolsComponent/morseCodeTranslator.meta.tsx Adds metadata for the Morse Code translator tool
app/components/developmentToolsComponent/milesToKmConverter.meta.tsx Adds metadata for the Miles→Kilometers tool
app/components/developmentToolsComponent/lineCounterComponent.meta.tsx Adds metadata for the line counter tool
app/components/developmentToolsComponent/kmToMilesConverter.meta.tsx Adds metadata for the Kilometers→Miles tool
app/components/developmentToolsComponent/jwtDecoder.meta.tsx Adds metadata for the JWT decoder tool
app/components/developmentToolsComponent/jsonToXmlConverter.meta.tsx Adds metadata for the JSON→XML tool
app/components/developmentToolsComponent/jsonCompare.meta.tsx Adds metadata for the JSON compare tool
app/components/developmentToolsComponent/javascriptValidatorLinter.meta.tsx Adds metadata for the JS validator/linter tool
app/components/developmentToolsComponent/javascriptTester.meta.tsx Adds metadata for the JS tester tool
app/components/developmentToolsComponent/javascriptRegexTester.meta.tsx Adds metadata for the JS regex tester tool
app/components/developmentToolsComponent/javascriptEscape.meta.tsx Adds metadata for the JS escape tool
app/components/developmentToolsComponent/ipToHexConverter.meta.tsx Adds metadata for the IP→Hex tool
app/components/developmentToolsComponent/htmlViewer.meta.tsx Adds metadata for the HTML Viewer tool
app/components/developmentToolsComponent/htmlToJade.meta.tsx Adds metadata for the HTML→Jade/Pug tool
app/components/developmentToolsComponent/htmlToBBCode.meta.tsx Adds metadata for the HTML→BBCode tool
app/components/developmentToolsComponent/htmlPrettify.meta.tsx Adds metadata for the HTML prettify tool
app/components/developmentToolsComponent/htmlMinify.meta.tsx Adds metadata for the HTML minify tool
app/components/developmentToolsComponent/htmlEscape.meta.tsx Adds metadata for the HTML escape tool
app/components/developmentToolsComponent/htmlCodeGenerator.meta.tsx Adds metadata for the HTML code generator tool
app/components/developmentToolsComponent/hoursToSecounds.meta.tsx Adds metadata for the hours→seconds tool
app/components/developmentToolsComponent/hexToRGBConverter.meta.tsx Adds metadata for the HEX→RGB tool
app/components/developmentToolsComponent/hexToPantone.meta.tsx Adds metadata for the HEX→Pantone tool
app/components/developmentToolsComponent/graphqlFormatter.meta.tsx Adds metadata for the GraphQL formatter tool
app/components/developmentToolsComponent/fibonacciCalculator.meta.tsx Adds metadata for the Fibonacci calculator tool
app/components/developmentToolsComponent/excelCompare.meta.tsx Adds metadata for the Excel compare tool
app/components/developmentToolsComponent/decimalToGrayCode.meta.tsx Adds metadata for the Decimal→Gray code tool
app/components/developmentToolsComponent/csvToExcelFileConvertor.meta.tsx Adds metadata for the CSV→Excel tool
app/components/developmentToolsComponent/cssValidator.meta.tsx Adds metadata for the CSS validator tool
app/components/developmentToolsComponent/cssToStylus.meta.tsx Adds metadata for the CSS→Stylus tool
app/components/developmentToolsComponent/cssToSass.meta.tsx Adds metadata for the CSS→SASS tool
app/components/developmentToolsComponent/cssToLess.meta.tsx Adds metadata for the CSS→LESS tool
app/components/developmentToolsComponent/cssPrettify.meta.tsx Adds metadata for the CSS prettify tool
app/components/developmentToolsComponent/cssMinify.meta.tsx Adds metadata for the CSS minify tool
app/components/developmentToolsComponent/crontabGenerator.meta.tsx Adds metadata for the crontab generator tool
app/components/developmentToolsComponent/colorPickerTool.meta.tsx Adds metadata for the color picker tool
app/components/developmentToolsComponent/colorInvertor.meta.tsx Adds metadata for the color inverter tool
app/components/developmentToolsComponent/cmykToRgbConverter.meta.tsx Adds metadata for the CMYK→RGB tool
app/components/developmentToolsComponent/binaryToDecimalConverter.meta.tsx Adds metadata for the Binary→Decimal tool
app/components/developmentToolsComponent/bcdToDecimalConverter.meta.tsx Adds metadata for the BCD→Decimal tool
app/components/developmentToolsComponent/base64Encoder.meta.tsx Adds metadata for the Base64 encoder tool
app/components/developmentToolsComponent/base64Decoder.meta.tsx Adds metadata for the Base64 decoder tool
app/components/developmentToolsComponent/asciiToUnicodeConverter.meta.tsx Adds metadata for the ASCII→Unicode tool
app/components/developmentToolsComponent/asciiToDecimalConverter.meta.tsx Adds metadata for the ASCII→Decimal tool
app/components/developmentToolsComponent/apiKeyGenerator.meta.tsx Adds metadata for the API key generator tool

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +14 to +19
development_tools_list: [
{ tool: 'JavaScript Validator & Linter', url: PATHS.JAVASCRIPT_TESTER },
{ tool: 'HTML Escape', url: PATHS.HTML_ESCAPE },
{ tool: 'HTML Unescape', url: PATHS.HTML_UNESCAPE },
{ tool: 'Text to One Line', url: PATHS.TEXT_TO_ONE_LINE },
],
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'JavaScript Validator & Linter' is linked to PATHS.JAVASCRIPT_TESTER, which appears to be a different tool. Point this entry to the validator/linter route (e.g., the corresponding PATHS constant for that tool) so the related-tools navigation doesn’t misroute.

Copilot uses AI. Check for mistakes.
Comment on lines +54 to +67
point: [
{
title: 'Optimization',
description: 'Keep code readable and consistent across teams.',
},
{
title: 'Optimization',
description: 'Minify CSS for faster load times.',
},
{
title: 'Diff clarity',
description: 'Minified CSS leads to cleaner diffs.',
},
],
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first point is labeled 'Optimization' but its description ('Keep code readable...') reads like a prettify/formatting benefit, and 'Optimization' is duplicated. Consider renaming the first title (e.g., 'Consistency') or adjusting the description so each point is unique and matches the minify tool’s purpose.

Copilot uses AI. Check for mistakes.
@Suvam-paul145 Suvam-paul145 changed the title 44 Refactor: Auto-Discovery Plugin System for Tool Registration Mar 3, 2026
Suvam-paul145 and others added 3 commits March 3, 2026 06:41
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…eta.tsx

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@Suvam-paul145
Copy link
Author

@SyedFahad7 review my code

Suvam-paul145 and others added 5 commits March 3, 2026 06:42
…ta.tsx

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ifier.meta.tsx

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ifier.meta.tsx

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…s.meta.tsx

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@SyedFahad7
Copy link
Collaborator

Hey, thanks for the effort here.

This PR is way too large for us to reasonably review. It touches 192 files and introduces major architectural changes. It also includes merge commits, reverts, and unresolved conflicts.

We are not going to move forward with this in its current form.

If you would like to contribute, please open smaller, focused PRs with clear scope and prior discussion for any architectural changes.

Closing this for now.

@SyedFahad7 SyedFahad7 closed this Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace the Monolithic Constants File with an Auto-Discovery Plugin System for Tool Registration

3 participants