# ach-raf/open_link_server architecture

> Architecture diagram of the GitHub repository ach-raf/open_link_server, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ach-raf/open_link_server
- Repository: https://github.com/ach-raf/open_link_server

## Overview

##### Project type and purpose
- This is a networked “backend” CLI application written in Python that serves as a remote‐control server for an Android client (OpenLink Client).
- It uses UDP broadcasting for discovery and TCP for command delivery, then executes OS‐level actions (keyboard events, screen control, link opening).

##### File structure
- Top‐level files:
- server_cli.py – entry point, starts UDP/TCP services and dispatches commands.
- lib/ – command‐action modules:
– udp_broadcaster.py – discovery responder
– keyboard_mouse.py & mouse_keyboard.py – input injection
– turn_off_screen.py – screen power control
- requirements.txt, Readme.md, LICENSE, .gitignore – metadata/config.

##### README for additional insights
- Technical stack: Python 3.x, standard library sockets, pyKey (keyboard handling).
- Behavior:
- UDP broadcast listening/responses for client autodiscovery.
- TCP server loop for receiving commands/links.
- Parsing commands and invoking corresponding lib modules.
- Opens URLs in default browser.

##### Detailed breakdown
– Action Modules cluster (keyboard_mouse, turn_off_screen, etc.)

## Diagram (Mermaid)

```mermaid
flowchart TD
    classDef network fill:#a2f5a2,stroke:#333,stroke-width:1px
    classDef core fill:#afd7ff,stroke:#333,stroke-width:1px
    classDef action fill:#ffd79e,stroke:#333,stroke-width:1px
    classDef external fill:#d3d3d3,stroke:#333,stroke-width:1px
    classDef doc fill:#f0e68c,stroke:#333,stroke-width:1px

    Android["OpenLink Client"]:::external

    subgraph "OpenLink Server"
        direction TB
        UDPService["UDP Discovery Service"]:::network
        TCPServer["TCP Command Server"]:::network
        Parser["Command Parser & Dispatcher"]:::core

        subgraph "Action Modules"
            direction TB
            KM["Keyboard/Mouse Module"]:::action
            MK["Mouse/Keyboard Module"]:::action
            Screen["Screen Power Control Module"]:::action
        end
    end

    Browser["Default Web Browser"]:::external
    HostOS["Host OS"]:::external

    Requirements["requirements.txt"]:::doc
    Readme["Readme.md"]:::doc

    Android -->|"UDP discovery"| UDPService
    UDPService -->|"UDP reply"| Android
    Android -->|"TCP connection"| TCPServer
    TCPServer -->|"TCP command"| Parser

    Parser -->|"keyboard command"| KM
    Parser -->|"mouse command"| MK
    Parser -->|"screen off command"| Screen
    Parser -->|"open link"| Browser

    KM -->|"OS event"| HostOS
    MK -->|"OS event"| HostOS
    Screen -->|"power control"| HostOS

    click UDPService "https://github.com/ach-raf/open_link_server/blob/master/lib/udp_broadcaster.py"
    click TCPServer "https://github.com/ach-raf/open_link_server/blob/master/server_cli.py"
    click Parser "https://github.com/ach-raf/open_link_server/blob/master/server_cli.py"
    click KM "https://github.com/ach-raf/open_link_server/blob/master/lib/keyboard_mouse.py"
    click MK "https://github.com/ach-raf/open_link_server/blob/master/lib/mouse_keyboard.py"
    click Screen "https://github.com/ach-raf/open_link_server/blob/master/lib/turn_off_screen.py"
    click Requirements "https://github.com/ach-raf/open_link_server/blob/master/requirements.txt"
    click Readme "https://github.com/ach-raf/open_link_server/blob/master/Readme.md"
```
