DEV Community

Cover image for PIRS — Public Infrastructure Reporting System
Layton Tozvireva
Layton Tozvireva

Posted on

PIRS — Public Infrastructure Reporting System

Sanity Challenge Path One Submission

This is a submission for the Sanity Challenge, Path One: Ship an Agent That Queries Real Content

What I Built

PIRS — Public Infrastructure Reporting System

What I Built

I built PIRS (Public Infrastructure Reporting System), a civic technology platform designed to help citizens report and understand public infrastructure problems in their communities.

People can encounter issues such as:

  • Electricity faults
  • Water problems
  • Blocked sewer systems
  • Potholes and damaged roads
  • Broken traffic lights
  • Illegal dumping
  • Fallen trees

PIRS gives citizens a way to report these problems, provide their location and supporting information, and track submitted reports.

For the Sanity Challenge, I extended PIRS with a structured Infrastructure Knowledge Base and AI assistant.

Instead of asking the AI to answer infrastructure questions purely from general knowledge, the assistant retrieves relevant structured PIRS knowledge from Sanity and uses that information as context for its response.

Demo

Live application:
https://public-infrastructure-reporting-sys.vercel.app/

The Knowledge page contains the Infrastructure Knowledge Base and AI assistant.

Example questions include:

How do I report a water problem?

Who should I contact about a damaged road?

What information should I provide when reporting an electricity fault?

The application also provides a directory of the underlying infrastructure knowledge and links to source information.

Code

GitHub repository:
https://github.com/laytontozvireva-star/Public_Infrastructure_Reporting_System

How I Used Sanity

Sanity is used as the structured knowledge layer behind the PIRS infrastructure assistant.

I created a Sanity project with a dedicated infrastructureKnowledge document type.

Each knowledge record can contain structured information such as:

  • Title
  • Infrastructure category
  • Problem
  • Safety guidance
  • Reporting procedure
  • Required information
  • Responsible authority
  • Location context
  • Summary
  • Source name
  • Source URL

The categories include:

  • Electricity
  • Water
  • Sewer
  • Roads
  • Traffic Lights
  • Illegal Dumping
  • Fallen Trees
  • Other

The knowledge base contains infrastructure information collected from relevant sources, with source information preserved alongside the structured records.

The PIRS backend queries the Sanity Content Lake and retrieves the infrastructure knowledge used by the assistant.

The AI assistant then performs relevance matching against the structured content before providing the relevant knowledge as context to Gemini.

The assistant is instructed to:

  1. Use only the provided PIRS knowledge.
  2. Avoid inventing authorities, procedures, phone numbers, or other facts.
  3. Prioritize safety information where applicable.
  4. State when the available knowledge is insufficient.
  5. Preserve the relationship between the answer and the underlying source information.

This makes Sanity the structured knowledge layer that the PIRS AI assistant depends on.

Sanity Project Details

Sanity Project ID: wenswj4d

Dataset: production

The project contains the infrastructureKnowledge schema and published infrastructure knowledge records used by the PIRS application.

Technical Stack

Frontend

  • React
  • React Router
  • Tailwind CSS
  • React Markdown
  • Lucide React

Backend / Services

  • Vercel serverless API routes
  • Sanity
  • Supabase
  • Google Gemini

Core flow

Citizen question
      ↓
PIRS AI Assistant
      ↓
Sanity structured knowledge
      ↓
Relevant infrastructure records
      ↓
Gemini
      ↓
Grounded response
      ↓
Source information displayed to the citizen
Enter fullscreen mode Exit fullscreen mode

The main PIRS reporting system also uses Supabase for authentication, reports, and report photos.

What I Learned

The biggest lesson from this project was that an AI assistant becomes much more useful when the information it relies on is structured and traceable.

Instead of treating infrastructure information as one large block of text, I modeled important parts of each issue separately: category, authority, reporting procedure, safety guidance, required information, location context, and source.

That structure made it possible for the application to retrieve relevant knowledge and give the AI a focused context for answering questions.

I also encountered real production issues during development, including temporary Gemini service errors and free-tier quota exhaustion. I added explicit handling for these conditions so users receive a meaningful service-limit message instead of a generic connection failure.

Why PIRS

Infrastructure problems are easy to see but often difficult to report correctly.

A citizen may know that a road is damaged or that a water pipe is leaking, but may not know:

  • Who is responsible?
  • What information should be provided?
  • Where should the problem be reported?
  • What safety precautions are necessary?

PIRS brings reporting, location, tracking, structured infrastructure knowledge, and an AI assistant into one civic technology experience.

The goal is simple:

Report. Locate. Track.

sanitychallenge

Top comments (0)