north-scape/relayboard

Relayboard: accessible team boards with audited actions, dependency maps, and shared web/MCP use cases.

A remix template · 0 remixes · Remix north-scape/relayboard

scripts/preview.py

"""Local, ephemeral preview. Not copied into the production Docker image.
Run from repo root: PYTHONPATH=app .venv/bin/python scripts/preview.py
"""
import json
from datetime import date, timedelta
import uvicorn
from boards.application.use_cases import Boards
from boards.domain.model import Person
from boards.infrastructure.memory import MemoryBoards
from boards.main import create_app

class PreviewAI:
    def checklist(self,title): return ['Confirm the outcome and owner','Complete the work','Review and share the result']
    def summary(self,board): return 'Local preview only: this is a deterministic placeholder, not a live AI response. Review the cards, clear blockers, and confirm due dates.'
    def embeddings(self,texts): return [[1.0,float(len(t)%10+1)] for t in texts]

owner=Person('preview@example.test')
service=Boards(MemoryBoards(),PreviewAI())
board=service.create_board(owner,'Studio launch')['id']
service.add_member(owner,board,'sam@example.test','member')
service.add_member(owner,board,'reviewer@example.test','viewer')
a=service.add_card(owner,board,'A clearer home for team work','Doing','Make ownership visible and help everyone see the next step.','preview@example.test',date.today().isoformat(),['Product','Focus'])
b=service.add_card(owner,board,'Review the launch checklist','To do','Agree on what done looks like.','sam@example.test',(date.today()+timedelta(days=2)).isoformat(),['Launch'])
service.add_card(owner,board,'Collect early feedback','To do','Start with three teammates and write down what is confusing.',None,(date.today()-timedelta(days=1)).isoformat(),['Research'])
service.add_card(owner,board,'Set the direction','Done','One board, shared ownership, fewer status meetings.','preview@example.test',None,['Strategy'])
service.set_blockers(owner,b['id'],[a['id']],b['revision'])
service.update_checklist(owner,a['id'],[{'text':'Agree on the outcome','done':True},{'text':'Give each task an owner'},{'text':'Review the launch plan'}],a['revision'])
app=create_app(service)
@app.middleware('http')
async def preview_identity(request,call_next):
    request.scope['headers']=[(k,v) for k,v in request.scope['headers'] if k.lower()!=b'x-dodil-user']+[(b'x-dodil-user',json.dumps({'email':owner.email}).encode())]
    response=await call_next(request)
    response.headers['X-Relayboard-Preview']='ephemeral fake data and AI; no authentication'
    return response

if __name__=='__main__':
    print('PRIVATE LOCAL PREVIEW: fake data/AI, no authentication. Never expose publicly.')
    uvicorn.run(app,host='127.0.0.1',port=8080)