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 🙏

© 2026 – Pkg Stats / Ryan Hefner

mongodb-models-visualizer

v0.1.17

Published

MongoDB Database Visualizer and models relationships between collections

Downloads

1,396

Readme

npm npm downloads license node typescript GitHub stars

mongodb-models-visualizer

🚀 Swagger-like Analyzer for MongoDB (Mongoose) Models

Automatically analyze, visualize, and document your MongoDB models in a Node.js + Express application.


✨ What is mongodb-models-visualizer?

mongodb-models-visualizer is a developer tool that introspects your Mongoose models and provides:

  • List of all registered models
  • Schema fields with types & validations
  • Model relationships (ref)
  • Collection names
  • Optional sample documents
  • Swagger-like web UI
  • JSON APIs for documentation & automation

Think of it as Swagger, but for MongoDB schemas.


🔧 Supported Stack

  • Node.js ≥ 16
  • Express ≥ 4
  • Mongoose ≥ 6

📦 Installation

npm install mongodb-models-visualizer

or

yarn add mongodb-models-visualizer

🚀 Quick Start

1️⃣ Setup Express & Mongoose

import express from 'express'
import mongoose from 'mongoose'
import { modelAnalyzer } from 'mongodb-models-visualizer'

const app = express()

mongoose.connect(process.env.MONGO_URI)

2️⃣ Mount the Analyzer Middleware

app.use(
  '/models-analyzer',
  modelAnalyzer({
    mongoose
  })
)

3️⃣ Start the Server

app.listen(3000, () => {
  console.log('Server running on http://localhost:3000')
})

4️⃣ Open in Browser 🎉

Navigate to http://localhost:3000/models-analyzer


📸 Screenshots

Models Overview

Models List

Model Details & Schema

Model Schema

Field Analysis

Field Details


📊 API Endpoints

🔹 Get all models

GET /models-analyzer/api/models

Example Response:

[
  {
    "name": "User",
    "collection": "users",
    "fields": [
      {
        "name": "email",
        "instance": "String",
        "required": true,
        "enum": [],
        "ref": null
      }
    ]
  }
]

🔹 Get a single model

GET /models-analyzer/api/models/:modelName

⚙️ Configuration Options

modelAnalyzer({
  mongoose,          // required
  sampleDocs: true,  // optional (default: false)
  auth: false        // optional (default: false)
})

| Option | Type | Description | |--------|------|-------------| | mongoose | Object | Mongoose instance | | sampleDocs | Boolean | Include sample documents | | auth | Boolean | Enable auth middleware |

🔐 Security (Recommended for Production)

Do NOT expose this endpoint publicly without authentication.

Example using basic auth:

import basicAuth from 'express-basic-auth'

app.use(
  '/models-analyzer',
  basicAuth({
    users: { admin: 'password' },
    challenge: true
  }),
  modelAnalyzer({ mongoose })
)

🧠 How It Works

  1. Scans all registered Mongoose models
  2. Extracts schema metadata
  3. Parses fields, types, refs, and indexes
  4. Builds structured JSON output
  5. Serves data via API & UI

🗺️ Roadmap

✅ v0.1 (Current)

  • Model scanner
  • Schema parser
  • JSON APIs

🚀 v0.2

  • Swagger-like UI
  • Relationship graph
  • Index analyzer

🧠 v1.0

  • Performance suggestions
  • Migration hints
  • CLI support
  • Fastify & NestJS adapters

🤝 Contributing

Contributions are welcome!

git clone https://github.com/Hibbanur-Rahman/mongodb-visualizer.git
cd mongodb-visualizer
npm install
npm run build

Feel free to open issues or pull requests 🚀

📄 License

MIT License © 2026

❤️ Why This Tool?

  • MongoDB has no built-in schema visualization
  • Helps onboarding new developers
  • Great for documentation & debugging
  • Inspired by Swagger & Prisma Studio