Skip to content

Latest commit

 

History

History
373 lines (286 loc) · 10.5 KB

File metadata and controls

373 lines (286 loc) · 10.5 KB

Local Nexus Controller - Recommendations & Enhancements

Overview

This document provides comprehensive recommendations for optimizing and enhancing your Local Nexus Controller setup.

What's Been Implemented

1. Auto-Discovery System

  • Automatic Repository Scanning: The controller now scans C:\Users\nedpe\Desktop\Repositories on startup
  • Program Type Detection: Automatically identifies Node.js, Python, Go, Rust, Java, and .NET projects
  • Smart Port Assignment: Assigns ports based on program type and avoids conflicts
  • Bundle Generation: Creates import bundles for discovered programs

2. File Watcher for ZIP Files

  • Desktop Monitoring: Watches C:\Users\nedpe\Desktop for new ZIP files
  • Automatic Extraction: Extracts ZIPs to the Repositories folder
  • Auto-Import: Automatically registers extracted programs
  • Background Processing: Runs in a background thread without blocking

3. Enhanced Dashboard with Launch Links

  • Prominent Launch Buttons: Blue "Launch Application" buttons in service details
  • Quick Launch: Launch buttons in the services table
  • Direct Links: Clickable URLs that open programs in new tabs
  • Visual Indicators: Running status with color-coded badges

4. Auto-Start on Windows Boot

  • Scheduled Task: Runs the controller automatically when you log in
  • Service Auto-Start: Launches all registered services on controller startup
  • Hidden Background Execution: Runs without popping up windows
  • Easy Management: Simple enable/disable scripts

Configuration

Environment Variables (.env)

# Auto-discovery settings
LOCAL_NEXUS_REPOSITORIES_FOLDER=C:\Users\nedpe\Desktop\Repositories
LOCAL_NEXUS_AUTO_DISCOVERY_ENABLED=true

# File watcher settings
LOCAL_NEXUS_FILE_WATCHER_ENABLED=true
LOCAL_NEXUS_FILE_WATCHER_FOLDER=C:\Users\nedpe\Desktop

# Auto-start all services on boot
LOCAL_NEXUS_AUTO_START_ALL_ON_BOOT=true

How to Use

Initial Setup

  1. Install Dependencies:

    pip install -r requirements.txt
  2. Configure Settings:

    • Edit .env to set your repository folder path
    • Enable auto-discovery and file watcher features
    • Set auto-start preferences
  3. Setup Windows Auto-Start (Optional):

    .\tools\setup_windows_startup.ps1

Adding New Programs

Method 1: Automatic Discovery

  • Place program folders in C:\Users\nedpe\Desktop\Repositories
  • Restart the controller or wait for next scan
  • Programs will be automatically registered

Method 2: ZIP File Import

  • Drop a ZIP file containing your program onto your Desktop
  • The file watcher will automatically extract and register it
  • The ZIP file will remain on your Desktop (can be deleted manually)

Method 3: Manual Import

  • Go to the Import page in the dashboard
  • Paste an import bundle JSON
  • Click "Import"

Launching Programs

From the Dashboard:

  1. Go to Services page
  2. Click the blue "Launch" button next to any service
  3. The program opens in your default browser

From Service Details:

  1. Click on a service name
  2. Click the "🚀 Launch Application" button at the top
  3. Use Start/Stop/Restart buttons to control the service

Managing Auto-Start

Enable Auto-Start:

.\tools\setup_windows_startup.ps1

Disable Auto-Start:

.\tools\disable_windows_startup.ps1

Manual Start (without auto-start):

.\run.ps1

Recommendations

Architecture & Organization

  1. Keep Programs Isolated

    • Each program in its own folder within Repositories
    • Each folder as its own Git repository
    • Independent dependency management per program
  2. Use Standard Project Structure

    • Include package.json for Node.js projects
    • Include requirements.txt for Python projects
    • Use conventional entry points (main.py, app.py, index.js)
  3. Document Your Programs

    • Create a local-nexus.bundle.json in each project
    • Include description, dependencies, and configuration notes
    • Version control these bundle files

Port Management

  1. Port Ranges

    • Web apps: 3000-3099
    • APIs: 3100-3199
    • Databases: 3200-3299
    • Tools/Utilities: 3300-3399
  2. Avoid Port Conflicts

    • Use the Ports Explorer to view all allocated ports
    • Let the controller assign ports automatically
    • Update .env files with assigned ports
  3. Healthcheck Endpoints

    • Add /health endpoint to all services
    • Return 200 OK when service is ready
    • Include version and status information

Database Management

  1. Use SQLite for Local Development

    • Fast setup, no server required
    • Perfect for single-user applications
    • Easy to backup (just copy the file)
  2. Separate Databases per Service

    • Avoid coupling between services
    • Easier to debug and maintain
    • Can move services independently
  3. Register Databases

    • Add all databases to the controller
    • Link services to their databases
    • Document schema in the controller

