Skip to content

natyavidhan/mongo-explorer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MongoDB Explorer

A desktop MongoDB client built with Python and DearPyGui. Browse databases, view and edit documents, run queries, manage indexes, analyze schemas, and import/export data — all from a native GUI. Because Mongo Compass is eating up my resources at an alarming rate.

License: GPL-3.0


Features

Connection Management

  • Quick Connect — paste a MongoDB URI and connect instantly
  • Saved Connections — store, edit, and organize connections with color coding
  • TLS/SSL support — configure CA files, client certificates, and hostname validation
  • Connection testing — verify connectivity and latency before saving
  • Recent connections — quick access from the welcome screen
  • Multiple connections — switch between servers without losing state

Database Browser

  • Sidebar tree view listing all databases and their collections
  • Filter/search databases by name
  • Create and drop databases directly from the UI
  • Create and drop collections
  • Real-time collection count display per database

Document Viewer

  • Tabbed interface — open multiple collections simultaneously, each in its own tab
  • Table view — spreadsheet-style document grid with resizable, reorderable, and sortable columns
  • JSON view — formatted JSON display with syntax highlighting
  • Inline editing — edit documents through a JSON editor dialog
  • Add documents — insert new documents with JSON validation
  • Delete documents — select and bulk-delete with confirmation
  • Type-aware display — color-coded values by BSON type (ObjectId, Date, String, Number, Array, etc.)
  • Tooltips — hover over truncated values to see the full content and type

Filtering and Sorting

  • Filter documents using MongoDB query syntax ({ "field": "value" })
  • Sort by any field in ascending or descending order
  • Dynamic sort field detection based on document structure

Pagination

  • Configurable page sizes: 25, 50, 100, 250, 500 documents per page
  • First / Previous / Next / Last page navigation
  • Direct page number input
  • Total page count and document count display

Query Console

  • Write and execute find and aggregate queries
  • Database and collection selectors
  • Query history — automatically saved per connection with execution time and document counts
  • Saved queries — bookmark frequently used queries with names and descriptions
  • Execution time reporting
  • Results rendered in a scrollable table

Index Management

  • View all indexes on a collection with key patterns and properties
  • Visual badges for index types: UNIQUE, SPARSE, TTL, TEXT
  • Create new indexes (single-field, compound, unique, sparse, TTL)
  • Drop indexes with confirmation
  • Background index builds

Schema Analysis

  • Sample-based schema inference across collection documents
  • Configurable sample size (10 – 10,000 documents)
  • Per-field breakdown: types, occurrence percentage, sample values
  • Detects mixed-type fields

Server Statistics

  • Host, version, process info, uptime
  • Connection counters (current, available, total created)
  • Operation counters (insert, query, update, delete, getmore, command)
  • Memory usage (resident, virtual, mapped)
  • Network I/O (bytes in/out, request count)
  • Optional auto-refresh

Import / Export

  • Export formats: JSON (array), JSON Lines (NDJSON), CSV
  • Import formats: JSON, JSON Lines
  • Optional query filter for selective export
  • Document limit and pretty-print options
  • Progress tracking during operations

UI / UX

  • Dark and light themes with one-click toggle
  • MongoDB-branded color palette (green accent)
  • Toast notifications (success, error, warning, info)
  • Status bar with connection state, active database/collection, and document count
  • Full keyboard shortcut support
  • Responsive layout that adapts to viewport resizing
  • Loading indicators on all async operations

Keyboard Shortcuts

Shortcut Action
Ctrl+N New Connection
Ctrl+T New Query Tab
Ctrl+Enter Execute Query
F1 Keyboard Shortcuts
F5 Refresh
F11 Toggle Fullscreen
Alt+F4 Exit

Requirements

  • Python 3.10+
  • A running MongoDB instance (local or remote)

Installation

# Clone the repository
git clone https://github.com/natyavidhan/mongo-explorer.git
cd mongo-explorer

# Create a virtual environment
python -m venv env
source env/bin/activate   # Linux/macOS
# env\Scripts\activate    # Windows

# Install dependencies
pip install dearpygui pymongo

Usage

# Activate the virtual environment
source env/bin/activate

# Run the application
python main.py

On launch you will see the welcome screen. Either:

  1. Enter a MongoDB URI in the Quick Connect field on the sidebar and click Go.
  2. Click + New Connection to configure and save a connection with TLS and other options.

Once connected, databases and collections appear in the sidebar tree. Click any collection to open it in the document viewer.


Configuration

Application settings are stored in an SQLite database at:

~/.mongo-explorer/config.db

This includes saved connections (URIs are stored as-is — use filesystem permissions to protect sensitive credentials), query history, saved queries, pinned collections, and UI preferences.


Running Tests

source env/bin/activate
pytest tests/

The test suite covers the config store, JSON helpers, data models, MongoDB client wrapper, threading utilities, and UI components (158 tests).


Architecture Notes

  • Threading model — All MongoDB operations run in a background thread pool (TaskExecutor). Results are marshalled back to the UI thread via a callback queue that is drained every frame in the render loop. This keeps the GUI responsive during slow queries or network calls.
  • Async-safe rendering — DearPyGui's container stack is unavailable from background threads. The app uses explicit parent= parameters and push_container_stack / pop_container_stack when building UI from async callbacks.
  • State management — Per-tab state (documents, pagination, filters, sort order, selections) is stored in a dictionary keyed by database.collection. Tabs can be closed independently and their state is cleaned up automatically.
  • Config persistence — SQLite with a simple schema: connections, query history, saved queries, pinned collections, and a key-value preferences table.

License

This project is licensed under the GNU General Public License v3.0.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages