# prakhar896/dl-manager architecture

> Architecture diagram of the GitHub repository prakhar896/dl-manager, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/prakhar896/dl-manager
- Repository: https://github.com/prakhar896/dl-manager

## Overview

##### Project type and purpose
- This is a full-stack Python web application called “DeepLens Manager (DLM).”
- Purpose: provide a browser-based UI to interact with AWS DeepLens devices and manage product activation via the external “Activator” DRM service.

##### File structure
- Top-level Python modules (main.py, api.py, activation.py, dlmAdmin.py, assets.py, session.py, models.py) implement the backend and business logic.
- “templates/” holds Jinja2 HTML templates (base.html, home.html, logout.html, zsh.html).
- “supportFiles/” contains client-side JavaScript (home.js, logout.js, zsh.js, base.js) and assets served by assets.py.
- “admin/” contains admin panel HTML.
- README.md, usage.md, about.md and documentation/ folder supply user/docs resources; mdConverter.py can convert markdown to HTML.
- requirements.txt, sbConfig.json and version.txt are configuration and dependency manifests.

##### Extract insights from the README
- DLM auto-activates itself against Activator on boot (activation.py).
- A licensekey.txt is downloaded and stored locally; periodic KVR (license verification) occurs every 14 days.
- If activation fails, the app disables certain functionality and prompts reactivation.
- The core flow: client browser → DLM web server → external Activator REST API → local file system (licensekey.txt) → back to web server.

##### Main architectural components
a. Client layer
- Web browser / user agent that loads HTML/JS pages from the DLM server.
b. Web application layer (Flask or similar)
- main.py: initializes the HTTP server and routing.
- api.py & dlmAdmin.py: define REST endpoints for device commands and admin functions.
- assets.py & supportFiles: serve static JS/CSS.
- session.py: user authentication/session management.
- models.py: data models (in-memory or SQLite) representing device/session/activation state.
- mdConverter.py: dynamic docs rendering.
c. File system / persistent storage
- licensekey.txt stored on local disk.
- optional session or DB file if used by models.py.
d. External services
- Activator DRM service (REST API) for activation & periodic KVR.
- AWS DeepLens device API (SSH or AWS SDK) that actual “device commands” endpoints in api.py call.
e. Documentation subsystem (static site / embedded video demos)

##### Relationships & data flows
- Browser → HTTP(S) → Web App (routes in api.py / dlmAdmin.py)
- Web App ↔ File System (read/write licensekey.txt, config files)
- Web App → HTTP(S) → Activator Service (activation.py handles initial activation & KVR)
- Web App → SSH/AWS SDK → DeepLens device (device management commands)
- Web App → render templates + mdConverter → HTML → Browser

##### Architectural patterns & design principles
- MVC-style separation:
- Models: models.py
- Views: templates/*.html + supportFiles/*.js
- Controllers: main.py, api.py, dlmAdmin.py
- Single codebase, monolithic web server.
- Periodic background task (KVR scheduler inside activation.py).
- Externalized configuration (sbConfig.json, requirements.txt, version.txt).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    Browser["Web Browser"]:::frontend

    %% Web Application Components
    subgraph "Web Application"
        direction TB
        main["main.py"]:::backend
        subgraph "Controllers"
            api["api.py"]:::backend
            dlmAdmin["dlmAdmin.py"]:::backend
            adminTemplates["admin/home.html"]:::frontend
        end
        assets["assets.py"]:::backend
        subgraph "Static Assets & Templates"
            templates["templates/"]:::frontend
            supportFiles["supportFiles/"]:::frontend
        end
        subgraph "Session & Models"
            session["session.py"]:::backend
            models["models.py"]:::backend
        end
        activation["activation.py"]:::backend
        subgraph "Documentation Renderer"
            mdConverter["mdConverter.py"]:::backend
            docs["documentation/"]:::frontend
        end
        subgraph "Config & Dependencies"
            sbConfig["sbConfig.json"]:::backend
            req["requirements.txt"]:::backend
            ver["version.txt"]:::backend
        end
    end

    %% Persistent Storage
    storage["licensekey.txt & DB"]:::storage

    %% External Services
    externalActivator["Activator DRM Service (REST)"]:::external
    externalDeepLens["AWS DeepLens Device (SSH/API)"]:::external

    %% Static Documentation & Resources
    subgraph "Static Documentation & Resources"
        readme["README.md"]:::frontend
        about["about.md"]:::frontend
        usage["usage.md"]:::frontend
        indexHTML["index.html"]:::frontend
        indexJS["index.js"]:::frontend
    end

    %% Relationships
    Browser -->|HTTP GET/POST| main
    Browser --> templates
    Browser --> supportFiles

    main --> api
    main --> dlmAdmin
    dlmAdmin --> adminTemplates
    main --> assets
    main --> session
    api --> session
    session --> models

    main --> activation
    activation --> storage
    activation -->|HTTP POST/GET| externalActivator

    api -->|SSH/API| externalDeepLens

    main --> mdConverter
    mdConverter --> docs

    main --> sbConfig
    main --> req
    main --> ver

    Browser -->|VIEW| readme
    Browser -->|VIEW| about
    Browser -->|VIEW| usage
    Browser -->|VIEW| indexHTML
    Browser -->|LOAD| indexJS

    %% Click Events
    click templates "https://github.com/prakhar896/dl-manager/tree/main/templates/"
    click supportFiles "https://github.com/prakhar896/dl-manager/tree/main/supportFiles/"
    click main "https://github.com/prakhar896/dl-manager/blob/main/main.py"
    click api "https://github.com/prakhar896/dl-manager/blob/main/api.py"
    click dlmAdmin "https://github.com/prakhar896/dl-manager/blob/main/dlmAdmin.py"
    click adminTemplates "https://github.com/prakhar896/dl-manager/blob/main/admin/home.html"
    click assets "https://github.com/prakhar896/dl-manager/blob/main/assets.py"
    click session "https://github.com/prakhar896/dl-manager/blob/main/session.py"
    click models "https://github.com/prakhar896/dl-manager/blob/main/models.py"
    click activation "https://github.com/prakhar896/dl-manager/blob/main/activation.py"
    click mdConverter "https://github.com/prakhar896/dl-manager/blob/main/mdConverter.py"
    click docs "https://github.com/prakhar896/dl-manager/tree/main/documentation/"
    click sbConfig "https://github.com/prakhar896/dl-manager/blob/main/sbConfig.json"
    click req "https://github.com/prakhar896/dl-manager/blob/main/requirements.txt"
    click ver "https://github.com/prakhar896/dl-manager/blob/main/version.txt"
    click readme "https://github.com/prakhar896/dl-manager/blob/main/README.md"
    click about "https://github.com/prakhar896/dl-manager/blob/main/about.md"
    click usage "https://github.com/prakhar896/dl-manager/blob/main/usage.md"
    click indexHTML "https://github.com/prakhar896/dl-manager/blob/main/index.html"
    click indexJS "https://github.com/prakhar896/dl-manager/blob/main/index.js"

    %% Styles
    classDef frontend fill:#E0F7FA,stroke:#006064,color:#006064;
    classDef backend fill:#E8F5E9,stroke:#2E7D32,color:#2E7D32;
    classDef external fill:#FFF3E0,stroke:#EF6C00,color:#E65100;
    classDef storage fill:#ECEFF1,stroke:#546E7A,color:#37474F;
```
