You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A complete organization management system that allows craftsmen to form teams, manage bookings under one brand, and operate as a professional services company.
The Organization feature transforms Hirfa from a 1-to-1 worker-client platform into a scalable multi-worker business model. A worker can create an organization, recruit other workers under it, and manage all bookings, payments, and ratings through a centralized dashboard.
Key Entities
Entity
Description
Organization
A business entity (e.g., "ورشة حكيم الجن وأولاده") owned by a worker
Organization Worker
A worker linked to an org (may or may not have a linked user account)
Org Booking
A client booking that goes through the organization
Org Review
A client review for the organization
How It Works
Lifecycle
1. Worker creates organization (becomes owner)
↓
2. Owner adds workers to the org
↓
3. Client browses orgs on home/services → views org profile
↓
4. Client books an org service → booking created with organization_id
↓
5. Org owner sees booking in dashboard → assigns a worker
↓
6. Worker completes job → confirmation code flow
↓
7. Payment credited to org owner's wallet
↓
8. Client rates → rating goes to both worker AND organization
Complete assigned jobs, see "rating as part of org" on profile
Client
Browse orgs, view org profile, book org services, rate org
Database Schema
Tables
organizations
id UUID PRIMARY KEY
owner_id UUID NOT NULL → auth.users
name TEXTNOT NULL
description TEXT
category TEXT
city TEXT
logo_url TEXT
plan TEXT DEFAULT 'free'-- 'free' | 'pro'
is_active BOOLEAN DEFAULT true
rating NUMERIC(3,2) DEFAULT 0
reviews_count INTEGER DEFAULT 0
worker_count INTEGER DEFAULT 0
created_at TIMESTAMPTZ
updated_at TIMESTAMPTZ
organization_workers
id UUID PRIMARY KEY
organization_id UUID NOT NULL → organizations (CASCADE)
linked_user_id UUID → auth.users (SETNULL)
display_name TEXTNOT NULL
avatar_url TEXT
phone TEXT
is_active BOOLEAN DEFAULT true
created_at TIMESTAMPTZ
organization_worker_portfolio
id UUID PRIMARY KEY
organization_worker_id UUID NOT NULL → organization_workers (CASCADE)
image_url TEXTNOT NULL
sort_order SMALLINT DEFAULT 0
created_at TIMESTAMPTZ
organization_services
id UUID PRIMARY KEY
organization_id UUID NOT NULL → organizations (CASCADE)
name TEXTNOT NULL
description TEXT
price NUMERIC
icon TEXT
is_active BOOLEAN DEFAULT true
created_at TIMESTAMPTZ
organization_gallery
id UUID PRIMARY KEY
organization_id UUID NOT NULL → organizations (CASCADE)
image_url TEXTNOT NULL
sort_order SMALLINT DEFAULT 0
created_at TIMESTAMPTZ
organization_reviews
id UUID PRIMARY KEY
organization_id UUID NOT NULL → organizations (CASCADE)
client_id UUID NOT NULL → auth.users (CASCADE)
booking_id UUID → bookings
rating SMALLINTNOT NULLCHECK (1-5)
textTEXT
created_at TIMESTAMPTZ