Erstes lauffähiges Grundgerüst: Monorepo, Fastify-API, React-Startseite, Docker

This commit is contained in:
2026-07-19 01:14:29 +02:00
parent 657496fe49
commit 7b8723729b
39 changed files with 4388 additions and 15 deletions

View File

@@ -0,0 +1,60 @@
import { sqliteTable, text, integer, real } from "drizzle-orm/sqlite-core";
/**
* Ein physisches/logisches Gerät im Netzwerk (z. B. per FritzBox-Scan gefunden).
*/
export const devices = sqliteTable("devices", {
id: text("id").primaryKey(),
hostname: text("hostname").notNull(),
ip: text("ip").notNull(),
mac: text("mac"),
manufacturer: text("manufacturer"),
model: text("model"),
online: integer("online", { mode: "boolean" }).notNull().default(false),
source: text("source").notNull(), // fritzbox | dns | http | https | portscan | manual
lastScan: text("last_scan"), // ISO-8601
createdAt: text("created_at").notNull(),
updatedAt: text("updated_at").notNull(),
});
/**
* Ein Dienst, der auf einem Gerät läuft (z. B. Frigate, Portainer, Gitea ...).
* Benutzeränderungen (displayName, category, favorite, order, alias, icon)
* dürfen von Scans NIEMALS überschrieben werden siehe README/Spezifikation.
*/
export const services = sqliteTable("services", {
id: text("id").primaryKey(),
deviceId: text("device_id")
.notNull()
.references(() => devices.id, { onDelete: "cascade" }),
// vom Benutzer gepflegt, wird von Scans nicht überschrieben
displayName: text("display_name").notNull(),
category: text("category"),
favorite: integer("favorite", { mode: "boolean" }).notNull().default(false),
order: real("order").notNull().default(0),
alias: text("alias").notNull().default("[]"), // JSON-Array als String
icon: text("icon"),
// von Scans aktualisierbar
hostname: text("hostname").notNull(),
url: text("url").notNull(),
https: integer("https", { mode: "boolean" }).notNull().default(false),
port: integer("port").notNull(),
favicon: text("favicon"),
description: text("description"),
createdAt: text("created_at").notNull(),
updatedAt: text("updated_at").notNull(),
});
/**
* Frei definierbare Kategorien (Erstellen/Löschen/Umbenennen/Sortieren per Drag & Drop).
*/
export const categories = sqliteTable("categories", {
id: text("id").primaryKey(),
name: text("name").notNull(),
order: real("order").notNull().default(0),
createdAt: text("created_at").notNull(),
updatedAt: text("updated_at").notNull(),
});