How infinigate-techservices/demo-hub-fastapi works
Main Components
• API / Backend: Highlight the FastAPI application (main.py) as the core of the system that runs the REST API and serves the web interface.
• Web Interface: Include the PyWebIO-based modules (e.g., pywebio_app.py, pywebio_dns.py, pywebio_guacamole.py, etc.) which create the user interface for different management tasks.
• External Integration Modules:
• Proxmox VE (pve.py & pywebio_pve.py) for VM lifecycle management.
• Guacamole (guacamole.py & pywebio_guacamole.py) for remote access.
• NGINX Proxy Manager (nginx_proxy_manager.py & pywebio_nginx.py) for reverse proxy configurations.
• Authentik (authentik.py) for identity management.
• FortiGate (fortigate.py) for DHCP/reservation and firewall management.
• Cloudflare (cf.py) for DNS management.
• LLDAP (lldap.py & pywebio_lldap.py) for LDAP user management.
• Models: The models.py file that defines the data models used across the system.
• Background Task Schedulers: Although not a separate file, the README details background tasks (e.g., VM scheduling, start/stop checks) that should be represented as part of asynchronous processes or scheduled jobs within the API.
Relationships and Interactions
• The FastAPI backend serves as the central hub. It exposes APIs (with Swagger and ReDoc UI) and triggers background tasks that manage the lifecycle of the training lab VMs.
• The web interface (via PyWebIO components) is the user-facing layer that interacts with the backend to trigger actions like “create training seats” or setting up configurations.
• Data flowing from the backend to these modules.
• Requests that handle VM creation, user provisioning, network configurations, etc.
• Background tasks (schedulers) periodically trigger calls to these integration modules for VM updates and cleanup.
Architectural Patterns and Design Principles
• Separation of Concerns: Clearly illustrate different layers (API/backend, UI layer, and external integrations) to emphasize modularity.
• Service Integration Pattern: Show how each external system is abstracted into its own module, allowing independent evolution and testing.
Relevant Technologies and Frameworks
• FastAPI: As the API framework powering the REST endpoints.
• PyWebIO: For constructing the interactive web interfaces.
• Python Environment: The system’s core is built in Python, featuring libraries like secrets for secure token/password generation.
• Web Interface to the API Backend that houses your main application logic.
• Branch out from the API Backend to multiple modules that interface with external systems:
• One branch for VM Management (linking to Proxmox VE module).
• Another for User Management (linking to Authentik, Guacamole, LLDAP modules).
• Yet another for Network Management (linking to FortiGate, Cloudflare, NGINX Proxy Manager modules).
• A background process block linked to the API Backend for periodic tasks like VM scheduling.
• Configuration details (load from .env, settings) where applicable.