How samflipppy/rubric works
1. Repository shape: two deployable surfaces. This repo is split into a web frontend and functions backend, deployed together through Firebase Hosting + Cloud Functions Gen 2. The product is a linear PR-review app, not a generic CRUD system.
2. Frontend boundary. web/ is a React 19 + Vite + TypeScript app styled with Tailwind. It uses URL params and local React state for navigation/state instead of a router or global store, which keeps the app centered on a single review session rather than persistent user accounts.
3. Frontend screen flow. The UI is organized around five pages: Home, Brief, Review, Ask, and Decide. That maps directly to the product’s four-phase review flow plus the landing page. Navigation is intentionally linear: orient, answer questions, optionally ask follow-ups, then make a final decision.
4. Frontend component roles. QuestionCard, DiffView, TierBadge, ProgressBar, and LoadingSequence make up the core review experience. The important architectural point is that the UI renders AI-produced questions alongside code slices, so the frontend is not just displaying text; it is presenting evidence and reviewer judgments side by side.
5. Frontend data plumbing. web/src/lib/api.ts is the client boundary to the backend. github.ts parses PR URLs / repo metadata, nav.ts handles screen transitions, and audit.ts assembles the final review transcript for copy-out. This means the browser holds the session state and the review artifact; there is no server-side persistence.
6. Backend boundary. functions/ is a Genkit-based Firebase Functions service running on Node 20. The backend is organized around flows rather than ad hoc endpoints: generateBrief, generateRubric, and answerPRQuestion, plus a plain listPRs HTTPS entry point for loading open PRs on the home screen.
7. Backend orchestration model. Each flow uses ai.defineFlow with Zod schemas for input/output validation. That implies strict typed boundaries between the web app, the orchestration layer, and the model outputs. The backend is designed to be deterministic in structure even though it calls an LLM for content generation.
8. LLM and model configuration. functions/src/genkit.ts centralizes the Genkit instance and the model constant, using Vertex AI Gemini 2.5 Flash-lite. The model choice is treated as infrastructure, not scattered configuration, which makes the model swap a single-point change.
9. GitHub as the source of truth. functions/src/tools/github.ts encapsulates GitHub REST API access and diff/PR fetching. The system reviews public PRs without auth by default, with optional GITHUB_TOKEN support. The raw GitHub diff is the authoritative input that all AI outputs must be checked against.
10. Fabrication guard as a core boundary. The key trust mechanism is that embedded code snippets in rubric questions and chat answers are substring-verified against the real GitHub diff after generation. Anything not present in the diff is dropped before reaching the reviewer. Architecturally, this turns the backend into a generate-then-verify pipeline rather than “trust the model” text generation.
11. Schema layer. functions/src/schemas/ contains separate Zod models for PR metadata, brief output, rubric output, review decisions, and ask/chat payloads. This makes the content pipeline explicit: PR data in, structured brief/rubric/question answers out, with the review transcript assembled from validated pieces.
12. End-to-end data flow. A reviewer opens a PR in the browser, the frontend requests PR data and review artifacts from Firebase Functions, the backend fetches GitHub diff context, Genkit generates a brief and rubric, the UI presents questions and evidence, optional follow-up answers are generated with the same verification guard, and the final decision is kept client-side for copy-to-clipboard review text.
13. What is deliberately absent. There is no Firestore, no auth, no multi-user collaboration, no posting comments back to GitHub, and no streaming or analytics. That means the architecture is optimized for a single-session demo-style review workflow with minimal backend state and a strong trust boundary around generated evidence.
14. Deployment topology. The frontend is served from Firebase Hosting, and the backend functions live in the same Firebase project (rubric-216). Local development mirrors the split: the frontend points at the deployed functions URL, while backend flows can be tested directly against live GitHub PRs.
Main entry points: App.tsx Web app · Review.tsx Review · generateBrief.ts Brief flow · generateRubric.ts Rubric flow
Components 26
Web app
React/Vite frontend for the linear review session
- Web app · React 19 single-session PR review interface
web/src/App.tsx - Home · Entry point for opening a PR review session
web/src/pages/Home.tsx - Brief · Shows the generated summary before the detailed review
web/src/pages/Brief.tsx - Review · Primary screen for questions, evidence, and judgments
web/src/pages/Review.tsx - Ask · Collects and presents follow-up questions or answers
web/src/pages/Ask.tsx - Decide · Captures the final review decision and copyable transcript
web/src/pages/Decide.tsx - Question card · Renders AI questions with evidence and reviewer response space
web/src/components/QuestionCard.tsx - Diff view · Shows PR code slices alongside generated review content
web/src/components/DiffView.tsx - Progress · Shows where the reviewer is in the linear flow
web/src/components/ProgressBar.tsx - Tier badge · Displays review severity or confidence tier
web/src/components/TierBadge.tsx - Loading · Animated loading state during generation and fetches
web/src/components/LoadingSequence.tsx - API client · Frontend calls to Firebase Functions and review data loading
web/src/lib/api.ts - Nav state · URL-param and local state transitions between review screens
web/src/lib/nav.ts - Audit builder · Builds the final review transcript for copy-out
web/src/lib/audit.ts - GitHub parser · Parses PR URLs and repo metadata on the client
web/src/lib/github.ts
Functions
Genkit-backed Firebase Functions orchestration
- Functions API · Cloud Functions Gen 2 entrypoints exposed to the web app
functions/src/index.ts - Genkit core · Central Genkit instance and model selection
functions/src/genkit.ts - GitHub tools · GitHub REST access and diff retrieval as source of truth
functions/src/tools/github.ts - AI flows · Structured generation flows for brief, rubric, and follow-up answers
functions/src/flows/generateBrief.ts - Brief flow · Generates the concise PR brief from GitHub context
functions/src/flows/generateBrief.ts - Rubric flow · Generates structured review questions and tiers
functions/src/flows/generateRubric.ts - Answer flow · Generates follow-up answers under the same verification rules
functions/src/flows/answerPRQuestion.ts
Shared flow
Data contracts and integration boundaries
- Firebase Hosting · Serves the web app in Firebase project rubic-216
firebase.json - Schemas · Structured input/output models for PRs, briefs, rubrics, reviews, and asks
functions/src/schemas/index.ts - Review schemas · Decision and transcript payload models
functions/src/schemas/review.ts - PR schemas · Pull request metadata and diff context models
functions/src/schemas/pr.ts
Connections 32
- Firebase Hosting → Web app: serves · Firebase Hosting delivers the frontend bundle
- Web app → Home: navigates · Session begins on the landing page
- Web app → Brief: navigates · Moves into the brief stage
- Web app → Review: navigates · Moves into the main review stage
- Web app → Ask: navigates · Moves into the follow-up question stage
- Web app → Decide: navigates · Moves into the final decision stage
- Review → Question card: renders · Shows AI questions and reviewer prompts
- Review → Diff view: renders · Displays supporting code evidence beside the question
- Review → Progress: shows · Tracks linear progress through the session
- Review → Tier badge: shows · Marks review tier or priority
- Web app → Loading: uses · Displays generation/loading states
- Nav state → Web app: drives · Controls screen transitions from URL and local state
- GitHub parser → API client: feeds · Parsed PR info is used to request backend data
- Audit builder → Decide: feeds · Assembles the final transcript shown for copy-out
- API client → Functions API: calls · Frontend requests PR data and generated artifacts
- Functions API → Brief flow: invokes · Entrypoint exposes brief generation
- Functions API → Rubric flow: invokes · Entrypoint exposes rubric generation
- Functions API → Answer flow: invokes · Entrypoint exposes follow-up answer generation
- Brief flow → Genkit core: uses · Flow runs through the centralized Genkit runtime
- Rubric flow → Genkit core: uses · Flow runs through the centralized Genkit runtime
- Answer flow → Genkit core: uses · Flow runs through the centralized Genkit runtime
- Brief flow → GitHub tools: reads · Uses GitHub diff and PR context as input
- Rubric flow → GitHub tools: reads · Uses GitHub diff and PR context as input
- Answer flow → GitHub tools: reads · Uses GitHub diff and PR context as input
- Brief flow → Schemas: validates · Structured brief inputs and outputs are schema-checked
- Rubric flow → Schemas: validates · Structured rubric inputs and outputs are schema-checked
- Answer flow → Schemas: validates · Structured follow-up inputs and outputs are schema-checked
- Schemas → Review schemas: includes · Review decision and transcript contracts
- Schemas → PR schemas: includes · PR metadata and context contracts
- Rubric flow → Question card: produces · Generated questions feed the review UI
- Brief flow → Brief: produces · Generated brief feeds the brief screen
- Answer flow → Ask: produces · Follow-up answers feed the ask screen