# Group Meditation Service

The group meditation service orchestrates collaborative practice flows, spanning
live sessions, community programs, and user-generated ritual tooling. It exposes
Fastify endpoints layered over MongoDB for persistence and Redis for optional
real-time coordination.

## Custom Meditation Creation Tools

Author-guided meditation blueprints support iterative refinement and publishing,
alongside reusable component templates.

- `POST /v1/custom-meditations` — create a meditation blueprint with phases,
  breath cues, audio layers, and media assets.
- `POST /v1/custom-meditations/:meditationId/revisions` — replace blueprint
  elements while preserving revision history and version metrics.
- `POST /v1/custom-meditations/:meditationId/publish` — record validation
  details and release-channel metadata when promoting a blueprint to published
  status.
- `GET /v1/custom-meditations/:meditationId/builder-insights` — surface
  analytics for duration balance, audio and breath coverage, and recommended
  improvements based on stored blueprint data.
- `POST /v1/custom-meditations/component-templates` — capture reusable
  phase/audio/breath combinations as author-scoped templates with analytics and
  usage metrics.
- `GET /v1/custom-meditations/component-templates?authorId=...` — list the
  author’s templates with aggregated statistics and tag histograms for quick
  filtering.
- `POST /v1/custom-meditations/:meditationId/apply-template` — merge a component
  template into an existing blueprint (append, prepend, replace, or insert)
  while updating version metrics, revision history, and template usage counts.

### Testing

Targeted Jest specs cover the creation, revision, publishing, analytics,
reusable templates, and template application flows:

```bash
cd apps/lilith/svc-group-meditation
timeout -k 5 180s env NODE_OPTIONS=--experimental-vm-modules \
  npx jest --runInBand src/__tests__/app.test.ts -t "Custom meditation creation tools"
```

MongoDB indexes for `custom_meditations` and `custom_meditation_templates` are
created on startup; supply `MONGO_URL` and `JWT_SECRET` to configure
authentication and persistence during local runs.

## Wisdom Sharing Platform

The wisdom sharing workflows help curators collect, analyze, and spotlight
community teachings.

- `POST /v1/wisdom-boards` — establish a wisdom board blueprint with spotlight
  themes, formats, and healer council metadata.
- `POST /v1/wisdom-boards/:boardId/contributions` — ingest community
  contributions with attachments, endorsements, and spotlight theme routing.
- `GET /v1/wisdom-boards/:boardId/curation-insights` — surface curator analytics
  (tag trends, format mix, endorsement averages, and top contributors).
- `POST /v1/wisdom-boards/:boardId/contributions/:contributionId/highlight` —
  mark a contribution as a featured teaching, updating highlight metrics and
  history.
- `POST /v1/wisdom-boards/:boardId/publish` — compile and release digests with
  spotlight rotation updates.

### Testing

Targeted Jest specs cover creation, contribution ingestion, curator insights,
highlights, and digest publishing:

```bash
cd apps/lilith/svc-group-meditation
timeout -k 5 180s env NODE_OPTIONS=--experimental-vm-modules \
  npx jest --runInBand src/__tests__/app.test.ts -t "Wisdom sharing platform"
```

## Virtual Temple Construction

Virtual temple orchestration enables architects to craft immersive sacred
spaces, track live presence, and archive consecration summaries.

- `POST /v1/virtual-temples` — register a temple blueprint with dimensional
  layout, sensory scapes, guardian council, and ritual chambers.
- `POST /v1/virtual-temples/:templeId/presence` — stream presence telemetry
  (entering/exiting participants, zone harmonics, ambient readings) and update
  active metrics.
- `POST /v1/virtual-temples/:templeId/complete` — finalize a temple cycle with
  guardian highlights, integration guidance, energetic readings, and archival
  assets.

### Testing

```bash
cd apps/lilith/svc-group-meditation
timeout -k 5 180s env NODE_OPTIONS=--experimental-vm-modules \
  npx jest --runInBand src/__tests__/app.test.ts -t "Virtual temple construction"
```
