What it does
Environmental reports are written for regulators and laboratories. A homeowner who pays for a mold or water test gets back pages of spore counts, parts per billion and lab codes with no plain answer to the question they care about: is this a problem, and what should I do? Clear Report answers it. A customer buys credits, uploads the report and receives an interpretation they can act on.
What the customer gets
- A two-to-three-sentence summary of what the report says.
- An overall risk level: low, moderate, high or critical.
- Every finding, itemized: its category, a description, a severity (info, warning, concern or critical), where it was found, the measured value and the safe threshold it is compared against.
- Prioritized recommendations: each with a priority (low, medium, high or urgent), the action, the reason and a timeline.
- A confidence score for the interpretation as a whole.
The customer uploads a PDF, JPEG, PNG or WebP file of up to 50 MB, follows its progress on the report page, which updates itself until the result is ready, and receives an email when it is.
Six report types, each with its own standards
Every interpretation starts from the same base instruction: act as an expert environmental health consultant, write in plain language for homeowners and property managers, stay calm rather than alarmist, and return strictly structured data. Each report type then adds the standards an expert would apply:
- Mold: spore species and counts, with the toxic genera Stachybotrys and Chaetomium flagged, and indoor counts compared with the outdoor baseline (typically 500 to 1,500 spores per cubic meter outdoors, with concern starting at 500 above it).
- Air quality: fine and coarse particulates, total volatile organic compounds, formaldehyde against the World Health Organization's 0.1 ppm, carbon dioxide (good below 800 ppm, poor above 1,000), carbon monoxide (any reading means investigate, above 9 ppm is dangerous) and humidity (30 to 50% ideal, above 60% a mold risk).
- Water quality: EPA maximum contaminant levels for lead (action level 15 ppb), arsenic (10 ppb), nitrate (10 mg/L), copper, mercury and fluoride; any coliform or E. coli fails; pH between 6.5 and 8.5.
- Radon: EPA action levels in picocuries per liter, below 2 low risk, 2 to 4 moderate, 4 to 8 high and above 8 critical, with lung-cancer context of about 16% more risk per 2 pCi/L.
- Lead: EPA and HUD thresholds for paint (1.0 mg/cm² by XRF or 0.5% by lab), dust (10, 100 and 400 µg/ft² for floors, window sills and window troughs) and soil (400 ppm in play areas, 1,200 elsewhere), with added concern when children under six are in the home.
- Asbestos: confirmed against presumed asbestos-containing material (above 1%), friable against non-friable, the fiber type (crocidolite the most dangerous), common locations, and the rule that removal needs licensed abatement.
A general fallback handles any other kind of environmental report by first identifying what was tested and then applying the standards that fit, and a normalizer maps the many names labs use (IAQ, fungal, drinking water, asbestos survey and others) onto the right type.
How it classifies a report
After a report is parsed, a keyword classifier scores its text against 15 to 17 terms for each report type. Multi-word phrases count double, a term found in a section header adds five points, and a type is chosen only when it holds at least 30% of the total score and scores at least five, with confidence capped at 0.95. The detected type is stored with the parsed report and travels with the interpretation job as its confidence signal, alongside the type the customer chose on the upload form.
The processing pipeline
Four job queues on Redis carry each report from upload to inbox:
- Upload: the app hands the browser a presigned storage link valid for one hour, so the file goes straight to S3-compatible storage, then records the upload.
- PDF processing (three jobs at once, three attempts, a five-minute limit): extracts the text, metadata, section headers and tables, runs the classifier, saves the parsed report and queues the interpretation.
- Interpretation (two at once, two attempts, a three-minute limit): checks the cache, otherwise calls Claude at a low temperature of 0.2, parses the structured reply with two fallbacks, and checks every value against the allowed lists. In one database transaction it marks the report complete, stores the interpretation, the model, the tokens used, the processing time and the estimated cost, and deducts one credit, on success only. A failure marks the report failed, records the error and the attempt count, and sends the customer a failure email instead.
- Email: five attempts through Resend, with six branded templates (welcome, report ready, report failed, order confirmation, password reset and refund confirmation).
Every queue retries with exponential backoff, keeps completed jobs for 24 hours and failed jobs for seven days, and starts with the server. A report moves through pending, uploaded, analyzing, reviewing and completed (or failed), the reviewing state holding a place for a human expert's review.
The cache
Identical reports are interpreted once. The cache key is a SHA-256 fingerprint of the report type plus the first 10,000 characters of the normalized text, and each interpretation is held in Redis for seven days. A cache hit skips the AI call while still charging the credit and sending the email, so the customer experience is identical and the cost is not. A cost estimator prices every call by input and output tokens, and utilities report the cache's size and memory use and can clear it.
Billing and credits
- Credit packs through Stripe Checkout: Basic at $29 for 5 credits, Standard at $79 for 15 (marked most popular) and Professional at $149 for 50.
- A webhook handling five Stripe events: completed checkouts, succeeded and failed payments, full and partial refunds, and refund creation.
- An order service that creates the order and adds the credits in one transaction, tracks seven order states from pending to refunded, issues refunds with an amount and reason, and reports each customer's order statistics.
- No credit, no report: creating a report is refused when the balance is below one.
- A partner program in the data model: business-to-business referral partners with their own codes and a default 20% commission, tracked on every order.
Accounts, roles and protection
- Four roles: user, expert, admin and super admin, enforced through four access levels in the API (public, signed in, expert and above, and admin), the higher two checked against the role stored in the database.
- Sign-in with email and password (bcrypt) or Google, with page protection in middleware and single-use, expiring password-reset tokens.
- Rate limits on every sensitive action: 5 sign-in attempts per 15 minutes, 3 password resets an hour, 10 registrations an hour per address, 100 API calls a minute, 20 uploads an hour and 10 checkouts an hour.
- Data rights: customers can export everything held about them (reports, orders and files), change their password or delete their account, and each of those actions, along with sign-ins, sign-outs, orders and refunds, is written to an audit log.
- Security headers on every response and validated environment settings at start-up.
Screens
Sixteen screens: the marketing site (home with how it works, about, pricing, and checkout success and cancel pages); sign-in, registration, forgot-password and reset-password; and the customer dashboard (credit balance and statistics, orders and order detail, reports, a two-step new-report flow that blocks when no credits remain, the report detail with key findings and recommendations, settings and profile). The interface is built from 45 components with drag-and-drop upload, progress bars and a light and dark theme.
What it achieved
- A complete paid service in one codebase: upload, classification, AI interpretation against published EPA, HUD and WHO standards, payment, refunds, email, accounts and data rights.
- Six report types, each interpreted to the standards a consultant would apply, with every finding shown against its safe threshold.
- Credits charged only for delivered results, and repeat reports served from the cache at no AI cost.
- Size: 16,462 lines of code in 176 files, 99 test cases in 10 test files (2,371 lines), 16 screens, 8 service routes, 6 API routers with 25 typed calls, 10 data tables and 7 enumerations, built across 54 commits.
The problem it solves
Homeowners, buyers and property managers pay for environmental testing because they are worried about their health or their investment, then receive a document they cannot read. The numbers mean nothing without the threshold beside them, and the threshold differs for every contaminant and every agency. The usual answer is to pay a consultant to explain it. Clear Report gives that explanation in minutes for a fixed credit price: what was found, how serious it is, and what to do next, in that order.
How he built it
Maxwell ran the build under a written agent protocol: five prime directives and a six-phase loop for every task (intake, preflight, implement, verify, document and complete), driven by five scripts that open a task, run the preflight, verify it (type check, lint, tests and build), scan for security issues and track the session. A master roadmap planned 38 tasks across six phases, with every decision and change recorded in tracking files.
The guards: pre-commit hooks lint and format every staged file; three GitHub workflows run linting, type checks, unit tests and the build on every push, check every pull request's title, conflicts and size and deploy a preview with a comment, and ship production. Tests run in Vitest with a browser environment and Playwright for end-to-end flows, covering the order service, the app state, the audit log, sign-in, the Stripe webhook and the user procedures.
An enterprise self-audit checked the system against 437 checkpoints across seven areas, and the rate limiting, security headers, password-reset flow and environment validation it checks for are all in the code.
The stack: Next.js 16 and React 19 with TypeScript, Tailwind and shadcn components; tRPC 11, Prisma 7 on PostgreSQL 16, BullMQ on Redis 7, the Anthropic SDK, Stripe, Resend with React Email, S3-compatible storage and Upstash rate limiting; Docker Compose for local development (Postgres, Redis and MinIO) and container deployment with health checks and automatic restarts.




