Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

PoSeeReview

PoSeeReview turns unusual restaurant reviews into AI-generated one- or two-panel comic strips and publishes ranked results to a global Hall of Fame leaderboard. The solution runs as a Blazor WebAssembly frontend and .NET 10 API in a single Azure App Service, backed by Azure Table and Blob Storage, Azure OpenAI, and Google Gemini for narrative and image generation.


Product Requirements Document (PRD)

Vision

Every neighborhood has restaurants with bizarre, unhinged, or strangely poetic Google Maps reviews. PoSeeReview mines that raw material, distills the strangest signal from real reviews, and turns it into shareable one- or two-panel comic strips. The output is ranked on a global leaderboard by a computed "strangeness score" (0–100), creating a continuously refreshing artifact of collective absurdity.

The product has a single core loop: open app → share location → browse nearby restaurants → tap one → watch the AI pipeline run → receive a personalized comic strip → share it or check your restaurant's global rank. This loop must complete in under 12 seconds on a cold miss, and under 500ms on a cache hit.

Problem

Restaurant review platforms index enormous volumes of user-generated content that is simultaneously hyper-local and culturally rich. Yet none of it is presented in a format optimized for entertainment, sharing, or rediscovery. Reviews are read once and forgotten. PoSeeReview recovers this latent value and transforms it into a new, ephemeral medium — the comic strip — that is inherently shareable and globally comparable.

The problem is not a lack of content; it is a lack of a lens that makes that content arresting. PoSeeReview is that lens.

Target Users

Primary persona — Curious Local: A smartphone user who opens the app while waiting for food, while exploring a new neighborhood, or while bored. They want to be entertained by something real and local. They are not looking for utility — they are looking for surprise. The friction to the first surprise must be near-zero. No registration, no onboarding form, no paywall.

Secondary persona — Restaurant Obsessive: A food blogger, local guide contributor, or review-reading enthusiast who already consumes review content as entertainment. They engage deeply with the strangeness score and leaderboard, returning to see if their favorite weird restaurant has risen in global rank.

Tertiary persona — Content Creator: A person who shares the comic to social media. They need the share action to work with one tap and to produce a clean, standalone image.

Core Features

1. Proximity-first discovery. The user grants location access and immediately sees the restaurants within 5 km, nearest first. One search box takes a place name or address for anyone who would rather not share a location; there are no category filters — the intent is serendipity, not utility.

2. One-tap comic generation. A single tap on a restaurant card initiates the AI pipeline. The loading state is presented as numbered steps (Fetching reviews → Analyzing strangeness → Writing narrative → Generating artwork → Composing strip) so users understand the system is working rather than broken. The generation target is under 10 seconds.

3. Strangeness scoring. Azure OpenAI (gpt-5.4-nano, temperature 0.3) reads up to five reviews, lowest-rated first, and returns three 0–10 ratings (absurdity, specificity, story potential), a narrative and a 1–2 panel script; the code computes the 0–100 score. Every panel cites the review numbers it draws on (reviewIds); citations outside the reviews sent are dropped. The verdict is cached per place in PoSeeReviewAnalyses, keyed by a hash of the reviews and Comics:PromptVersion, so a redraw keeps its score and a "too ordinary" place is never re-scored for nothing. The system message is kept above Azure's 1024-token prompt-cache threshold (measured: 1024 of ~1265 input tokens cached). Places that score below Comics:MinimumStrangenessScore get a 422 and a refund.

4. Comic image generation — draft, then remaster. Every comic is drawn first by the cheap painter (Ai:ImageProvider, default AzureOpenAI = gpt-image-1-mini at low quality, ~$0.005). ComicRemasterService redraws the live board's top Remaster:TopN with the premium painter (Ai:RemasterProvider, default Gemini = gemini-2.5-flash-image, ~$0.04) from the same scenes and captions, at most Remaster:MaxPerRun every Remaster:IntervalMinutes (Remaster:Enabled); the score never moves, the blob is overwritten in place so board and archive rows follow, and a refused or failed remaster is recorded and never retried. ComicTextOverlayService draws the captions. A sampled vision check (ImageQa:SampleRate, ImageQa:Deployment) scores panel count, stray lettering, scene match and character consistency per image model (Comics.ImageQa.*) — it measures, never redraws. Ai:ImageProvider=Local (Development only) draws through a local OpenAI-compatible server (LocalImage:*) so image-prompt work costs nothing. appsettings.Development.json draws with Black Forest Labs FLUX.1-Kontext-pro on the same Azure resource (AzureOpenAI:ImageDeployment + AzureOpenAI:BlackForestLabsRoute, which switches to Azure's /providers/blackforestlabs/v1/{route} API): the subscription has no gpt-image quota yet. Clear both once it does.

