# BarkWho: Manor Network Controller

**BarkWho** is a self-hosted, "Dark Academia" themed parental control dashboard designed specifically for the UniFi Dream Router (UDR). It provides a simplified, high-fidelity interface for managing family internet access, implementing curfews, and "nuking" specific devices during emergencies.

---

## 🏛️ Architecture & Logic

BarkWho is built as a bridge between your family`s daily needs and the complex UniFi Network application.

### The Stack
*   **Frontend:** React (Vite) PWA with Tailwind CSS. Styled with a custom "Dark Academia Tech" aesthetic (Deep Viridian, Gold, Cream) featuring glassmorphism and circuit board motifs.
*   **Backend:** Node.js (Express) acting as a secure middleware.
*   **Integration:** Communicates directly with the UDR`s local API (`/proxy/network/v2/...`).

### Core Logic: "State Inversion"
BarkWho operates on a **"Permission First"** mental model, whereas UniFi operates on a **"Restriction"** model.
*   **UI Green (Allowed):** BarkWho sends `enabled: false` to the UniFi Block Rule. (The block is *off*, so traffic flows).
*   **UI Red (Blocked):** BarkWho sends `enabled: true` to the UniFi Block Rule. (The block is *active*, traffic is stopped).

---

## 🚀 Deployment Guide

### Prerequisites
1.  **UniFi Dream Router (UDR)** with SSH enabled or a local admin user.
2.  **Docker & Docker Compose** installed on your hosting server (e.g., Raspberry Pi, Proxmox VM).

### 1. Configuration
Create a `.env` file in the project root:
```bash
UDR_IP=192.168.1.1          # IP address of your UDR
UDR_USER=localadmin         # Local admin username (not UI.com email)
UDR_PASSWORD=password123    # Local admin password
APP_SECRET_KEY=secret_key   # Random string for session security
```

### 2. Map Your Policies
BarkWho needs to know which UniFi Traffic Rules correspond to your dashboard categories.
1.  Log in to your UniFi Network Controller.
2.  Go to **Settings > Traffic Management > Rules**.
3.  Create your blocking rules (e.g., "Block Social Media", "Block Gaming"). **Assign them to the specific Target Groups (Target: "kids_console", "kids_computers") in UniFi.**
4.  BarkWho will auto-discover these rules. In the BarkWho Dashboard, click the **Settings (Gear)** icon on a Category card to select which rules belong to "Social", "Gaming", etc.

### 3. Launch
```bash
docker compose up -d --build
```
Access the dashboard at `http://<server-ip>:5173`.

---

## 📖 End User Guide (How-To)

### 1. Dashboard Controls
*   **Category Toggles:** Switch "Social Media" or "Gaming" on/off instantly. This toggles the underlying rules on your router.
*   **Bonus Time:** Click the **Circle/Plus** icon on a category to grant temporary access (15m, 30m, 1h). The system automatically re-blocks access when time expires.
*   **Rule Assignment:** Click the **Gear** icon to choose which UniFi rules are controlled by that category card.

### 2. The Curfew Clock
*   **Status:** Shows if the "Estate Curfew" is currently active.
*   **Overrides:** If you need to extend internet access past bedtime, use the **Custom** or preset buttons (+30m, +1h) to temporarily disable the curfew.

### 3. Device Library & "Nuke"
*   **Search:** Quickly find devices by name (e.g., "iPad") or Owner.
*   **NUKE:** The big red button immediately cuts off **all** internet access for that specific device (via UniFi`s "Block Client" feature). Use "Restore" to unblock.

---

## 🧩 Device Profiles & Router Groups

**Q: I see a "Profile: Kids" option in BarkWho, but I have "kids_computers" and "kids_console" groups on my router. How do they match?**

**A: In Version 1.0, they function independently.**

1.  **BarkWho Profiles (Visual Tagging):**
    The dropdown in the Device Library (Default, Kids, IoT) is a **visual organizer** for *you*. It helps you quickly identify which iPad belongs to whom within the BarkWho interface. It remembers your selection locally but does **not** reconfigure the router.

2.  **Router Groups (Functional Enforcement):**
    The actual blocking power comes from the **UniFi Traffic Rules**.
    *   *Example:* In UniFi, you create a rule named "Block Roblox". You set the **Target** of that rule to include both your `kids_computers` and `kids_console` groups.
    *   *In BarkWho:* You assign the "Block Roblox" rule to the "Gaming" category.
    *   *Result:* When you toggle "Gaming" to **Block** in BarkWho, it enables that rule. UniFi then enforces it against *whomever* you defined in the rule settings (both computer and console groups).

**Summary:** Use UniFi to define *who* gets blocked (Groups). Use BarkWho to decide *when* they get blocked (Policies/Curfew).
