# Run Instructions ## Project Description Minmon is a student-friendly web dashboard for managing private servers, services, domains, and internal notes. The current implementation focuses on protected CRUD flows plus lightweight DNS A-record checking. ## Current Main Features - First-run administrator registration when no users exist - Better Auth sign-in with ordinary public registration disabled - User creation by initial password or one-time invitation link - Invitation copy, revoke, replace, accepted, and revoked lifecycle states - Forced password replacement for administrator-created initial passwords - Root route (`/`) redirects automatically: - no users -> `/setup` - initial-password replacement required -> `/change-password` - logged in -> `/dashboard` - not logged in -> `/login` - Dashboard summary for: - total servers - total services - total domains - DNS match / mismatch / unresolved counts - inactive or down services - recent notes - Server CRUD - Service CRUD - Domain CRUD - Note CRUD - Domain DNS check from: - domain list - domain detail page - Server detail page includes notes that belong to that server - Foreign-key form fields use select inputs for related records: - service -> server - domain -> service - note -> server - Optional sample admin and demo dataset ## Current Route Structure - `/` -> auth-based redirect - `/setup` -> first administrator registration, available only while there are no users - `/login` -> sign-in page - `/change-password` -> required initial-password replacement - `/invite/$token` -> one-time invitation acceptance - `/dashboard` -> summary page - `/dashboard/servers` -> server list - `/dashboard/servers/new` -> create server - `/dashboard/servers/$serverId` -> server detail + edit + related notes - `/dashboard/services` -> service list - `/dashboard/services/new` -> create service - `/dashboard/services/$serviceId` -> service detail + edit - `/dashboard/domains` -> domain list - `/dashboard/domains/new` -> create domain - `/dashboard/domains/$domainId` -> domain detail + edit - `/dashboard/notes` -> note list - `/dashboard/notes/new` -> create note - `/dashboard/notes/$noteId` -> note detail + edit - `/dashboard/users` -> users, roles, and invitation lifecycle management ## Local Setup 1. Install dependencies ```bash bun install ``` 2. Prepare environment file at `apps/server/.env` Example values: ```env DATABASE_URL=postgresql://postgres:postgres@localhost:5432/minmon BETTER_AUTH_SECRET=your-32-char-or-longer-secret-value-here BETTER_AUTH_URL=http://localhost:3000 CORS_ORIGIN=http://localhost:5173 NODE_ENV=development ``` 3. Prepare web environment at `apps/web/.env` ```env VITE_SERVER_URL=http://localhost:3000 ``` 4. Ensure the web app can reach the server - The web client uses the better-auth client with `env.VITE_SERVER_URL` - Make sure the web environment points to the running API server 5. Start PostgreSQL if needed ```bash bun run db:start ``` 6. Apply schema ```bash bun run db:push ``` 7. Run the apps ```bash bun run dev ``` 8. Open the app - Web: `http://localhost:5173` - API: `http://localhost:3000` With an empty user table, the root and login routes redirect to `/setup`. Create the first administrator there. The backend serializes first-account creation and rejects any later public registration attempt. ### Optional demo seed The explicit demo seed is still available when the sample inventory and fixed demo administrator are needed: ```bash bun run --filter @minmon/db db:seed ``` Seeded admin login: - Email: `admin@minmon.local` - Password: `admin12345` ## Docker Compose Deployment Run the deployable stack with one command: ```bash cp .env.example .env docker compose up -d ``` Default Docker endpoints: - Web: `http://localhost:3001` - API: `http://localhost:3000` The Compose stack starts PostgreSQL, applies the schema, and ensures the default roles and permissions exist. It does not seed a default user; finish initialization from the first-run setup screen. Docker Compose reads the root `.env` file automatically. Edit it before startup if you need different ports, public URLs, credentials, or secrets. ## Current Behavior Notes ### List Ordering - Main CRUD list pages are ordered by: - `createdAt DESC` - then `id DESC` - This keeps row ordering deterministic after refetch. ### Delete Actions - List pages use a two-click destructive icon flow: - first click: trash icon - second click: check icon confirms delete - Confirm state resets on blur and timeout. ### Domain DNS Check - Domain list uses the DNS status badge itself as the check trigger. - Domain detail page also provides a DNS check action. - DNS checking resolves IPv4 A records only. ### Relationship Behavior - Deleting a server removes related services, domains, and notes through cascade rules in the database. - Deleting a service removes related domains through cascade rules. ## Helpful Commands ```bash bun run check-types bun run db:push bun run db:studio bun run --filter web check-types bun run --filter server check-types bun x tsc --noEmit -p packages/api/tsconfig.json ``` ## Notes - Full workspace typecheck may still fail because of a pre-existing `apps/desktop` typing issue for `three`. - The verified implementation path is the web app + server app + database push + database seed. - DNS checking is limited to A record / IPv4. - Docker Compose is available for running the app stack; the app itself does not include SSH, reverse proxy, or host orchestration automation.