Skip to content

PlaceBrain/frontend

Repository files navigation

frontend

Vue 3 SPA for PlaceBrain — places, devices, live telemetry, alerts.

License: Apache 2.0 Vue 3 TypeScript Vite

The web client for PlaceBrain. It talks REST to the gateway for CRUD and Auth, and subscribes over MQTT-over-WebSocket for live telemetry and alerts. The design is minimalist, theme-aware (light/dark), and laid out for both desktop (left sidebar) and mobile (bottom navbar).

Role in PlaceBrain

PlaceBrain is an open-source IoT platform for smart buildings. See the organization profile for the full architecture.

  • Talks only to gateway over HTTP (VITE_API_URL, proxied by Traefik on /api/*).
  • Fetches short-lived MQTT credentials from POST /api/mqtt/credentials and connects to EMQX over WebSocket (/mqtt).
  • Subscribes to placebrain/{placeId}/device/{deviceId}/telemetry and placebrain/{placeId}/alerts for live updates.

Tech stack

Structure (Feature-Sliced Design)

src/
├── app/          Providers (router, pinia, TanStack Query), layouts, global styles
├── pages/        Login, Register, VerifyOtp, Dashboard, Places, PlaceDetail,
│                 Devices, DeviceDetail, DeviceEditor, SensorEditor, Alerts, Profile
├── widgets/      Sidebar, MobileNavbar, PlaceTabs, SensorsPanel, ActuatorsPanel,
│                 ChartsPanel, PlaceCardGrid
├── features/     Auth forms, CRUD modals, manage-devices/sensors/actuators, theme toggle
├── entities/     user, place, device, member (types, TanStack Query hooks, UI)
└── shared/       UI kit (UiButton, UiInput, UiModal, UiConfirmDialog, UiOtpInput, ...),
                  API client, query keys, composables (useMqtt, useBreakpoint), stores, config

Design language

  • Light/dark themes via CSS variables + dark class on <html>.
  • Minimalist, no gradients. Accent #6E9EF9, danger #E85A4F.
  • Inter for body, Space Grotesk for headings (font-heading class).
  • Colors are referenced only through var(--color-*); hardcoded Tailwind palette classes are avoided.
  • Surface convention: --color-surface for cards/sidebars/modals, --color-surface-elevated for the page background. Cards always stand out from the background.

UX conventions

  • Destructive actions go through <UiConfirmDialog>, never native confirm().
  • Post-mutation feedback via useToast() on authenticated pages; inline on auth pages (login/register/verify-otp).
  • Icon-only buttons carry an aria-label. Modals are role="dialog" with focus trap.
  • Breakpoint 768px: desktop sidebar (w-64 / w-16 collapsed, toggle via Cmd/Ctrl+B), mobile bottom navbar (h-16).
  • Auth flow: register → OTP email verification → login. Unverified users are redirected to /verify-otp.

Local development

Full stack (recommended): clone infra and run make dev. The frontend is served by a Vite dev container behind Traefik; the SPA lives at http://localhost.

Service-only mode:

npm install
cp .env.example .env          # set VITE_API_URL
npm run dev

You still need a reachable gateway at VITE_API_URL.

Scripts

npm run dev         # Vite dev server
npm run build       # vue-tsc -b + vite build
npm run preview     # serve production build
npm run lint:fix    # ESLint autofix
npm run format      # Prettier
npx vue-tsc -b      # standalone type-check (also run by CI)

Environment variables

Variable Purpose
VITE_API_URL Base URL of the gateway HTTP API (e.g. http://localhost)

License

Apache License 2.0 — see LICENSE.

About

Vue 3 SPA for PlaceBrain: places, devices, live telemetry, alerts

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors