Skip to content

alphacrcavae-hub/omnitool-python-dashboard

Repository files navigation

Omnitool Admin Dashboard (Python)

A complete Python-based web dashboard for monitoring Omnitool usage analytics. Built with Streamlit for rapid development and FastAPI for backend services.

Features

  • Real-time Analytics: Usage statistics, user activity, and system health monitoring
  • Interactive Visualizations: Charts and graphs powered by Plotly
  • User Management: Track individual user engagement and session data
  • Department Analytics: Filter and analyze usage by department
  • System Health: Monitor database connections and service status
  • Export Capabilities: Download reports and data exports

Architecture

┌─────────────────────────────────────────────────────────────┐
│                    Omnitool Clients                         │
│              (Local installations on PCs)                   │
└──────────────────────┬──────────────────────────────────────┘
                       │
                       │ Authenticate via AD
                       │ Send usage events
                       │
┌──────────────────────▼──────────────────────────────────────┐
│              Microsoft Active Directory                     │
│         (Authentication & Authorization)                    │
└──────────────────────┬──────────────────────────────────────┘
                       │
                       │ User identity & groups
                       │
┌──────────────────────▼──────────────────────────────────────┐
│              PostgreSQL Database                            │
│  - users, sessions, usage_events, auth_logs                │
└──────────────────────┬──────────────────────────────────────┘
                       │
                       │ Query data
                       │
┌──────────────────────▼──────────────────────────────────────┐
│              FastAPI Backend (Optional)                     │
│         REST API endpoints for dashboard                    │
└──────────────────────┬──────────────────────────────────────┘
                       │
                       │ Serve data
                       │
┌──────────────────────▼──────────────────────────────────────┐
│              Streamlit Dashboard                             │
│         Interactive web interface                           │
└─────────────────────────────────────────────────────────────┘

Quick Start

Prerequisites

  • Python 3.9 or higher
  • pip (Python package manager)

Installation

  1. Navigate to the dashboard directory:

    cd C:\Users\jperez\omnitool-python-dashboard
  2. Create a virtual environment (recommended):

    python -m venv venv
    .\venv\Scripts\Activate.ps1
  3. Install dependencies:

    pip install -r requirements.txt
  4. Run the dashboard:

    streamlit run app.py
  5. Open your browser to the URL shown (typically http://localhost:8501)

Project Structure

omnitool-python-dashboard/
├── app.py                 # Main Streamlit dashboard application
├── config.py             # Configuration settings
├── data/
│   ├── models.py         # Data models and schemas
│   └── generator.py      # Mock data generator
├── api/
│   └── backend.py        # FastAPI backend (optional)
├── utils/
│   └── database.py       # PostgreSQL connection utilities
├── requirements.txt      # Python dependencies
├── README.md            # This file
└── schema.sql           # Database schema reference

Configuration

Edit config.py to configure:

  • Database connection settings (when connecting to PostgreSQL)
  • Active Directory settings (for authentication)
  • API endpoints
  • Dashboard preferences

Usage

Dashboard Views

  1. Overview: Key metrics and recent activity
  2. Usage Statistics: Detailed analytics and trends
  3. User Activity: Individual user engagement
  4. System Health: Infrastructure status

Mock Data Mode

By default, the dashboard runs with realistic mock data. This allows you to:

  • Demo the interface to stakeholders
  • Test visualizations and features
  • Develop without database access

Production Mode

To connect to a real PostgreSQL database:

  1. Update config.py with your database credentials
  2. Ensure the database schema matches schema.sql
  3. The dashboard will automatically switch to live data

API Backend (Optional)

The FastAPI backend provides REST endpoints for programmatic access:

uvicorn api.backend:app --reload --port 8000

Available endpoints:

  • GET /health - Health check
  • GET /api/stats/overview - Overview statistics
  • GET /api/stats/usage - Usage analytics
  • GET /api/users/activity - User activity data
  • GET /api/system/health - System health status

Database Schema

See schema.sql for the complete database schema. Key tables:

  • users - User information synced from Active Directory
  • sessions - User session records
  • usage_events - Feature usage and interaction events
  • authentication_logs - Login/logout events

Active Directory Integration

The dashboard is designed to work with Microsoft Active Directory:

  1. Authentication: Users authenticate via AD credentials
  2. Authorization: Admin access controlled by AD group membership
  3. User Identity: Uses userPrincipalName (UPN) or objectGUID as stable identifiers

Development

Adding New Features

  1. Add data models in data/models.py
  2. Update mock data generator in data/generator.py
  3. Add new dashboard pages in app.py
  4. Update API endpoints in api/backend.py if needed

Testing

The dashboard includes mock data generation for testing. To test with different scenarios, modify the seed or parameters in data/generator.py.

Deployment

Production Deployment

  1. Set up PostgreSQL database
  2. Configure environment variables or config.py
  3. Set up reverse proxy (Nginx) for HTTPS
  4. Configure Active Directory authentication
  5. Deploy using:
    streamlit run app.py --server.port 8501

Docker Deployment (Optional)

FROM python:3.11-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"]

Troubleshooting

Port Already in Use

If port 8501 is busy, Streamlit will automatically use the next available port. Check the terminal output for the actual URL.

Database Connection Issues

  • Verify PostgreSQL is running
  • Check connection credentials in config.py
  • Ensure network access to database server
  • Verify database schema matches schema.sql

Import Errors

If you see import errors:

pip install -r requirements.txt --upgrade

License

Corporate internal tool. All rights reserved.

Support

For questions or issues, refer to:

  • config.py - Configuration options
  • schema.sql - Database structure
  • This README - General documentation

About

omnitool-python-dashboard

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors