managarten/maerchenzauber/apps/backend
2025-11-26 01:31:12 +01:00
..
docs chore: initial commit - consolidate 4 projects into monorepo 2025-11-22 23:38:24 +01:00
migrations chore: initial commit - consolidate 4 projects into monorepo 2025-11-22 23:38:24 +01:00
scripts chore: initial commit - consolidate 4 projects into monorepo 2025-11-22 23:38:24 +01:00
src add mana core 2025-11-25 18:56:35 +01:00
test chore: initial commit - consolidate 4 projects into monorepo 2025-11-22 23:38:24 +01:00
.dockerignore chore: initial commit - consolidate 4 projects into monorepo 2025-11-22 23:38:24 +01:00
.env.example chore: initial commit - consolidate 4 projects into monorepo 2025-11-22 23:38:24 +01:00
.env.prod chore: initial commit - consolidate 4 projects into monorepo 2025-11-22 23:38:24 +01:00
.eslintrc.js chore: initial commit - consolidate 4 projects into monorepo 2025-11-22 23:38:24 +01:00
.gitignore chore: initial commit - consolidate 4 projects into monorepo 2025-11-22 23:38:24 +01:00
.npmrc chore: initial commit - consolidate 4 projects into monorepo 2025-11-22 23:38:24 +01:00
.prettierrc chore: initial commit - consolidate 4 projects into monorepo 2025-11-22 23:38:24 +01:00
Dockerfile chore: initial commit - consolidate 4 projects into monorepo 2025-11-22 23:38:24 +01:00
get-db-schema.sql chore: initial commit - consolidate 4 projects into monorepo 2025-11-22 23:38:24 +01:00
make-character-public.sql chore: initial commit - consolidate 4 projects into monorepo 2025-11-22 23:38:24 +01:00
nest-cli.json chore: initial commit - consolidate 4 projects into monorepo 2025-11-22 23:38:24 +01:00
NESTJS_CLS_SOLUTION.md chore: initial commit - consolidate 4 projects into monorepo 2025-11-22 23:38:24 +01:00
package.json make auth working 2025-11-26 01:31:12 +01:00
README.md chore: initial commit - consolidate 4 projects into monorepo 2025-11-22 23:38:24 +01:00
README_CHARACTER_UPDATE_FIX.md chore: initial commit - consolidate 4 projects into monorepo 2025-11-22 23:38:24 +01:00
RLS_IMPLEMENTATION_GUIDE.md chore: initial commit - consolidate 4 projects into monorepo 2025-11-22 23:38:24 +01:00
RUN_THIS_MIGRATION.sql chore: initial commit - consolidate 4 projects into monorepo 2025-11-22 23:38:24 +01:00
schema-diagram.dbml chore: initial commit - consolidate 4 projects into monorepo 2025-11-22 23:38:24 +01:00
schema-diagram.html chore: initial commit - consolidate 4 projects into monorepo 2025-11-22 23:38:24 +01:00
test-public-characters.sql chore: initial commit - consolidate 4 projects into monorepo 2025-11-22 23:38:24 +01:00
test-supabase-mcp.ts chore: initial commit - consolidate 4 projects into monorepo 2025-11-22 23:38:24 +01:00
test-trigger.sql chore: initial commit - consolidate 4 projects into monorepo 2025-11-22 23:38:24 +01:00
tsconfig.build.json chore: initial commit - consolidate 4 projects into monorepo 2025-11-22 23:38:24 +01:00
tsconfig.json chore: initial commit - consolidate 4 projects into monorepo 2025-11-22 23:38:24 +01:00

storyteller-backend

Authentication

This application uses Supabase for authentication, following a multi-Supabase architecture:

  1. A central auth Supabase instance ("mana") handles user authentication
  2. An application-specific Supabase instance ("maerchenzauber") handles application data
  3. The NestJS backend serves as a token exchange middleware and application server

Setup Requirements

You need to set up two Supabase instances:

  1. mana - Central authentication service
  2. maerchenzauber - Application-specific database

See auth.md for detailed setup instructions and database schema.

Environment Variables

Configure the following environment variables (see .env.example):

  • MANA_SUPABASE_URL - URL of the central auth Supabase instance
  • MANA_SUPABASE_ANON_KEY - Anon key for the central auth Supabase
  • MANA_JWT_SECRET - JWT secret for verifying tokens from the central auth
  • MAERCHENZAUBER_SUPABASE_URL - URL of the application Supabase instance
  • MAERCHENZAUBER_SUPABASE_ANON_KEY - Anon key for the application Supabase
  • MAERCHENZAUBER_JWT_SECRET - JWT secret for signing tokens for the application Supabase
  • APP_ID - Application identifier (default: "8d2f5ddb-e251-4b3b-8802-84022a7ac77f")

Build and Deploy

gcloud config set project storyteller-a1fde

build it and deploy it to cloud run

gcloud builds submit --tag gcr.io/storyteller-a1fde/storyteller-api:v1.5.7

after sucesfull build it shows something like this

gcr.io/storyteller-a1fde/storyteller-api:v1.5.7

then run

gcloud run deploy storyteller-api
--image gcr.io/storyteller-a1fde/storyteller-api:v1.5.7
--region=us-central1
--platform=managed
--allow-unauthenticated

currently deployed: gcr.io/storyteller-a1fde/storyteller-api:v1.5.7

Testing Request

curl -X POST http://localhost:3000/story
-H "Content-Type: application/json"
-d '{ "characters": ["7d800d18-dcb4-4a48-addf-c6a6a88dd7ed"], "storyDescription": "A fun adventure story about friendship and courage", "illustratorId": "QsqH9Cyds24rRbAYf6zT", "authorId": "fKMNQsgKojozOHTnjAbs" }'