mbok_dev / README.md
Renecto's picture
feat: add /reset-password page
52279ac verified
metadata
title: mbok_dev
emoji: 🔐
colorFrom: blue
colorTo: green
sdk: docker
pinned: false

mbok_dev

Public gateway with Supabase authentication that dynamically loads the private ver20 application from DLPO/habadashi Space.

Features

  • Supabase email/password authentication
  • Cookie-based session management
  • Dynamic loading of private application code (source code not exposed in public repo)
  • Role-based access control via profiles table

Environment Variables (Set in HF Space Secrets)

  • SUPABASE_URL: Your Supabase project URL
  • SUPABASE_KEY: Your Supabase anon/service key
  • HF_TOKEN: Hugging Face token with access to private DLPO/habadashi Space
  • OPENAI_KEY: OpenAI API key (required by ver20)
  • CLIENTPOOL: Client pool configuration (required by ver20)

Architecture

  1. User visits public Space
  2. Bootstrap downloads ver20 from private DLPO/habadashi Space
  3. User logs in with Supabase credentials
  4. On successful login, ver20 Gradio app is mounted at /app/
  5. User profile and organization info loaded from profiles table

Startup Phase Logging

The application logs structured startup phases to help diagnose issues. Look for these phase markers in the logs:

Expected Startup Sequence

  1. [STARTUP_META] - Environment and configuration info
  2. [PHASE] bootstrap_start - Begin downloading private app
  3. [PHASE] bootstrap_end success=true - Private app downloaded
  4. [PHASE] supabase_init_start - Initialize Supabase client
  5. [PHASE] supabase_init_end success=true - Supabase ready
  6. [PHASE] fastapi_init_start/end - FastAPI app created
  7. [PHASE] create_ui_start/end - Login UI created
  8. [PHASE] import_ver20_start - Import ver20 app
  9. [PHASE] import_ver20_end success=true - Ver20 loaded
  10. [PHASE] mount_login_start/end - Login UI mounted
  11. [PHASE] mount_app_start/end - Ver20 app mounted
  12. [STARTUP_COMPLETE] - All phases complete

Health Check Endpoint

Once started, check the health endpoint:

curl https://DLPO-mbok-dev.hf.space/healthz

Expected response:

{
  "ok": true,
  "ver20_loaded": true,
  "private_app_dir": "./private_app"
}

Debugging Startup Failures

If the Space fails to start or restarts repeatedly:

  1. Check the last phase reached in logs
  2. Look for [ERROR] and [TRACEBACK] markers after the last phase
  3. Common failure points:
    • bootstrap_end success=false - HF_TOKEN missing or invalid
    • supabase_init_end success=false - SUPABASE_URL/KEY missing
    • import_ver20_end success=false - Ver20 app.py structure issue
    • No phases after mount_app_end - Port binding or health check issue

Request Logging

All HTTP requests are logged with:

  • [REQUEST] - Incoming request (method, path)
  • [RESPONSE] - Response status and duration

Example:

[REQUEST] method=GET path=/
[RESPONSE] method=GET path=/ status=307 duration=0.015s