Core Philosophy
This document defines the “Soul” of the Visita Intelligence Platform. It contains the fundamental principles that guide all development decisions and architectural choices.For AI Agents: Before writing code, read this file. If a user request conflicts with these principles, warn them before proceeding.
1. What Visita Is NOT
2. What Visita IS
Visita is a Civic Intelligence Platform that:- ✅ Optimizes for awareness and participation
- ✅ Sells intelligence tools, not ads
- ✅ Builds critical infrastructure with care and deliberation
- ✅ Empowers citizens with actionable local intelligence
3. The “Civic Window” Metaphor
The interface is a window into the user’s physical reality:Location → Intelligence → Participation
This three-step flow defines every interaction in Visita:- Location Awareness: The system knows where you are (ward, municipality, province)
- Intelligence Delivery: Relevant information is surfaced based on your location
- Participation Opportunity: You’re empowered to act on what you’ve learned
4. Architecture Rules
A. The “Source of Truth” Rule
Postgres is King: All authoritative data lives in Supabase tables.
- Supabase (PostgreSQL): The single source of truth
- Algolia: A read-only cache for search and discovery
- AI: A utility that summarizes or formats existing data, never generates facts
B. The “No-Magic” Auth Rule
Intent-Based Authentication:- Never force login on public pages
- Only request authentication when user attempts a protected action
- Always preserve user context (URL) after login
- Use
RequireAuthandRequireContextguards, not just middleware
C. The “Graph” Geography Model
Wards are Atomic: The Ward is the base unit of civic organization and data aggregation.
- Many-to-Many Relationships: A business can serve multiple wards
- No Hardcoded Hierarchies: Use graph relationships, not rigid trees
- Wards as Nodes: Wards connect to businesses, roads, incidents, people
- Navigational Views: URLs are curated paths through the graph, not ownership hierarchies
Visita models reality as a graph. Pages are curated paths through that graph.
5. What NOT To Build (The Anti-Roadmap)
We explicitly avoid building features that contradict our core philosophy:- ❌ Global Chat: No unmoderated global feeds
- ❌ Gamification: No badges, streaks, or dopamine loops
- ❌ Chatbots as Navigation: AI is a feature, not the UI
- ❌ Inline SQL: No raw SQL in components. Use RPCs or Typed Clients
- ❌ Hardcoded Emails: All emails must go through
/services/email
6. AI Governance
AI in Visita is an assistive, derived-intelligence system, not a decision-maker.Guiding Principles
- AI is never a source of truth
- AI outputs are always derived, explainable, and replaceable
- AI must not silently influence civic, legal, or financial outcomes
- AI usage must be cost-controlled and auditable
- Humans retain ultimate authority over interpretation and action
Permitted AI Use Cases
✅ Summarization: Ward intelligence summaries, crime trend explanations ✅ Classification: Crime categorization, topic tagging ✅ Pattern Explanation: Explaining already-computed trends (NOT detecting new ones)Prohibited AI Use Cases
❌ Generating or modifying source-of-truth data ❌ Making automated decisions affecting user permissions or payments ❌ Real-time moderation without human oversight ❌ Predictive policing or profiling ❌ Sentiment analysis on individualsAI Output Data Model
All AI outputs must be stored as derived data with:- Clear labeling as AI-generated
- Links to source data, timestamp, and model used
- Safe to delete and regenerate at any time
7. Directory Structure Meaning
Understanding the codebase organization:8. Technical Stack (Strict)
We maintain strict adherence to our technology choices:- Framework: Next.js 14+ (App Router)
- Language: TypeScript (Strict mode)
- Database: Supabase (PostgreSQL)
- Auth: Supabase Auth (SSR)
- Styling: Tailwind CSS + shadcn/ui
- Maps: Leaflet (via
react-leaflet) - Search: Algolia (Discovery layer only)
- Email: Mailgun (via
/services/email)
9. AI Coding Instructions
When contributing to Visita:- Check Context: Before editing a file, check
ROADMAP.mdfor active phases - Use Services: Do not import 3rd party SDKs directly into UI components. Use the
/serviceslayer - Type Everything: No
any. Create interfaces in/types - Mobile First: Always verify responsive classes (
md:,lg:)
Summary
AI in Visita is a lens, not a judge. It assists understanding, but never replaces accountability.This philosophy exists to ensure we build technology that strengthens trust rather than eroding it. Every feature, every line of code, and every architectural decision should align with these principles.
Next Steps:
- Architecture Overview - See how these principles are implemented
- Quickstart Guide - Set up your development environment
- AI Governance - Deep dive into AI usage policies