Skip to content

ninefyi/pyconth25

Repository files navigation

PyConTH25 - MongoDB Atlas Projects Manager

Boosting Operational Productivity with Python and Textual: Modern Terminal Dashboards for Developers

A modern terminal-based application built with Python 3.12+ and the Textual framework to view and manage MongoDB Atlas projects.

Features

  • 🎯 Modern TUI: Beautiful terminal user interface powered by Textual
  • 🔐 Secure Authentication: Uses MongoDB Atlas Administration API v2.0
  • 📊 Project Overview: View all your Atlas projects in a clean table format
  • 🔍 Cluster Details: Click on any project to view its clusters with detailed information
  • 🌍 Environment Support: Load credentials from environment variables
  • Async Performance: Fast, non-blocking HTTP requests with httpx
  • 🖱️ Interactive Navigation: Use mouse clicks or keyboard to navigate between views

Prerequisites

  • Python 3.8 or higher (recommended: Python 3.12+)
  • MongoDB Atlas account with API access
  • Atlas API Key (Public + Private Key pair)

Quick Start

  1. Fork and setup:

    cd pyconth25
  2. Configure your Atlas API credentials:

    # Edit the .env file with your credentials
    nano .env

    Add your Atlas API credentials:

    ATLAS_PUBLIC_KEY=your_atlas_public_key_here
    ATLAS_PRIVATE_KEY=your_atlas_private_key_here
    ATLAS_ORG_ID=your_organization_id_here
  3. Run the application:

    python atlas_projects_manager.py

Getting Atlas API Credentials

  1. Log in to MongoDB Atlas
  2. Go to Access ManagerAPI Keys
  3. Click Create API Key
  4. Add a description and select appropriate permissions:
    • Organization Member (minimum)
    • Project Read Only or higher for project access
  5. Copy the Public Key and Private Key
  6. Add your current IP to the API Access List

Application Features

Main Interface

  • Projects View: Main screen showing all Atlas projects
    • Project Name
    • Project ID
    • Creation Date
  • Cluster View: Detailed view of clusters in a selected project
    • Cluster Name
    • Status (Active, Paused, etc.)
    • Cloud Provider (AWS, Azure, GCP)
    • Region
    • Instance Size
    • MongoDB Version
  • Status Display: Real-time feedback on operations

Navigation

  • Mouse: Click on any project row to view its clusters
  • Keyboard: Use arrow keys to select, then press Enter
  • Back Navigation: Press Escape or 'b' to return to projects view

Keyboard Shortcuts

  • a: Authenticate and load projects
  • v: View clusters for selected project
  • Escape Back to projects view (from cluster view)
  • d: Delete selected project
  • q: Quit the application

Architecture

The application is built with:

  • Textual Framework: Modern TUI framework for Python
  • httpx: Modern async HTTP client
  • MongoDB Atlas API v2.0: Official REST API for Atlas management
  • Python 3.12+: Latest Python features and performance

File Structure

pyconth25/
├── atlas_projects_manager.py    # Main application
├── requirements.txt             # Python dependencies
├── .env.example               # Environment template
├── .env                       # Your credentials (create this)
└── README.md                  # This file

API Integration

This application uses the MongoDB Atlas Administration API v2.0:

  • Base URL: https://cloud.mongodb.com/api/atlas/v2
  • Authentication: HTTP Digest Authentication
  • Endpoint: /groups (lists all projects)
  • API Version: application/vnd.atlas.2023-01-01+json

Development

Requirements

All dependencies are listed in requirements.txt:

  • httpx: Async HTTP client
  • textual[dev]: TUI framework with development tools
  • rich: Terminal formatting
  • python-dotenv: Environment variable management

Running in Development

# Install development dependencies
pip install -r requirements.txt

# Run with development features
python atlas_projects_manager.py

Troubleshooting

Common Issues

  1. Import errors: Make sure all dependencies are installed

    pip install -r requirements.txt
  2. Authentication errors: Verify your API credentials

    • Check Public Key and Private Key are correct
    • Ensure your IP is in the API Access List
    • Verify API key has necessary permissions
  3. Connection errors: Check your internet connection and Atlas status

Error Messages

  • API request failed: Check credentials and network connection
  • Invalid JSON response: Atlas API may be unavailable
  • Please enter both keys: Both Public and Private keys are required

Contributing

This is a PyCon Thailand 2025 demonstration project showcasing modern Python development with Textual framework.

License

MIT License - feel free to use and modify for your projects.

MongoDB Atlas Resources

Legacy Instructions

  1. copy .env.template to .env
  2. run python atlas_projects_manager.py

About

th.pycon.org (Python Conference 2025 in Thailand)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages