AI-powered legal information assistant focused on Canadian immigration law.
Disclaimer: IMMCAD is an informational tool and not legal advice. It does not create a lawyer-client relationship. Users should consult a licensed immigration lawyer or RCIC for legal advice.
IMMCAD starts from the LawGlance architecture (RAG + legal documents + chat interface) and adapts it to the Canadian immigration context.
The goal is to help users quickly understand:
- Eligibility pathways (study, work, PR, citizenship)
- Official process steps
- Required documents and timelines
- Common policy constraints and risks
The current implementation is converging on a single production runtime:
- Next.js chat UI in
frontend-web(production path) - Python API backend in
src/immcad_api(production path) - Document intake/readiness/package endpoints are available via frontend
/api/documents/*proxy routes backed by backendsrc/immcad_api/api/routes/documents.py - Streamlit UI in
app.pyis now a legacy dev-only thin API client to/api/chat - Legacy local-RAG modules are archived under
legacy/local_rag/for compatibility and historical evaluation workflows - CI quality gates include ingestion smoke, dependency review, jurisdiction suite, and repository hygiene
- Legal corpus completeness
- Complete IRPA/IRPR/IRCC source coverage and enforce freshness cadence.
- Grounding enforcement
- Add runtime citation-grounding verification beyond template-level constraints.
- Product localization
- Deliver bilingual-ready user journeys (English now, French next).
- Legacy retirement
- Fully decommission legacy local-RAG modules once all evaluation dependencies are migrated.
- Immigration and Refugee Protection Act (IRPA)
- Immigration and Refugee Protection Regulations (IRPR)
- Citizenship Act and related regulations (as applicable)
- IRCC official pages and Program Delivery Instructions
- Ministerial Instructions relevant to Express Entry and category-based selection
- Federal Court immigration decisions (selected, high-impact)
- IRB policy/process references where publicly available
- Provincial Nominee Program (PNP) official program pages
- Rename/rebrand project artifacts to IMMCAD
- Replace README and legal disclaimers
- Create a dedicated data ingestion folder for Canadian sources
- Define document metadata schema:
jurisdiction,source_type,program,effective_date,url
- Build ingestion pipeline for official sources (PDF + HTML)
- Normalize text and chunk with legal-structure awareness
- Rebuild Chroma index from Canadian corpus only
- Remove or archive legacy vector database artifacts
- Rewrite
SYSTEM_PROMPTandQA_PROMPTfor Canadian immigration domain - Add strict answer format:
- Plain-language summary
- Applicable rule/policy
- Source citation(s)
- Confidence + when to seek licensed counsel
- Tune retriever thresholds and context window strategy
- Create evaluation dataset of real immigration questions
- Measure:
- Citation coverage
- Groundedness
- Hallucination rate
- Refusal correctness (out-of-scope handling)
- Add regression tests for prompts and retrieval behavior
- Add jurisdiction-aware UX copy and legal notices
- Add bilingual-ready UI structure (English/French)
- Add observability (request logs, failure analytics)
- Prepare private beta release with feedback loop
- Keep
src/immcad_api/policy/prompts.pyas the single canonical prompt source. - Finalize Canadian source coverage and run ingestion refresh + smoke validation in CI on schedule.
- Implement grounding-verification checks in response assembly before delivery.
- Add bilingual-ready locale handling to production UI/API contracts (
en-CA,fr-CA) with coverage tests. - Remove archive references once
legacy/local_rag/is fully retired.
- Source inventory and version control (effective dates)
- Corpus quality review and deduplication
- Citation policy definition
- Ingestion scripts + chunking strategy
- Metadata filtering and retriever tuning
- Evaluation pipeline and benchmark dataset
- Disclaimer placement and user consent flows
- Out-of-scope response policy
- Bilingual content strategy (EN now, FR next)
- Python 3.11+
uv- Node.js 20+
- OpenAI API key
- Redis (recommended)
git clone <your-private-repo-url> # obtain this URL from your project admin or internal repository portal
cd IMMCAD
uv syncAccess note: this repository is private; request access through your project admin before cloning.
Create .env:
OPENAI_API_KEY=your-api-key-hereRun the production path locally:
Terminal 1 (API):
make api-devTerminal 2 (frontend):
make frontend-install
make frontend-devApp URLs:
Frontend: http://127.0.0.1:3000
API: http://127.0.0.1:8000Run API service scaffold:
uv run uvicorn immcad_api.main:app --app-dir src --reload --port 8000Health check:
http://127.0.0.1:8000/healthzInstall frontend dependencies:
make frontend-installRun frontend:
make frontend-devFrontend URL:
http://127.0.0.1:3000Create frontend-web/.env.local with:
NEXT_PUBLIC_IMMCAD_API_BASE_URL=/api
IMMCAD_API_BASE_URL=http://127.0.0.1:8000
IMMCAD_API_BEARER_TOKEN=your-api-bearer-tokenProduction safety notes:
NEXT_PUBLIC_IMMCAD_API_BASE_URLshould remain/apiso browser calls stay on the same origin.IMMCAD_API_BASE_URLmust usehttps://inNODE_ENV=production.- Keep
IMMCAD_API_BEARER_TOKENserver-only; do not publish it viaNEXT_PUBLIC_*. - If using
git-secretfor encrypted repo-stored env bundles, followdocs/release/git-secret-runbook.mdand keep production runtime secrets in GitHub/Cloudflare secret managers.
Use this only for local prototyping or migration troubleshooting. It is not the production runtime path.
uv run streamlit run app.pyLegacy UI URL:
http://127.0.0.1:8501Generate ingestion execution report from the Canada source registry:
make ingestion-runThis runner now keeps a checkpoint file (artifacts/ingestion/checkpoints.json) and uses
ETag / Last-Modified conditional requests to mark unchanged sources as not_modified.
Generate jurisdictional readiness scoring report (JSON + Markdown):
make jurisdiction-evalRun behavior-focused jurisdictional suite (policy refusal + citation behavior):
make jurisdiction-suiteOutputs are written under artifacts/ (gitignored) and uploaded by CI in quality-gates as jurisdiction-eval-report.
Run documentation quality audit (link/style/content/freshness checks):
make docs-auditApply safe documentation auto-fixes (TOC refresh):
make docs-fixReports are generated to:
artifacts/docs/doc-maintenance-report.md
artifacts/docs/doc-maintenance-report.jsonRalph is now wired in this repo under scripts/ralph/.
Run with Codex (default):
make ralph-runRun with Codex (explicit target):
make ralph-run-codexRun with Amp:
make ralph-run-ampRun with Claude Code (optional):
make ralph-run-claudePreflight validation (no iterations):
bash scripts/ralph/ralph.sh --tool codex --checkCheck story progress:
make ralph-statusRalph execution state is in:
scripts/ralph/prd.jsonscripts/ralph/progress.txt
IMMCAD is considered Canada-ready when:
- All production retrieval sources are Canadian immigration sources
- Every answer includes citation(s) or a safe refusal
- Hallucination rate is within agreed threshold on benchmark set
- Legal disclaimer and escalation guidance are consistently applied
- Beta users can complete top immigration question flows with useful outcomes
This project is licensed under the Apache License, Version 2.0.
Maintainers may relicense in the future; see LICENSE.md and project governance for updates.