homarr-dashboard/DASHBOARD_AS_CODE.md

261 lines
5.2 KiB
Markdown

# 🏗️ Dashboard as Code for Homarr
Homarr 1.0 stores data in SQLite, but there are ways to work with it programmatically.
---
## Option 1: JSON Export/Import (Recommended)
Homarr 1.0+ supports exporting/importing boards as JSON.
### How to Export Your Current Board
```
1. Go to Manage → Boards
2. Click on a board
3. Click "Export" button
4. Download JSON file
```
### JSON Structure Example
Here's a complete board JSON you can import:
```json
{
"name": "Main Dashboard",
"description": "Public dashboard with news and links",
"backgroundImage": "",
"backgroundImageAttachment": "fixed",
"backgroundImageRepeat": "no-repeat",
"backgroundImageSize": "cover",
"colorScheme": "dark",
"customCss": "/* Paste CSS from custom-boards.css here */",
"items": [
{
"type": "clock",
"x": 0,
"y": 0,
"width": 2,
"height": 2,
"options": {
"showDate": true,
"timeFormat": "24"
}
},
{
"type": "weather",
"x": 2,
"y": 0,
"width": 2,
"height": 2,
"options": {
"location": "Stockholm, Sweden",
"unit": "celsius"
}
},
{
"type": "rss",
"x": 0,
"y": 2,
"width": 4,
"height": 3,
"options": {
"feedUrls": [
"https://selfh.st/rss/",
"https://noted.lol/rss/",
"https://feeds.fireside.fm/selfhosted/rss"
],
"postsLimit": 10,
"enableRtl": false,
"descriptionLineClamp": 3,
"hideDescription": false
}
},
{
"type": "rss",
"x": 4,
"y": 2,
"width": 4,
"height": 3,
"options": {
"feedUrls": [
"https://www.bleepingcomputer.com/feed/",
"https://feeds.feedburner.com/TheHackersNews",
"https://krebsonsecurity.com/feed/"
],
"postsLimit": 10,
"descriptionLineClamp": 2
}
},
{
"type": "app",
"x": 0,
"y": 5,
"width": 1,
"height": 1,
"options": {
"appId": "gmail-id"
}
},
{
"type": "app",
"x": 1,
"y": 5,
"width": 1,
"height": 1,
"options": {
"appId": "github-id"
}
}
],
"visibility": "public",
"layout": {
"columnCount": 8
}
}
```
### How to Import
```
1. Manage → Boards
2. Click "Import" button
3. Upload JSON file
4. Review and confirm
```
---
## Option 2: SQLite Database Editing (Advanced)
Homarr stores everything in `/opt/homarr/appdata/db/homarr.db`
### Access the Database
```bash
# SSH to your server
docker exec -it homarr sh
# Install sqlite3
apk add sqlite3
# Open database
sqlite3 /appdata/db/homarr.db
# View tables
.tables
# View boards
SELECT * FROM Board;
# View apps
SELECT * FROM App;
```
### Key Tables
| Table | Purpose |
|-------|---------|
| `Board` | Board definitions |
| `Section` | Board sections/items |
| `App` | App definitions |
| `Integration` | Integration configs |
---
## Option 3: API Approach (Scripting)
Homarr has internal APIs you can script against:
### Get Board Data
```bash
# Get all boards
curl http://localhost:7575/api/boards
# Get specific board
curl http://localhost:7575/api/boards/main-dashboard
```
### Create Board via API
```bash
# This requires authentication cookie/session
# You'd need to extract from browser DevTools
curl -X POST http://localhost:7575/api/boards \
-H "Content-Type: application/json" \
-H "Cookie: your-auth-cookie" \
-d '{
"name": "Auto Created Board",
"visibility": "public"
}'
```
---
## Option 4: Pre-built JSON Files (I Can Create These)
I can create complete JSON files for you to import!
### Board 1: Main Dashboard JSON
**File:** `boards/main-dashboard.json`
### Board 2: System Monitor JSON
**File:** `boards/system-overview.json`
### Board 3: Infrastructure JSON
**File:** `boards/infrastructure.json`
You would:
1. Download these JSON files
2. Import each one in Homarr
3. Done!
---
## What I Can Do For You
### Option A: Create Importable JSON Files
I'll create complete JSON files for each board:
- ✅ Main Dashboard (with RSS feeds, clock, weather)
- ✅ System Overview (full-screen Dash.)
- ✅ Infrastructure (with all your apps)
- ✅ Media Center (if needed)
**You just import them!**
### Option B: Create SQL Scripts
Generate SQL INSERT statements to directly populate the database.
### Option C: Step-by-Step Copy/Paste
Provide exact values to enter in each field.
---
## Which Option Do You Want?
| Option | Effort For You | Effort For Me | Best For |
|--------|---------------|---------------|----------|
| **A - JSON Import** | Low (just import) | Medium | Quick setup |
| **B - SQL Script** | Low (run script) | Medium | Automation |
| **C - Copy/Paste** | Medium | Low | Learning |
---
## Tell Me:
1. **Which boards** do you want me to build?
- Main Dashboard (public)
- System Overview (private)
- Infrastructure (private)
- Media Center (private)
- News Hub (public)
2. **Which method?**
- JSON import files
- SQL script
- Copy/paste guide
3. **Your details:**
- Location (for weather)
- Apps you want included (from the 60+ list)
- RSS feed preferences
I'll build them for you! 🚀