Skip to content

Rhishavhere/onecloud

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

31 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

OneCloud: Personal Cloud Server and API

PYTHON FLASK OS CLOUDFLARED

OneCloud is a personal cloud backend that gives you real-time insights and control over your devices.

It acts as the central hub for your personal cloud, enabling system monitoring, AI-assisted queries, and remote operations โ€” securely accessible from anywhere.

The backend leverages Flask APIs and Cloudflare Tunnel for secure access, even behind NAT or firewalls.

With OneCloud, you can:

  • Monitor multiple devices in real time
  • View detailed system metrics
  • Capture screenshots remotely
  • Perform control actions like shutdown/reboot
  • Chat with an AI assistant about your system
  • Keep your devices safe with token-based authentication

Frontend ( separate repo )

The OneCloud Backend works together with the OneCloud Frontend to give you a full dashboard experience. The frontend is a separate project and can be found here: Frontend Repo โ†’ github.com/Rhishavhere/mydesk.app


Architecture

OneCloud consists of:

  1. Backend API (This Project) Runs on each monitored device, collecting metrics and handling control actions.

  2. Frontend Dashboard A separate React/TypeScript project that consumes this API and displays a beautiful dashboard (see link above).


Cloudflare Tunnel Integration

Cloudflare Tunnel securely connects your devices to the internet without opening ports.

When a request is made to your domain (e.g., https://your-domain.com), Cloudflare routes it through a secure outbound-only tunnel to your API.

Benefits:

  • ๐Ÿ”’ No open ports โ€” safer by design
  • โšก Simpler setup โ€” no complex networking configs
  • ๐Ÿ“œ TLS by default โ€” automatic HTTPS
  • ๐Ÿ›ก DDoS Protection โ€” Cloudflare shields your API

Platform-Specific Note

OneCloud supports both Windows and Linux (Fedora) environments with separate API scripts:

  • Windows โ†’ api_win.py โ†’ exposes /desktop/* endpoints
  • Linux (Fedora) โ†’ api_linux.py โ†’ exposes /laptop/* endpoints

Update the exposed endpoints to match your device preferences.

Simply run the script for your OS and tunnel it using Cloudflare Tunnel to your chosen public hostname. Example:

  • Desktop: https://your-domain.com/desktop/system/overview
  • Laptop: https://your-domain.com/laptop/system/overview

API Endpoints

๐Ÿ–ฅ System Information

Endpoint Method Description
/status GET Quick overview: OS, hostname, uptime
/system/overview GET Full CPU, memory, disk, network, battery, temp
/system/cpu GET Detailed CPU stats
/system/memory GET Memory + swap usage
/system/disk GET Disk partitions & I/O
/system/network GET Interfaces, I/O, connections
/system/processes GET Running processes info
/system/battery GET Battery status
/system/temperature GET Temperature readings
/system/users GET Logged-in users
/system/services GET Windows services
/system/metrics/history GET Historical CPU/mem/network usage

๐Ÿ›  System Control

Endpoint Method Description
/system/screenshot GET Capture current screen
/system/control/shutdown POST Schedule shutdown
/system/control/reboot POST Schedule reboot
/system/control/cancel-shutdown POST Cancel shutdown/reboot
/laptop/camera/capture GET Capture image from webcam and return as PNG

๐ŸŽฎ Remote Desktop & Input

Endpoint Method Description
/desktop/livestream GET MJPEG video stream of the desktop
/desktop/mapping POST Control mouse/keyboard actions

๐Ÿค– AI Integration

Endpoint Method Description
/ai/chat POST Chat with your devices using Google Gemini AI

โค๏ธ Health Check

Endpoint Method Description
/health GET API health status

Endpoint Parameters

/system/processes (GET)

  • limit (int) โ€” number of processes to return (default: 20)
  • sort (string) โ€” sort by memory, cpu, name, or pid (default: memory)

Example:

GET /desktop/system/processes?limit=10&sort=cpu

/system/screenshot (GET)

  • width (int) โ€” resize image width before returning
  • height (int) โ€” resize image height before returning
  • quality (int) โ€” image quality (default: 95)

Example:

GET /desktop/system/screenshot?width=800&height=600&quality=80

/ai/chat (POST)

  • query (string) โ€” natural language question or command
  • include_screenshot (bool) โ€” if true, attaches a screenshot for AI context Body: { "query": "Describe the system status", "include_screenshot": true }

---

### `/desktop/livestream` (GET)
- `fps` *(int)* โ€” frames per second (default: 15, max: 30)
- `quality` *(int)* โ€” JPEG quality 1-100 (default: 70)
- `scale` *(float)* โ€” resolution scale 0.1-1.0 (default: 0.5)
- `cursor` *(string)* โ€” `crosshair`, `simple`, or `none`

**Example:**
```bash
https://your-domain.com/desktop/livestream?fps=20&quality=80&scale=0.75

/desktop/mapping (POST)

Control the mouse remotely. Requires Authorization header.

Body (Move):

{
  "action": "move",
  "x": 0.5,     // 0.0 to 1.0 (normalized)
  "y": 0.5,
  "normalized": true
}

Body (Click/Tap):

{
  "action": "tap", // or 'doubletap', 'rightclick'
  "x": 0.5,
  "y": 0.5
}

Body (Scroll):

{
  "action": "scroll",
  "delta": 200 // positive = up, negative = down
}

Setup

Prerequisites

  • Python 3.8+
  • Cloudflare account + cloudflared tunnel
  • Cloudflare account + cloudflared tunnel
  • Google Gemini API key
  • (mss is recommended for faster screen capture, installed via requirements)

Install & Run

# Create venv & install deps
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt

# Create .env
echo "GEMINI_API_KEY=your_gemini_key" >> .env
echo "CONTROL_TOKEN=your_secure_token" >> .env

# Start API
python api_win.py   # for Windows
# or
python api_linux.py # for Linux (Fedora)

---

Expose API via Cloudflare Tunnel

  1. Install Cloudflare Tunnel CLI (cloudflared): Installation Guide โ†’ Cloudflare Docs

  2. Authenticate with Cloudflare:

cloudflared login
  1. Create a tunnel (replace <YOUR_TUNNEL_NAME> with a name you choose):
cloudflared tunnel create <YOUR_TUNNEL_NAME>
  1. Configure the tunnel by creating ~/.cloudflared/config.yml:
tunnel: <YOUR_TUNNEL_UUID>
credentials-file: /home/user/.cloudflared/<YOUR_TUNNEL_UUID>.json

# Change hostname to your Cloudflare domain/subdomain
hostname: your-domain.com
service: http://localhost:5000
  1. Run the tunnel:
cloudflared tunnel run <YOUR_TUNNEL_NAME>

Once the tunnel is running, your API will be available at:

  • Desktop: https://your-domain.com/desktop/*
  • Laptop: https://your-domain.com/laptop/*

Security Tips

  • Use strong, unique tokens in .env
  • Always access via HTTPS (Cloudflare provides this)
  • Keep dependencies updated

About

Personal Cloud Server and API

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published