4a. Weirdness forecast and pre-draw. GET /api/comics/cached also returns forecasts — the cached score for undrawn places — and forecastFloor; discovery greys out places already known to be too ordinary. Nothing is computed for the probe. Each forecast sighting and each comic-page miss counts as demand; ComicPredrawService draws, once a day, up to Predraw:MaxPerRun places scoring at least Predraw:MinScore with Predraw:MinDemand sightings and no live comic, zeroing their demand before each attempt so a failure is not retried nightly. Remaster, pre-draw and image QA all spend money unasked, so appsettings.json turns them off and only appsettings.Production.json turns them on — a new environment, a laptop or a test host spends nothing in the background.

1a. Map-first discovery. Results open on a map (List is the remembered alternative; devices without WebGL fall back to the list on their own). Pan or zoom and a Search this area button re-runs nearby search at the map's centre without moving the camera. Once results are showing, the search bar turns compact and carries the query (edit it and search again), a clear button, the count and the List / Map switch; its Near me locates the user, draws a "you are here" dot and, with the map up, searches around it without leaving the map. On a phone the three nearest drawable places sit under the map as cards ("Nearest to you", or "In this area" for a panned or typed search, where distances are hidden because they are not from the user) with a link to the full list; from 64rem the map and every drawable card sit side by side, the cards scrolling beside the map, and a tapped pin's card moves to the top. The landing pairs the search with what is already drawn — the live top five and this browser's recent comics — in two columns on a desktop. The live Hall of Fame shows the current top ten; a single "☰ Right now" button opens a drawer (side panel on a desktop, bottom sheet on a phone) to switch to the weekly archive (?view=week) or the board on a map. Pins are coloured and numbered by the live comic's score (GET /api/comics/cached returns scores alongside cachedPlaceIds); an undrawn place is a small dashed pin. A pin tap only selects — the place's usual card or row appears under the map, so opening or paying for a comic is still that card's own button. Leaderboard rows carry latitude / longitude from the comic that wrote them; rows older than that have none and the board's toggle stays hidden until some do.

5. Global leaderboard. Every generated comic is projected to a regional leaderboard (PoSeeReviewLeaderboard table) using an inverted RowKey pattern for zero-cost descending sort. The leaderboard is queryable by ISO region code (e.g., US, GB, US-CA-SF) and returns the top N entries sorted by strangeness descending. The live board only lists places whose comic would open for free right now — unexpired and drawn under the current Comics:PromptVersion (ILiveComicLookup, owned by Comics) — so a row never leads to the paid Generate prompt; when a comic expires the cleanup also deletes its live board row, keeping the blob for the weekly archive.

6. Content takedown. Restaurant owners or legal representatives can request removal of a specific comic via POST /api/takedowns authenticated with an X-Api-Key header. The endpoint suppresses the place first (so a partial failure cannot let it be redrawn), then erases the comic row, its blob, the live board row and the Hall of Fame entry. Telemetry events are emitted for moderation audit trails.

