A comprehensive barangay management system built with React, TypeScript, and Supabase. This application enables residents to submit complaints and barangay administrators to manage and respond to community issues in real-time.
- Features
- Tech Stack
- Prerequisites
- Installation
- Database Setup
- Environment Variables
- Running the Application
- Project Structure
- User Roles
- Available Scripts
- Troubleshooting
- Contributing
- License
- 📝 Submit Complaints - Report barangay issues with photos and location details
- 👁️ Track Status - Monitor complaint progress in real-time
- 👤 Profile Management - Update personal information and settings
- 📊 View History - Access all submitted complaints and their statuses
- 🎯 Complaint Management - Review, prioritize, and respond to complaints
- 📈 Data Analytics - Visualize complaint trends and statistics
- 👥 User Management - Manage resident accounts and permissions
- 🔄 Real-time Updates - Instant synchronization across all devices
- 🎨 Admin Dashboard - Centralized control panel for all operations
- 🔐 Secure Authentication - User signup, login, and role-based access control
- 🌓 Dark/Light Mode - Toggle between themes for comfortable viewing
- 📱 Responsive Design - Works seamlessly on desktop, tablet, and mobile
- ☁️ Cloud Storage - All data securely stored in Supabase
- 🔄 Real-time Sync - Automatic updates without page refresh
- React 18.3.1 - UI library
- TypeScript - Type-safe JavaScript
- Vite - Fast build tool and dev server
- Tailwind CSS - Utility-first CSS framework
- Radix UI - Accessible component primitives
- Lucide React - Beautiful icon set
- Recharts - Charting library for analytics
- React Hook Form - Form validation and management
- Sonner - Toast notifications
- Supabase - Backend-as-a-Service (PostgreSQL database, authentication, real-time subscriptions)
- Row Level Security (RLS) - Database-level access control
- Custom component library built with Radix UI primitives
- Shadcn/ui inspired design system
- Fully accessible and keyboard navigable
Before you begin, ensure you have the following installed:
- Node.js (v16.x or higher)
- npm or yarn or pnpm
- Supabase Account (free tier available at supabase.com)
-
Clone the repository
git clone https://github.com/OptimizedSpaghetti-ru/BarangayCare.git cd BarangayCare -
Install dependencies
npm install # or yarn install # or pnpm install
-
Set up environment variables
Create a
.envfile in the root directory:VITE_SUPABASE_URL=your_supabase_project_url VITE_SUPABASE_ANON_KEY=your_supabase_anon_key
You can find these credentials in your Supabase project settings:
- Go to supabase.com/dashboard
- Select your project
- Navigate to Settings → API
- Copy Project URL and anon/public key
-
Open Supabase SQL Editor
- Go to your Supabase Dashboard
- Select your project
- Click SQL Editor in the left sidebar
- Click New Query
-
Run the setup script
- Open
src/utils/supabase/setup-database.sqlin your project - Copy all contents
- Paste into the SQL editor
- Click Run
Note: If you encounter permission errors and already ran an old script, use
src/utils/supabase/fix-policies.sqlinstead. - Open
-
Enable Real-time
- Go to Database → Replication
- Find the
complaintstable - Toggle Replication ON
-
Create an Admin User
- Go to Authentication → Users
- Sign up through the app first
- Find your user in the dashboard
- Click on the user
- In the User Metadata section, add:
{ "role": "admin", "name": "Your Name" } - Click Save
-
Verify Setup
- ✅ Table
complaintsexists in Table Editor - ✅ 6 RLS policies are active (Database → Policies)
- ✅ Real-time replication is enabled
- ✅ At least one admin user is configured
- ✅ Table
For comprehensive database setup instructions, migration guides, and troubleshooting:
Create a .env file in the root directory with the following variables:
# Supabase Configuration
VITE_SUPABASE_URL=https://your-project.supabase.co
VITE_SUPABASE_ANON_KEY=your-anon-key-hereWhere to find these values:
- Log into Supabase Dashboard
- Select your project
- Go to Settings → API
- Copy the Project URL and anon/public key
npm run dev
# or
yarn dev
# or
pnpm devThe application will start at http://localhost:5173 (or another port if 5173 is busy).
npm run build
# or
yarn build
# or
pnpm buildnpm run preview
# or
yarn preview
# or
pnpm previewBarangayCare/
├── icon/ # Application icons and assets
├── src/
│ ├── components/
│ │ ├── auth/ # Authentication components
│ │ │ ├── auth-context.tsx # Auth state management
│ │ │ ├── login-form.tsx # Login interface
│ │ │ ├── signup-form.tsx # Registration interface
│ │ │ ├── profile-management.tsx
│ │ │ └── user-management.tsx
│ │ ├── figma/ # Custom components
│ │ │ └── ImageWithFallback.tsx
│ │ ├── ui/ # Reusable UI components
│ │ │ ├── button.tsx
│ │ │ ├── card.tsx
│ │ │ ├── dialog.tsx
│ │ │ ├── form.tsx
│ │ │ └── ... (30+ components)
│ │ ├── admin-panel.tsx # Admin control center
│ │ ├── complaint-form.tsx # Complaint submission
│ │ ├── complaint-manager.tsx # Complaint state management
│ │ ├── data-analytics.tsx # Analytics dashboard
│ │ ├── header.tsx # App header/navigation
│ │ ├── migration-helper.tsx # Data migration utility
│ │ ├── resident-settings.tsx # User settings
│ │ ├── theme-provider.tsx # Dark/light mode
│ │ └── unified-dashboard.tsx # Main dashboard
│ ├── guidelines/
│ │ └── Guidelines.md # Development guidelines
│ ├── styles/
│ │ └── globals.css # Global styles
│ ├── supabase/
│ │ └── functions/ # Serverless functions
│ ├── utils/
│ │ └── supabase/
│ │ ├── client.tsx # Supabase client setup
│ │ ├── info.tsx # Database info
│ │ ├── setup-database.sql # Database schema
│ │ ├── fix-policies.sql # RLS policy fixes
│ │ ├── migrate-localStorage.tsx
│ │ └── DATABASE_SETUP_GUIDE.md
│ ├── App.tsx # Main application component
│ ├── main.tsx # Application entry point
│ ├── index.css # Base styles
│ ├── QUICK_START_DATABASE.md # Quick setup guide
│ ├── SUPABASE_DATABASE_README.md
│ ├── TROUBLESHOOTING_DATABASE.md
│ └── Attributions.md # Third-party credits
├── index.html # HTML template
├── package.json # Dependencies and scripts
├── vite.config.ts # Vite configuration
├── tsconfig.json # TypeScript configuration
└── README.md # This file
- Submit and view own complaints
- Update personal profile
- Track complaint status
- View barangay information
- All resident permissions
- View all complaints from all users
- Update complaint status and priority
- Manage user accounts
- Access analytics dashboard
- Respond to complaints
To make a user an admin:
- Go to Supabase Dashboard → Authentication → Users
- Click on the user
- Add to User Metadata:
{"role": "admin", "name": "Admin Name"}
| Command | Description |
|---|---|
npm run dev |
Start development server |
npm run build |
Build for production |
npm run preview |
Preview production build |
npm run lint |
Run ESLint (if configured) |
1. Can't submit complaints
- Ensure you're logged in
- Check that the database is set up correctly
- Verify RLS policies are active
2. Real-time updates not working
- Enable replication for the
complaintstable in Supabase - Check your internet connection
- Verify Supabase credentials in
.env
3. Permission denied errors
- Run
fix-policies.sqlto update RLS policies - Ensure your user has the correct role
- Check Supabase logs for detailed errors
4. Build errors
- Delete
node_modulesandpackage-lock.json - Run
npm installagain - Ensure Node.js version is 16.x or higher
5. Supabase connection issues
- Verify
.envfile exists and contains correct credentials - Check that environment variables start with
VITE_ - Restart the development server after changing
.env
- 📖 Check the Troubleshooting Guide
- 🐛 Open an issue
- 📧 Contact the development team
The application supports dark and light modes. Theme configuration is in src/components/theme-provider.tsx.
- Global styles:
src/styles/globals.css - Component styles: Tailwind CSS classes
- Custom components:
src/components/ui/
- Create components in
src/components/ - Add routing logic in
App.tsx - Update database schema in
setup-database.sql - Add RLS policies for new tables
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Follow TypeScript best practices
- Use existing UI components when possible
- Maintain accessibility standards
- Write clean, documented code
- Test on multiple devices and browsers
This project is private and proprietary.
- Supabase - For the amazing backend platform
- Radix UI - For accessible component primitives
- Shadcn/ui - For design inspiration
- Lucide - For beautiful icons
- Tailwind CSS - For the utility-first CSS framework
- React Team - For the excellent UI library
For support and questions:
- 📧 Email: [your-email@example.com]
- 🐛 Issues: GitHub Issues
- 📖 Documentation: Check the
/srcdirectory for detailed guides
- Profile Picture Integration
- Multi-language support
- 2FA Email
- Mobile app (Capacitor)
- SMS notifications
- Advanced analytics
- Document management
- Event scheduling
- GIS mapping integration
- Offline Use
Current Branch: Barangaycare Guest Account