Skip to content

Treeper — Backend (NestJS)

REST API for the Treeper mobile app. Sits in front of Supabase (which handles auth, Postgres, and storage) and orchestrates the Python workers (apps/workers) for AI ingest and scraping.

For the why and the architecture, see ADRs: 0002 Supabase + NestJS API, 0003 Python workers, 0006 Docker / Coolify deploy.

The first feature this service implements is 0001 Trip Planner — see its §8 for the v0 endpoint surface.


Terminal window
cd apps/backend
cp .env.example .env.local # fill in real values
npm install
npm run start:dev # http://localhost:3000/v1/health

Required env vars are documented in .env.example. The service refuses to start without SUPABASE_JWT_SECRET.

apps/backend/
├── src/
│ ├── main.ts bootstrap + helmet + global v1 prefix
│ ├── app.module.ts
│ ├── auth/
│ │ ├── auth.module.ts
│ │ ├── supabase-jwt.strategy.ts HS256 verify of Supabase access tokens
│ │ ├── jwt-auth.guard.ts
│ │ └── current-user.decorator.ts
│ └── health/
│ ├── health.module.ts
│ └── health.controller.ts
├── test/
├── package.json
├── tsconfig.json
├── tsconfig.build.json
├── nest-cli.json
├── Dockerfile
└── .env.example

The mobile client signs in with Supabase Auth and stores the resulting access token. Every API call sends it as Authorization: Bearer <token>.

// Example controller
@UseGuards(JwtAuthGuard)
@Get('me')
me(@CurrentUser() user: AuthenticatedUser) {
return user;
}

SupabaseJwtStrategy verifies the token’s signature using SUPABASE_JWT_SECRET (from your Supabase project’s API settings) and populates req.user with { id, email, role }.

Python workers are reachable at WORKERS_BASE_URL (defaults to http://workers:8000 inside docker-compose). Calls authenticate via the shared WORKERS_SHARED_SECRET header. A typed client lives under src/workers/ (to be added when we wire feature 0002 — AI ingest).

Terminal window
npm test # unit
npm run test:e2e # endpoint tests with supertest

Acceptance criteria from feature specs map 1:1 to e2e test names.

This service ships as a Docker image. Coolify builds from the repo using Dockerfile. See infra/coolify/README.md.