dependency-graph-construction
v1.0.2
Published
A powerful tool to construct dependency graphs for JavaScript and TypeScript projects. Useful for project structure analysis and debugging.
Maintainers
Readme
Frontend - File Dependency Graph (FDG)
This project is a React-based FDG constructor designed to create, render, and interact with hierarchical file dependency graphs. The tool constructs dependencies between modules, folders, and files in a structured graph format. Developers can use this tool to understand and analyze project structures.
Features
- Dynamic Graph Generation: Automatically generates a dependency graph based on the provided project structure.
- Interactive Visualization: Enables interaction with graph nodes and edges.
- Zoom and Navigation: Includes zoom-in, zoom-out, and reset functionality for easy navigation
- Customizable Events: Supports event handlers for user interactions such as node/edge clicks.
- Hierarchical Structure: Visualizes folders and files with distinct styles and properties for better clarity.
File Structure
Below is an overview of the main files and their responsibilities:
Components
- NavBar: Handles user interactions and controls graph visualization.
- GraphMenu: Provides options for managing hidden nodes and graph-related settings.
- ZoomSwitcher: Enables zoom-in, zoom-out, and reset functionality.
Hooks
- useZoom: Manages zoom level states and their corresponding handlers.
- useLevelGraphVisualization: Visualizes graph levels dynamically.
Visualizer
- event.js: Initializes and manages event handlers for nodes, edges, and clusters.
- generateDotSchema.js: Converts node data into DOT schema for graph rendering.
- setupGraph.js: Configures graph properties and creates the initial graph structure.
Utils
- graphProperties.js: Defines properties like shapes, colors, and styles for nodes and edges.
- buildGraph.js: Builds level-wise dependency graphs using data from dependencyGraph.json.
- dependencyGraph.json: Contains structured data defining nodes and their dependencies.
Installation and Setup
Follow the steps below to set up and run the project:
- Clone the repository:
git clone https://github.com/DixitLukhi/frontend-fdg.git- Navigate to the project directory:
cd frontend-fdg- Install dependencies:
npm install- Run the application:
npm start- Access the application: Open http://localhost:3000 in your browser to view the FDG.
Steps to Use the FDG Constructor
- Prepare Project Data:
- Structure your project according to the dependency requirements.
- Update the dependencyGraph.json file with your project nodes and dependencies.
- Customize Graph Settings:
- Modify the bundler.config.json file to include root modules or update the Babel configuration.
- Run the Application:
- Start the application to automatically generate and render the dependency graph.
- Interact with the Graph:
- Click on nodes or edges to see their relationships.
- Use the GraphMenu to hide/unhide specific nodes.
- Adjust zoom levels using the ZoomSwitcher
How It Works
- Graph Setup:
- setupGraph.js initializes graph properties such as layout, colors, and styles.
- generateDotSchema.js translates node data into a DOT schema for rendering.
- Rendering:
- App.js manages rendering the graph using Viz.js.
- SVG elements are appended dynamically to the DOM.
- Event Handling:
- event.js initializes click, hover, and keyboard events for user interaction.
- Utility functions in utils/handlers.js process these events.
- Dynamic Visualization:
- Graph levels and dependencies are visualized dynamically using useLevelGraphVisualization.