Security Best Practices

  1. Never Commit Secrets

    • Use environment variables for API keys
    • Reference them in the controller (don't store values)
    • Keep .env files out of Git
  2. Use API Token Protection

    • Set LOCAL_NEXUS_TOKEN in production
    • Require token for write operations
    • Protect against unauthorized changes
  3. Local Network Only

    • Bind to 127.0.0.1 for local-only access
    • Use 0.0.0.0 only if accessing from other devices
    • Consider firewall rules for remote access

Performance Optimization

  1. Limit Auto-Discovery Scope

    • Only scan the Repositories folder
    • Exclude node_modules, .git, and other large folders
    • Run discovery on startup only (not continuously)
  2. Log Management

    • Rotate logs regularly
    • Set max log size per service
    • Archive or delete old logs
  3. Process Management

    • Use restart commands instead of kill+start
    • Implement graceful shutdown in services
    • Monitor memory usage for long-running services

Workflow Improvements

  1. Use Categories

    • Categorize services: "web", "api", "tool", "database"
    • Filter services by category in the dashboard
    • Group related services together
  2. Tag Services

    • Use tags for technology: "react", "fastapi", "express"
    • Tag by purpose: "client-work", "personal", "learning"
    • Search by tags in the future
  3. Document Dependencies

    • List service dependencies in the controller
    • Track which services depend on each other
    • Plan startup order for dependent services

Backup Strategy

  1. Controller Database

    • Backup data/local_nexus.db regularly
    • Include in your backup routine
    • Store backups in cloud storage
  2. Service Data

    • Each service should backup its own data
    • Use separate backup schedule per service
    • Test restore procedures
  3. Configuration Files

    • Version control all .env.example files
    • Document configuration changes
    • Keep settings synchronized

API Endpoints for Automation

Auto-Discovery

Scan Repository Folder:

POST /api/autodiscovery/scan
{
  "folder_path": "C:\\Users\\nedpe\\Desktop\\Repositories",
  "auto_import": true
}

Extract ZIP and Import:

POST /api/autodiscovery/extract-zip
{
  "zip_path": "C:\\Users\\nedpe\\Desktop\\myapp.zip",
  "extract_to": "C:\\Users\\nedpe\\Desktop\\Repositories",
  "auto_import": true
}

Service Control

Start Service:

POST /api/services/{service_id}/start

Stop Service:

POST /api/services/{service_id}/stop

Restart Service:

POST /api/services/{service_id}/restart

Get Service Status:

GET /api/services/{service_id}

Troubleshooting

Controller Won't Start

  • Check Python version (3.10+)
  • Verify all dependencies installed
  • Check port 5010 is not in use
  • Review logs in terminal

Service Won't Start

  • Check start_command is correct
  • Verify working_directory exists
  • Check port is available
  • Review service logs in dashboard

Auto-Discovery Not Working

  • Verify LOCAL_NEXUS_REPOSITORIES_FOLDER path is correct
  • Check folder contains valid projects
  • Enable auto-discovery in .env
  • Restart the controller

File Watcher Not Processing ZIPs

  • Verify LOCAL_NEXUS_FILE_WATCHER_FOLDER path exists
  • Check file watcher is enabled
  • Ensure ZIP files are valid
  • Check controller logs for errors

Auto-Start Not Working

  • Verify scheduled task exists: Get-ScheduledTask LocalNexusController_AutoStart
  • Check task is enabled in Task Scheduler
  • Review task history for errors
  • Ensure script paths are correct

Future Enhancements

Recommended Next Steps

  1. Service Health Monitoring

    • Automated health checks every minute
    • Email/SMS alerts for service failures
    • Automatic restart on failure
  2. Resource Monitoring

    • Track CPU and memory usage per service
    • Disk space monitoring
    • Network bandwidth tracking
  3. Deployment Automation

    • One-click deploy from Git
    • Automatic dependency installation
    • Rolling updates with zero downtime
  4. Service Grouping

    • Start/stop groups of related services
    • Dependency-aware startup order
    • Environment-based groups (dev, test, prod)
  5. Remote Access

    • Secure tunnel for remote access
    • Mobile app for service management
    • Multi-machine controller network
  6. Analytics Dashboard

    • Service uptime tracking
    • Request/response metrics
    • Error rate monitoring

Best Practices Summary

  • Keep it simple: Don't over-engineer; start small and grow
  • Document everything: Future you will thank present you
  • Automate repetitive tasks: Let the controller do the work
  • Monitor actively: Check the dashboard regularly
  • Backup frequently: Don't lose your configuration
  • Update regularly: Keep dependencies up to date
  • Test in isolation: Test services independently
  • Use version control: Git everything
  • Follow conventions: Consistency makes maintenance easier
  • Ask for help: Community and documentation are your friends

Support

For issues, questions, or suggestions:

  • Check the documentation: README.md
  • Review the API docs: http://localhost:5010/docs
  • Check existing issues on GitHub
  • Create a new issue with details

Conclusion

The Local Nexus Controller is now set up for automatic program discovery, ZIP file monitoring, easy launching, and auto-start on Windows boot. Use the recommendations above to optimize your workflow and keep your local development environment organized and efficient.

Happy coding!