Skip to content

About

This is MongoDB document visulizer that visulize the models and relationships between models and data flow

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

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

About

This is MongoDB document visulizer that visulize the models and relationships between models and data flow

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages