Skip to content

osbyrne/pemd360

Repository files navigation

PEMD360

PEMD360 is a web application for building diagnostics and waste management (PEMD - Plan d'Évacuation des Matériaux et Déchets). The application uses Matterport 3D scans to create interactive tags for tracking various building materials, hazards (asbestos, lead, termites, structural issues), and waste management plans.

Setup

Pre-Requisite

Installation

# Install project dependencies:
npm install

# Login with Doppler to get the environment variables
doppler login

# Select project and config
doppler setup

Database Migration

# Generate migration
npm run drizzle-kit generate

# Apply migration
npm run drizzle-kit migrate

Matterport SDK Usage

  • Tags are stored with anchorPosition and stemVector for 3D positioning
  • Images can be captured directly from the Matterport viewer
  • The SDK is loaded via CDN (see package.json trusted dependencies)

Resources

Common Tasks

Adding a New Table

  1. Define schema in src/lib/server/db/schema.ts
  2. Add relations if needed
  3. Run npx drizzle-kit generate to create migration
  4. Run npx drizzle-kit migrate to apply

Creating a New Protected Route

  1. Add under src/routes/(app)/app/
  2. Use +layout.server.ts for authentication checks
  3. Access user via locals.user

Working with Matterport Tags

  • Reference existing tag tables (tags_amiante, tags_plomb, etc.)
  • Store anchorPosition and stemVector from Matterport SDK
  • Image can be base64 data URL or R2 URL
  • Link to projet via sidId (projet.id)

Generating Reports

  • Use src/lib/server/excel.ts for Excel generation with ExcelJS
  • Use pdf-lib for PDF manipulation
  • Export endpoints are in src/routes/(app)/app/admin/*/export/+server.t

Matterport Not Loading

  • Verify MATTERPORT_SDK_KEY is set
  • Check browser console for SDK errors
  • Ensure model ID is valid

Authentication Errors

  • Verify BETTER_AUTH_SECRET is set
  • Clear cookies and sessions if having issues

notes

Run npm run check and fix issues before committing Also run npm run format

About

Resources

Security policy

Stars

Watchers

Forks

Contributors