npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

integraph

v1.0.2

Published

Create Architecture diagrams from your code.

Downloads

191

Readme

Integraph codecov

Create Architecture diagrams from your code.

Architecture

Architecture

Install

npm install -g integraph

Usage

Map integrations adding @integraph comments in your source code:

class ECommerce {
    /**
     * @integraph
     * service: e-commerce
     * integrations:
     *   - service: Payment gateway
     *     edgeDirection: RL
     *     group: External APIs
     */
    processsPayment() {
        // ...
    }
}

Under your project root directory/repository, run the following command:

integraph

The generated diagram:

Example 01

It will search for files containing @integraph comments and mapping all integrations, and as results it generates the following files under the directory .integraph:

  • diagram.js

    architecture-beta
        group externalapis[External APIs]
    
        service ecommerce(server)[e_commerce]
        service paymentgateway(server)[Payment gateway] in externalapis
    
        ecommerce:R -[ecommerce__paymentgateway]- L:paymentgateway
  • integrations.js

    • it contains the funciton getIntegrations which returns a json with all mappend integrations.
    [
        {
            "startPosition":{
                "row":1,
                "column":4
            },
            "endPosition":{
                "row":8,
                "column":7
            },
            "yaml":{
                "service":"e-commerce",
                "integrations":[
                    {
                        "service":"Payment gateway",
                        "edgeDirection":"RL",
                        "group":"External APIs"
                    }
                ]
            },
            "path":"diagrams/__tests__/fixtures/example_01.ts",
            "repo":"https://github.com/danilosampaio/integraph/blob/main",
            "sourceCode":"class ECommerce { ..."
        }
    ]
  • arch.html

    • a html page containing the diagram and a few actions such as refresh, show diagram source, and show integrations json. Addtionally, it makes all edges clickable, adding the ability to open the souce file where the integration is defined.

    Example 01

  • main.css

    • this is the css styles for the page arch.html
  • main.js

    • this is the main js file which initialize mermaid library, render the diagram, etc.

Service and Integration Attributes

/**
 * @integraph
 * service: <string> Service name. e.g Market Place, Payment API
 * icon: <string> Icon name. e.g. server, database, logos:google-cloud, vscode-icons:file-type-mermaid
 * group: <string> Group name. e.g. External APIs, Auth Services
 * integrations: <object[]> list of integrations
 *   - service: <string> Service name. e.g Market Place, Payment API
 *     edgeDirection: <string> direction of the edge. e.g. RL, LR, TB, BT (see https://mermaid.js.org/syntax/architecture.html#edge-direction)
 *     group: <string> Group name. e.g. External APIs, Auth Services
 *     groupEdge: true (see https://mermaid.js.org/syntax/architecture.html#edges-out-of-groups)
 *     arrowedEdge: true (see https://mermaid.js.org/syntax/architecture.html#edges)
 */

Supported languages

Typescript/javascript

class ECommerce {
    /**
     * @integraph
     * service: e-commerce
     * integrations:
     *   - service: Payment gateway
     *     edgeDirection: RL
     */
    processsPayment() {
        // ...
    }
}

Java

public class PaymentGateway {
    /**
     * @integraph
     * service: Payment gateway
     * group: External APIs
     * integrations:
     *   - service: Bank API
     *     edgeDirection: RL
     *   - service: Fraud Detection
     */
    public boolean postTransaction() {
        // ...
    }
}

Python

"""
@integraph
service: Fraud Detection
group: AI Agents
integrations:
  - service: Load AI Models
    group: AI Agents
"""
def detectFraud():
    print("all good!")

Rust

// @integraph
// service: Load AI Models
// group: AI Agents
// integrations:
//   - service: chatgpt
//
fn loadModels() {
    // ...
}

Mermaid Architecture Diagram

https://mermaid.js.org/syntax/architecture.html

Take a look at the available icons

https://icon-sets.iconify.design/logos/

Registered icons:

https://unpkg.com/@iconify-json/logos@1/icons.json

https://unpkg.com/@iconify-json/[email protected]/icons.json

https://unpkg.com/@iconify-json/[email protected]/icons.json