How najibcode/ibuild works
Purpose and Entry Points
IBUILD ERP is an internal, multi-platform construction-operations system for supervisors and owners. Flutter is the client runtime for web, Android, iOS, desktop; its application entry point is lib/main.dart. Routing and adaptive shell/layout boundaries are centralized in lib/core/routing/router.dart, lib/mobile_dashboard.dart, and lib/web_dashboard.dart.
Application Composition
The codebase is organized primarily by feature, commonly separating data models/repositories, domain repository contracts, and Riverpod-backed presentation controllers/screens. A typical flow is screen → controller → repository interface/implementation → Supabase. Examples: lib/features/projects/presentation/controllers/project_controller.dart, lib/features/projects/domain/repositories/project_repository.dart, and lib/features/projects/data/repositories/supabase_project_repository.dart.
Identity, Authorization, and Navigation
Authentication is isolated behind an implementation and domain contract, with login, recovery, and startup screens under lib/features/auth/data/repositories/auth_repository_impl.dart, lib/features/auth/presentation/controllers/auth_controller.dart, and lib/features/auth/presentation/screens/splash_screen.dart. RBAC supplies role/permission models, a Supabase role repository, and UI guards for restricting sensitive features: lib/features/rbac/data/repositories/supabase_role_repository.dart, lib/features/rbac/presentation/providers/permission_provider.dart, and lib/features/rbac/presentation/widgets/permission_guard.dart.
Operational Domain Modules
Projects provide the central site/project identifier used to connect operational records and project dashboards: lib/features/projects/data/models/project_model.dart, lib/features/projects/presentation/screens/project_operations_screen.dart, and lib/features/projects/data/repositories/project_dashboard_repository.dart. Workforce workflows cover employees, attendance, daily wages, and reports through lib/features/employees/data/repositories/supabase_employee_repository.dart, lib/features/attendance/presentation/controllers/attendance_controller.dart, and lib/features/attendance/data/services/attendance_report_service.dart. Site execution tracks daily progress, activities, checklists, drawings, and tickets, including evidence-oriented models/repositories such as lib/features/daily_progress/data/repositories/supabase_daily_progress_repository.dart, lib/features/drawings/data/repositories/supabase_drawing_repository.dart, and lib/features/tickets/data/repositories/supabase_ticket_repository.dart.
Commercial, Asset, and Reporting Workflows
Financial workflows include expenses, billing, quotations, sales bills, payments, and ledger documents: lib/features/expenses/data/repositories/supabase_expense_repository.dart, lib/features/billing/data/building_pdf_generator.dart, and lib/features/payments/data/payment_ledger_pdf_generator.dart. Inventory and equipment track stock/history and fleet placement: lib/features/inventory/data/repositories/supabase_inventory_repository.dart, lib/features/inventory/presentation/screens/inventory_history_screen.dart, and lib/features/equipment/data/repositories/supabase_equipment_repository.dart. Shared export capabilities produce PDF/Excel outputs via lib/core/services/generic_pdf_table_generator.dart, lib/core/services/excel_generator_service.dart, and lib/features/reports/data/pdf_report_generator.dart.
Backend, Media, and Schema Boundary
Supabase is the external system of record for PostgreSQL data, Auth, RLS enforcement, and storage; the client integration boundary is lib/core/supabase/supabase_client.provider.dart. Versioned SQL migrations define the evolving relational schema and policies: supabase/migrations/001_rbac_tables.sql, supabase/migrations/003_project_operations.sql, and supabase/migrations/005_supervision_and_evidence.sql. Image uploads use ImageKit as a separate media service, with client services and a Supabase Edge Function that issues ImageKit authentication: lib/core/image/imagekit_auth_service.dart, lib/services/imagekit/imagekit_service.dart, and supabase/functions/imagekit-auth/index.ts.
Delivery and Platform Infrastructure
Web is deployed as a Flutter SPA to Vercel, configured by vercel.json; all routes rewrite to the client application. Native launchers package the same Flutter runtime for Android and iOS through android/app/src/main/kotlin/com/example/ibuild/MainActivity.kt and ios/Runner/AppDelegate.swift. CI runs through GitHub Actions at .github/workflows/dart.yml.
Main entry points: router.dart Routing & adaptive shell · supabase_client.provider.dart Supabase client boundary · supabase_daily_progress_repository.dart Site execution · supabase_expense_repository.dart Finance & billing
Components 21
Flutter Client
Multi-platform ERP runtime.
- Flutter entry
lib/main.dart - Routing & adaptive shell · Selects mobile and web dashboard layouts.
lib/core/routing/router.dart
Access Control
- Auth controller
lib/features/auth/presentation/controllers/auth_controller.dart - Auth repository
lib/features/auth/data/repositories/auth_repository_impl.dart - Permission guard
lib/features/rbac/presentation/widgets/permission_guard.dart - Role repository
lib/features/rbac/data/repositories/supabase_role_repository.dart
Operational Modules
- Projects & operations · Provides the project/site context for operational records.
lib/features/projects/presentation/screens/project_operations_screen.dart - Project controller
lib/features/projects/presentation/controllers/project_controller.dart - Project repository
lib/features/projects/data/repositories/supabase_project_repository.dart - Workforce & attendance · Employees, attendance, wages, and attendance reports.
lib/features/attendance/presentation/controllers/attendance_controller.dart - Site execution · Progress, drawings, checklists, activities, and tickets.
lib/features/daily_progress/data/repositories/supabase_daily_progress_repository.dart
Commercial & Assets
- Finance & billing · Expenses, quotations, bills, payments, and ledgers.
lib/features/expenses/data/repositories/supabase_expense_repository.dart - Inventory & equipment · Stock history and fleet placement.
lib/features/inventory/data/repositories/supabase_inventory_repository.dart - PDF & Excel exports
lib/core/services/generic_pdf_table_generator.dart
Platform Services
- Supabase client boundary
lib/core/supabase/supabase_client.provider.dart - Supabase · PostgreSQL, Auth, RLS, storage, and Edge Functions.
- SQL schema & policies
supabase/migrations/003_project_operations.sql - ImageKit media service
lib/services/imagekit/imagekit_service.dart - ImageKit auth function · Issues ImageKit authentication.
supabase/functions/imagekit-auth/index.ts - ImageKit
- Web, native & CI delivery · Vercel SPA deployment, Android/iOS launchers, and GitHub Actions CI.
vercel.json
Connections 26
- Flutter entry → Routing & adaptive shell: starts
- Routing & adaptive shell → Auth controller: auth flow
- Routing & adaptive shell → Projects & operations: navigates
- Routing & adaptive shell → Workforce & attendance: navigates
- Routing & adaptive shell → Site execution: navigates
- Routing & adaptive shell → Finance & billing: navigates
- Routing & adaptive shell → Inventory & equipment: navigates
- Auth controller → Auth repository: uses
- Auth repository → Supabase client boundary: auth API
- Permission guard → Role repository: checks permissions
- Role repository → Supabase client boundary: queries roles
- Projects & operations → Project controller: drives
- Project controller → Project repository: uses
- Project repository → Supabase client boundary: persists projects
- Workforce & attendance → Supabase client boundary: persists records
- Site execution → Supabase client boundary: persists evidence
- Finance & billing → Supabase client boundary: persists transactions
- Inventory & equipment → Supabase client boundary: persists assets
- Finance & billing → PDF & Excel exports: generates documents
- Supabase client boundary → Supabase: connects to
- SQL schema & policies → Supabase: defines schema and RLS
- Site execution → ImageKit media service: uploads images
- ImageKit media service → ImageKit auth function: requests auth
- ImageKit auth function → Supabase: runs on
- ImageKit media service → ImageKit: uploads media
- Web, native & CI delivery → Flutter entry: packages and deploys