This is the RADAR Self-Enrolment UI, a Next.js application that lets participants:
- Discover a study via a landing page.
- Create and manage their account (via Ory Kratos / Hydra).
- Enrol into a study defined in GitHub or local JSON files.
- Complete tasks and connect devices (SEP, pRMT, aRMT, Apple Health).
Study definitions are loaded from:
- GitHub: default (remote JSON definitions repo), and/or
- Local:
public/study/{studyId}(e.g.public/study/default).
If no remote/local definition exists for a project created in Management Portal, the app falls back to a default study (by default public/study/default) but keeps the requested studyId for routing and API calls.
To run this UI end-to-end you need:
- Node.js (v18+ recommended).
- Ory Kratos (identity) – running and reachable.
- Ory Hydra (OAuth2 / consent) – running and reachable.
- Management Portal (optional but recommended) – to create projects and have project metadata available.
- A GitHub repository containing study definitions (optional if you only use local
public/study/*).
Without Kratos and Hydra running and correctly configured, login/enrolment and token-based flows will fail with
fetch failed/ENOTFOUNDerrors.
You can set these in .env.local (for local dev) or your deployment environment.
BASEPATH(optional): Base path the app is served under (e.g./study).
Used to setNEXT_PUBLIC_BASEPATHat build time.
KRATOS_INTERNAL_URL(required)
Internal URL used by the server for Kratos REST calls, e.g.:http://localhost:4433(local)http://kratos:4433(Docker / k8s, matching your service name)
HYDRA_ADMIN_URL(required for consent/logout flows), e.g.:
HYDRA_ADMIN_URL=http://localhost:4445
NEXT_PUBLIC_HYDRA_PUBLIC_URL=http://localhost:4444Defined in app/_lib/github/config/github-config.ts and app/_lib/study/config.ts:
GITHUB_REPO_NAME(optional, defaultradar-self-enrolment-definitions)
GitHub repository name holding the definitions.GITHUB_REPO_BRANCH_NAME(optional, defaultmain)
Branch to read definitions from.GITHUB_AUTH_TOKEN(optional)
Used for authenticated GitHub API access if needed.STUDY_DEFINITION_REPOSITORY(optional, defaultGITHUB)"GITHUB"– load study protocol/pages from GitHub, with local/default fallback."LOCAL"– prefer localpublic/study/{studyId}protocol/pages, with default fallback.
DEFAULT_STUDY_ID(optional, defaultdefault)- The id of the local fallback study under
public/study/{DEFAULT_STUDY_ID}. - This study’s
protocol.jsonandlandingpage.jsonare used when a project exists in Management Portal but has no remote/local definitions yet. - The UI content comes from this default study, but the runtime protocol’s
studyIdandnameare set to the requested id.
- The id of the local fallback study under
MP_CONFIG_BASE_URL(optional, defaulthttp://localhost:8080/managementportal)
Base URL for Management Portal API.MP_PROJECTS_ENDPOINT(optional, defaultapi/public/projects)
Endpoint used to fetch the list of projects.
-
SEP (Study Extension Platform):
SEP_CLIENT_ID(defaultSEP)SEP_CLIENT_SECRETNEXT_PUBLIC_SEP_REDIRECT_URI
-
pRMT:
PRMT_CLIENT_ID(defaultpRMT)PRMT_CLIENT_SECRETNEXT_PUBLIC_PRMT_REDIRECT_URI
-
aRMT (RADAR active RMT / Apple Health, etc.):
ARMT_CLIENT_ID(defaultaRMT)NEXT_PUBLIC_ARMT_REDIRECT_URI
Used by email helpers (e.g. app/_lib/email/send.ts):
SMTP_HOSTSMTP_USERSMTP_PASSSMTP_PORT(default587)SMTP_FROM(sender address)
- Install dependencies
npm install- Create
.env.local
Minimal example for local development (adjust URLs to your stack):
KRATOS_INTERNAL_URL=http://localhost:4433
HYDRA_ADMIN_URL=http://localhost:4445
NEXT_PUBLIC_HYDRA_PUBLIC_URL=http://localhost:4444
MP_CONFIG_BASE_URL=http://localhost:8080/managementportal
MP_PROJECTS_ENDPOINT=api/public/projects
STUDY_DEFINITION_REPOSITORY=GITHUB
DEFAULT_STUDY_ID=default
GITHUB_REPO_NAME=radar-self-enrolment-definitions
GITHUB_REPO_BRANCH_NAME=main
BASEPATH=/study- Run the development server
npm run devThen open http://localhost:3000 (or http://localhost:3000/study if BASEPATH=/study) in your browser.
Ensure Kratos, Hydra, and (optionally) Management Portal are running and reachable at the URLs you configured above before testing login/enrolment.
- If a project exists in Management Portal but has no study definitions in GitHub or local
public/study/{studyId}, the app uses the default study frompublic/study/default(orDEFAULT_STUDY_ID) for:- Landing page content (e.g.
public/study/default/landingpage.json). - Protocol and tasks (e.g.
public/study/default/protocol.json).
- Landing page content (e.g.
- The UI content/theme comes from the default study, but:
protocol.studyIdis set to the requested id.protocol.nameis also set to the requested id (so titles/nav reflect the project id).
- The default landing page CTA (hero block with
href: "enrol") is automatically resolved to/{studyId}/enrol(and base path–aware, e.g./study/{studyId}/enrolwhenBASEPATHis set).
This allows you to create a new project in Management Portal and immediately:
- Visit
/{studyId}(or/study/{studyId}), - See a functional default landing page,
- Enrol and access
/[studyId]/portalwithout having created project-specific definitions yet.