Skip to main content

A framework-agnostic MongoDB admin library with intelligent relationship detection and dual views

Project description

Monglo - Framework-Agnostic MongoDB Admin Library

The MongoDB admin interface that's actually magical to use.

Python License


✨ Why Monglo?

Other MongoDB admin tools:

  • Require tons of boilerplate code
  • Manual template setup, routing, serialization
  • Framework-locked or ORM-dependent
  • Complex configuration

Monglo:

  • 10 lines of code - that's it!
  • Library handles EVERYTHING automatically
  • Works with FastAPI, Flask, Django
  • Auto-detects collections, schemas, relationships
  • Production-ready UI included

🚀 Quick Start (< 5 minutes)

Installation

pip install monglo motor fastapi  # or flask, or django

Setup (Literally 10 lines!)

from fastapi import FastAPI
from motor.motor_asyncio import AsyncIOMotorClient
from monglo import MongloEngine
from monglo.ui_helpers.fastapi import create_ui_router

# 1. Connect to MongoDB
client = AsyncIOMotorClient("mongodb://localhost:27017")

# 2. Create FastAPI app
app = FastAPI()

# 3. Initialize Monglo
engine = MongloEngine(database=client.mydb, auto_discover=True)

@app.on_event("startup")
async def startup():
    await engine.initialize()
    app.include_router(create_ui_router(engine))

# That's it! 🎉

Run it:

uvicorn app:app --reload

Visit: http://localhost:8000/admin

You now have a full-featured admin interface with:

  • ✅ Collection browsing
  • ✅ Document viewing/editing
  • ✅ Search and filtering
  • ✅ Relationship navigation
  • ✅ Auto-detected schemas
  • ✅ Professional UI

🎯 Features

🔮 Magical Auto-Detection

# Just initialize - Monglo does the rest
engine = MongloEngine(database=db, auto_discover=True)
await engine.initialize()

# Automatically discovers:
# - All collections
# - Field types and schemas
# - Relationships (user_id → users collection)
# - Indexes

🔗 Intelligent Relationships

# Your MongoDB document:
{
    "user_id": ObjectId("..."),      # → Automatically links to users collection
    "tags": [ObjectId("...")],       # → Automatically links to tags collection  
    "category": "electronics"
}

# Monglo automatically:
# - Detects these relationships
# - Creates clickable navigation
# - Resolves related documents
# - Shows relationship graphs

📊 Dual Views

Table View - Browse and filter thousands of documents

  • Sortable columns
  • Advanced filtering
  • Global search
  • Bulk operations
  • Export (CSV, JSON)

Document View - Inspect and edit individual documents

  • Full JSON tree structure
  • Relationship navigation
  • Field validation
  • Nested document support

🎨 Production-Ready UI

  • Modern, responsive design
  • Dark/light modes
  • Customizable branding
  • Mobile-friendly
  • Professional aesthetics

📚 Framework Support

FastAPI (Recommended)

from monglo.ui_helpers.fastapi import create_ui_router

app.include_router(create_ui_router(engine))

Flask

from monglo.ui_helpers.flask import create_ui_blueprint

app.register_blueprint(create_ui_blueprint(engine))

Django

# In urls.py
from monglo.ui_helpers.django import create_ui_urlpatterns

urlpatterns = [
    *create_ui_urlpatterns(engine, prefix="admin"),
]

🛠️ Customization (Optional!)

Everything works out of the box, but you can customize:

Branding

create_ui_router(
    engine,
    title="My Admin Panel",
    logo="https://example.com/logo.png",
    brand_color="#ff6b6b"
)

Collection Configuration

from monglo import CollectionConfig, TableViewConfig

await engine.register_collection(
    "products",
    config=CollectionConfig(
        list_fields=["name", "price", "stock"],
        search_fields=["name", "description"],
        table_view=TableViewConfig(
            per_page=50,
            default_sort=[("created_at", -1)]
        )
    )
)

Authentication

from monglo.auth import SimpleAuthProvider

engine = MongloEngine(
    database=db,
    auth_provider=SimpleAuthProvider(users={
        "admin": {
            "password_hash": SimpleAuthProvider.hash_password("admin123"),
            "role": "admin"
        }
    })
)

📖 Documentation


🎓 Examples

Check out examples/ for complete working examples with FastAPI (Flask and Django support coming in future versions):


💻 Development

Setup

# Clone the repo
git clone https://github.com/me-umar/monglo.git
cd monglo

# Create virtual environment
python3 -m venv .venv
source .venv/bin/activate

# Install development dependencies
pip install -e ".[dev]"

Run Tests

pytest tests/ --cov=monglo --cov-report=html

Run Linters

ruff check monglo/
black monglo/ tests/
mypy monglo/ --strict

Run Examples

cd examples/fastapi_example/basic_example
python app.py

🤝 Contributing

Contributions are welcome! See CONTRIBUTING.md for guidelines.


📝 License

MIT © 2025


⭐ Star History

If Monglo saves you time, give it a star! ⭐


🙏 Acknowledgments

Built with:


Before Monglo: 380 lines of boilerplate (templates, routing, serialization, filters...)

After Monglo: 10 lines. Everything just works. ✨

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

monglo-0.1.1.tar.gz (111.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

monglo-0.1.1-py3-none-any.whl (100.9 kB view details)

Uploaded Python 3

File details

Details for the file monglo-0.1.1.tar.gz.

File metadata

  • Download URL: monglo-0.1.1.tar.gz
  • Upload date:
  • Size: 111.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for monglo-0.1.1.tar.gz
Algorithm Hash digest
SHA256 70c2cd9a836f918bc3381829df1dfe38b8f16c64f2bf64c2aac2fb43d1dca22c
MD5 f2d2cb84ed80730a3688750e0872a87e
BLAKE2b-256 c51c73c4d424ca31b1eaabab39dd2be1fcc0e4d41d15c998d34ebb19dc12a380

See more details on using hashes here.

File details

Details for the file monglo-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: monglo-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 100.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for monglo-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ef1467dedc35466a5f0171d6f6390c82ad80c8c926423fa8a3c3839cd6806254
MD5 f38d7c55f1f26d8bcdeb92996345f229
BLAKE2b-256 b4a83ab8051522b145e06adae6b68ed6e83a151743ae3093aa72fcde7c2e5840

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page