title: “Ward Community Module” description: “Architecture and implementation guide for the hyper-local community social feed.”
Ward Community Module
The Ward Community module provides a hyper-local social layer for the Visita Intelligence Platform, enabling residents, businesses, and councillors to interact within a specific geographic ward.Overview
We build critical infrastructure, not social networks. Every community feature must serve awareness and civic participation. The community feed is designed to facilitate discussion, report local issues, and connect citizens with their ward representatives.Schema Configuration
The module extends thevisita_myward schema with two primary tables:
community_posts
Authoritative record for all community discussions and reports.
| Column | Type | Description |
|---|---|---|
id | UUID | Primary key. |
ward_id | UUID | FK referencing visita_myward.communities. |
user_id | UUID | FK referencing auth.users. |
content | TEXT | Post body content. |
media_urls | TEXT[] | Array of image URLs stored in Supabase Storage. |
category | Enum | general, safety, service_delivery, business. |
issue_type | TEXT | Specific type for service delivery (e.g., ‘pothole’). |
issue_status | Enum | open, resolved, null. |
community_comments
| Column | Type | Description |
|---|---|---|
id | UUID | Primary key. |
post_id | UUID | FK referencing community_posts. |
user_id | UUID | FK referencing auth.users. |
content | TEXT | Comment body. |
Error Handling Strategy
The module implements a robust, multi-layer error handling strategy as defined in@/lib/error-handler.ts.
1. Standardized Response Format
All server actions return a consistentActionResponse<T> object:
2. Schema-Specific Logging
Errors are logged with schema and operation context to facilitate debugging and monitoring:3. User-Safe Messages
Internal database errors are caught and transformed into user-friendly messages while preserving technical context for developers.Component Architecture
The module follows the 3-Column Layout pattern:- Left Sidebar: Navigation and global filtering.
- Main Feed: Post creation widget and infinite scroll feed.
- Right Sidebar: Contextual ward information (Councillor profile, Ward health stats).
Security & Governance
Row Level Security (RLS)
- Select: Anyone (including anonymous users) can view community posts.
- Insert: Restricted to authenticated users.
- Update/Delete: Restricted to the post author.
Role-Based Actions
ThemarkIssueResolved action implements governance rules:
- Authors can mark their own issues as resolved.
- Councillors can mark any issue in their ward as resolved to facilitate service delivery oversight.
Implementation Status (Prototype Mode)
- UI Architecture (3-Column Layout)
- Mock Data Visualization (Enabled)
- Next Step: Connect
WardCommunityBoardtovisita_mywarddatabase.- Posts Source:
visita_myward.posts - Councillor Source:
public.wards - Stats Source: Aggregated count of
issue_status = 'open'
- Posts Source:
Future Roadmap
- Multi-image carousel support.
- Real-time feed updates via Supabase Realtime.
- AI-assisted issue categorization and sentiment analysis.