6a. AI-assisted moderation. The pre-publish screen layers Azure AI Content Safety (Moderation:ContentSafetyEndpoint, the shared AI Services resource and the scorer's key) under the lexical word lists; it fails open to the lexical verdict. POST /api/moderation/{placeId}/triage (Moderator role) asks Moderation:TriageDeployment (gpt-5.4-mini) to compare the live comic with its reviews and reports and suggest keep / hide / remove with reasons; the advice is stored beside the queue row and shown on /moderation. It never changes state.

6b. As uncensored as possible, and never silently. Reviews reach the scorer as written (Comics:ReviewFilter = None; Mask bleeps profanity, Strict also drops reviews with explicit terms). Image scenes are drawn as written (Comics:BluntImagePrompts = false; on, filter-tripping words become "unusual" and each swap is reported). Gemini's adjustable safety settings are BLOCK_NONE. The lexical screen hard-blocks only child sexual content, bestiality and suicide instructions; Azure AI Content Safety blocks only at severity 6 and flags from 4. Everything that hides, blocks, refuses or softens a comic goes on the moderation queue and to the owner's phone via ntfy (Moderation:AlertNtfyTopic — Key Vault PoSeeReview--Moderation--AlertNtfyTopic; Moderation:AlertNtfyServer, default https://ntfy.sh; Moderation:AlertLinkBase makes each alert open the comic). A blocked comic tells the user which screen category refused it. Limits outside the app — the image models' own non-adjustable checks and the Azure OpenAI deployment's content filter policy — still apply; their refusals are shown and alerted, never hidden.

6c. Audio comic. "Listen in" under a comic records a conversation overheard at the place on first tap (~10s, about 3¢) and replays the cached recording after that: AzureOpenAI:AudioScriptDeployment (gpt-5.4-mini) writes a make-believe visit, overheard: no narrator and not a retelling of the comic, just two or three archetypes (a regular, the server, …) living one invented visit stitched from details across up to ten reviews — Google's five "most relevant" plus its five newest, fetched for this only from the legacy Place Details API (reviews_sort=newest, ~2¢) — with the words written fresh (labelled a dramatization; never real names, never quotes), and AzureOpenAI:TtsDeployment (gpt-4o-mini-tts) voices each line with its own acting direction. Swear words are cut out and replaced with a synthesized bleep tone. The WAV and its timed script are cached per comic id in the comics container (audio/{comicId}.v4.wav|.json; the version bumps with the prompt or the mix). Every speaker is normalised to one loudness (-20 dBFS gated RMS, soft-limited peaks), the bleep at the same level; captions and the speaking panel follow playback. GET /api/comics/{placeId}/audio (cached script or 404), POST (records it; on the comics-post limiter), GET …/audio/file (the WAV, range requests). A voice or script refusal is a 422 with its reason and an owner alert.

7. Ephemeral by design. Comics expire after 7 days (Comics:CacheDurationDays). The ExpiredComicCleanupService runs on a 30-minute background loop and batch-purges expired rows and blobs (batch size 25, configurable 5–200). This keeps storage costs bounded and the leaderboard fresh. Users who want to regenerate a comic can force-refresh at any time.

Non-Goals (v1)

  • No server-side user profiles: sign-in is a session cookie, and "My comics" history lives only in the browser.
  • No automated moderation decisions: the AI triage advises, a moderator acts.
  • No real-time collaborative features beyond optimistic concurrency on the same restaurant.
  • The browser (Blazor WASM) is the primary delivery target. The native companion app (src/PoSeeReview.Mobile, below) is not in PoSeeReview.slnx and is not built or shipped by CI.
  • No paid tier or premium features.

Technical Constraints

  • Latency target: p50 cold-miss generation < 10s. p95 cache hit < 500ms.
  • Caching: Comics cache for 7 days and restaurant data for 24 hours in Azure Table Storage. SAS URLs are issued for 8 days, outliving the comic, to avoid stale URL errors within the cache window.
  • Rate limiting: The comic generation stream (POST /api/comics/{placeId}/stream) has its own comics-post policy, 3 per minute per signed-in user, on top of the 240/min global window per IP, plus a daily per-user and app-wide budget.
  • Bot protection: All requests are evaluated by UserAgentValidationMiddleware. Requests with missing or blocked User-Agent patterns are rejected at 400 before hitting the application layer.
  • Sign-in required by default. Every endpoint needs a session (Microsoft sign-in, or the guest cookie outside Production) unless it opts out: /auth, /health*, /api/diag (the JSON behind the public /diag status page), /s/{code}, /share/{placeId}/card.png, the SPA shell, and POST /api/takedowns, which carries its own X-Api-Key.
  • Security: All secrets are stored in Azure Key Vault and resolved at startup via Managed Identity. No credentials appear in appsettings.json or environment variables in production.

Success Metrics

  • Time-to-first-comic for a new user < 30 seconds end-to-end.
  • Cache hit rate > 40% for restaurants in active urban areas.
  • Zero 5xx errors due to unhandled exceptions (all paths covered by GlobalExceptionHandler).
  • Leaderboard latency < 200ms p99.
  • Takedown SLA < 5 minutes from submission to artifact removal.

Architecture Overview

Layer Technologies
Edge Delivery Browser (Blazor WASM), Azure App Service host
Compute ASP.NET Core 10 API, ExpiredComicCleanupService, ComicRemasterService, ComicPredrawService, ComicImageQaService
Data Azure Table Storage, Azure Blob Storage, Azure Key Vault
External AI Azure OpenAI (gpt-5.4-nano scorer and image QA, gpt-5.4-mini moderation triage, gpt-image-1-mini drafts), Azure AI Content Safety, Google Gemini (gemini-2.5-flash-image remasters), Google Maps Places. Local: Ollama (chat), any OpenAI-compatible image server (Development)
Observability Application Insights, OpenTelemetry, Serilog
Imaging SkiaSharp (caption overlay, lossy WebP, share cards); Bangers and DM Sans embedded
Components Radzen.Blazor 12.2.0 on every page (owner decision 2026-11-21): buttons, text boxes, slider, radio list, dialogs and confirms, the /moderation DataGrid. Its material-base theme is @imported into the vendor cascade layer by css/radzen.css (the first stylesheet loaded, before any app CSS) and re-coloured from the app's tokens by the --rz-* bridge; controls that keep the app's look carry class sr-plain (the plain layer reverts Radzen's styling so .btn, .chip-toggle and friends draw them). The trimmed assembly and the framework pieces it pulls in add ~0.97 MB brotli to the boot download
Graphics & audio One hand-written WebGL2 backdrop shader on a shared rAF loop with a frame-budget tier (off/lite/full, full by default — lite is the calm one: the ink reveal and glass only, while the stamp, confetti, springy score, board and pin animations wait for full); an optional WebGPU compute particle layer (ink motes); 2D-canvas confetti and ink splats; Web Audio synthesis, no audio assets. Every extra (sound, haptics, map sounds, ink motes) is on by default at full volume and can be switched off on /settings
Maps MapLibre GL JS 5.24.0 (UMD, jsDelivr, SRI-pinned, loaded only when a map opens) over OpenFreeMap vector tiles — no key, no per-load billing
Alerting infra/alerts.bicep: Http5xx, AI spend, in-band generation failures, fail-open guards, image refusals, moderation queue → email action group
Quality gates axe-core (Deque.AxeCore.Playwright 4.13.0) in the E2E UI suite; Lighthouse CI (@lhci/cli 0.15.1, scripts/lighthouserc.json) in the post-deploy smoke (scripts/post-deploy-smoke.ps1)
Version v{YYMMDD} from the HEAD commit's UTC date (BuildVersion, stamped by Directory.Build.props), shown bottom-right on every page (.po-version) and as Version on /diag (version in /api/diag)
Mobile companion src/PoSeeReview.Mobile — .NET MAUI (XAML) for Android/iOS, built by hand (dotnet build src/PoSeeReview.Mobile -f net10.0-android). Native GPS with a place-name fallback; a native map with score pins (Apple Maps; Google Maps on Android only when built with POSEEREVIEW_ANDROID_MAPS_KEY, else list-only); offline copies of the last search, the board and the last 30 comics (never past ExpiresAt, evicted on 404/451); draw a comic over the SSE stream with a haptic per step and on the reveal (Settings switch); Share sends the /s/{code} short link. App Links / Universal Links open /comic/* and /s/* in the app; without it they open the web page. The API serves /.well-known/assetlinks.json and /.well-known/apple-app-site-association from MobileApp:AndroidPackage, MobileApp:AndroidCertSha256 (release keystore SHA-256 fingerprints) and MobileApp:AppleAppId (TEAMID.com.punkouter.poseereview); each answers 404 while unset. /.well-known/* skips the User-Agent check so Google's and Apple's verifiers can read them. Auth: Entra bearer token (AddJwtBearer) or, in Debug builds only, X-Fake-User against a Dev/Test API. Dev loop: Android emulator → http://10.0.2.2:5000; USB phone → adb reverse tcp:5000 tcp:5000, then http://localhost:5000 in Settings; test a link with adb shell am start -a android.intent.action.VIEW -d poseereview://comic/<placeId>
Shell & look The Po web standard: wwwroot/css/po-tokens.css (this repo's copy of the Po conventions; Inter + Space Grotesk self-hosted, one indigo accent, light/dark follow the device — no theme switch), one .po-header on every page (name upper-left; email or Sign in, then the settings gear upper-right), /diag (System status: API, Data, Services), and Tab with nothing focused opens /po-dev.html (js/po-devwindow.js)

Documentation

  • AGENTS.md — the Po web app standard this repo follows, plus the working rules.
  • docs/development.md — commands, test tiers, architecture, configuration and conventions.
  • infra/README.md — Azure resources and how they are applied.
  • SCREENSHOTS/ — before/after pages of UI changes (YYMMDD-feature-name.html + one annotated .png), made by pwsh scripts/screenshots.ps1 -Feature <name>. Git-ignored: local review aids, not committed.

Refactor Blast Radius Assessment

Refactor: Replace direct provider clients with a single orchestration service

  • Purpose: centralize Google Maps, LLM, and image-model execution with explicit retries, fallback policy, and correlation IDs.
  • Blast radius:
    • API layer: changes to service registration and endpoint call paths.
    • Infrastructure layer: adapter wrappers around existing provider SDK clients.
    • Telemetry: metric names and traces may shift to orchestration-centric spans.
    • Tests: unit/integration tests mocking provider dependencies must be updated.
    • Downstream dependencies: provider quota behavior and timeout strategy become coupled to orchestrator policy.

Refactor: Introduce projection worker for leaderboard materialization

  • Purpose: decouple ranking updates from request path to reduce p95 latency.
  • Blast radius:
    • API layer: request handlers move from synchronous projection writes to enqueue-only behavior.
    • Data layer: adds queue/table checkpoint records and idempotency keys.
    • UI layer: leaderboard eventual-consistency window must be communicated.
    • Operations: requires new health checks and backlog alerts.
    • Downstream dependencies: consumers reading immediate ranks may observe delayed updates.

Refactor: Add versioned state machine for comic lifecycle

  • Purpose: make status transitions explicit and enforceable across create, publish, expire, and takedown flows.
  • Blast radius:
    • Core model: enum/state transition rules and validation constraints change.
    • API contracts: response fields may include state version and transition metadata.
    • Storage schema: migration required for lifecycle version and transition audit fields.
    • Background jobs: cleanup/takedown workers must honor state-machine gates.
    • Downstream dependencies: reporting and moderation tools must map to new state values.

Refactor: Introduce anti-corruption DTO boundary between API and shared client contracts

  • Purpose: reduce accidental coupling between persistence entities and external payloads.
  • Blast radius:
    • API endpoints: mapping logic added for read/write DTO translations.
    • Client app: contract changes may require adapter updates in typed services.
    • Tests: snapshot and serialization tests need baseline refresh.
    • Performance: additional mapping allocations may require profiling.
    • Downstream dependencies: any external consumer of existing DTO shape may need migration coordination.

Build and Run

dotnet restore
dotnet build PoSeeReview.slnx
dotnet run --project src/PoSeeReview.Api --launch-profile https

Hot Reload (code-only changes)

Configuration changes (appsettings, Key Vault secrets) require a full API restart. For code-only changes use hot reload to avoid the full startup delay:

dotnet watch --project src/PoSeeReview.Api --launch-profile https

Cloud Smoke Testing

After a deploy (push to master), the live URL is:

az webapp show --name app-poseereview2 --resource-group PoSeeReview --query defaultHostName -o tsv

CI checks formatting, builds, runs the Unit and Integration tiers, deploys and confirms the new commit answers /health/live; the smoke is run by hand after a deploy:

# Post-deploy smoke (NET_RULES 5.4): Blazor render tree, /health, then Lighthouse budgets
pwsh scripts/post-deploy-smoke.ps1 -BaseUrl https://<fqdn>

It installs Playwright and Chromium, runs scripts/post-deploy-smoke.mjs, then Lighthouse against /login (three runs, median). Layout shift above 0.1 or an accessibility score under 0.9 fails the run; performance and LCP only warn, because an F1 cold start swings them. Reports stay in .lighthouseci/ locally; CI no longer uploads them.

The full C# Playwright UI suite targets a running app via E2E_BASE_URL (it includes AccessibilityUiTests, axe-core over the main pages):

$env:E2E_BASE_URL = "https://<fqdn>"
dotnet test tests/PoSeeReview.E2EUI

Locally, run it against the app in mock mode (UseMockData=true, Development or Test only): sample places instead of Google Maps, every AI call answered by AiMockDelegatingHandler, real Azurite storage on ports 10000/10002 (scripts/start-azurite.ps1; when another app's emulator holds those, run one elsewhere and set Storage:AzuritePorts to blob,queue,table, e.g. Storage__AzuritePorts=5541,5542,5543), Key Vault blanked so no production secret is read:

KeyVault__Uri= UseMockData=true ASPNETCORE_ENVIRONMENT=Development ASPNETCORE_URLS=http://localhost:7208 \
  dotnet run --project src/PoSeeReview.Api --no-launch-profile
E2E_BASE_URL=http://localhost:7208 dotnet test tests/PoSeeReview.E2EUI

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages