🚀 JoDija Repository (jodija_repository)
Simplifying Flutter Workflows And Universal Cross-Platform Solutions
An enterprise-grade Flutter/Dart data management, networking, and repository layer framework for Single-Solution and Multi-Solution architectures.
🌐 Language / اللغة
English • 🇸🇦 العربية (README.ar.md) • 📚 Documentation Portal (documents/README.md)
💡 The Core Architectural Philosophy (فلسفة المكتبة الأساسية)
The foundational philosophy of JoDija Repository was created to solve a critical software engineering challenge: How to share domain business logic, data models, and API integrations across multiple applications without duplicating code or coupling UI to networking details.
graph TD
subgraph UI_Solutions ["1. حلول واجهات المستخدم (UI Solutions)"]
UI1["📱 تطبيق العميل (Customer App)"]
UI2["🏪 تطبيق التاجر (Merchant App)"]
UI3["🖥️ لوحة التحكم الإدارية (Admin Dashboard)"]
UI4["🌐 تطبيق الويب (Customer Web)"]
end
subgraph Logic_Layer ["2. طبقة منطق الأعمال المشترك (Shared Business Logic)"]
Logic["🧠 matger front logic<br/>(MatgerLogicConfiguration + BLoCs + Repositories)"]
end
subgraph Core_Data ["3. مكتبة مصدر البيانات الأساسية (Core Data Source Engine)"]
Repo["⚙️ JoDija_reposatory<br/>(DataSourceConfigration + HttpClient + Firebase + Error Handling)"]
end
subgraph Backend_Server ["4. الواجهة الخلفية الموحدة (Unified Backend API)"]
Server["🚀 matger express<br/>(REST API Endpoints + Image Hosting + Auth)"]
end
UI1 --> Logic
UI2 --> Logic
UI3 --> Logic
UI4 --> Logic
Logic --> Repo
Repo <--> Server
1. Multi-Solution Architecture (التطبيقات متعددة الحلول) - e.g., matger front logic
- The Problem: In modern platforms like Matger (متجر), you have multiple user-facing clients (Customer Mobile App, Merchant App, Web Dashboard, Delivery App) that all interact with the same database and share identical business rules.
- The Solution:
JoDija_reposatory(The Engine): Handles networking, caching, serialization, and error mapping.matger front logic(The Shared Brain): InheritsDataSourceConfigration, manages state (BLoCs/Cubits), synchronizes auth tokens andx-langlanguage codes, and exposes clean use cases.- UI Solutions (The Presentation): Flutter apps for iOS, Android, Web, and Desktop focus 100% on UI/UX and consume
matger front logic. matger express(The Unified Backend): Serves all clients through a standard JSON contract and respectsx-langandAuthorizationheaders.
2. Single-Solution Architecture (التطبيقات أحادية الحل)
- Standalone Apps: When building a single application (e.g. standalone mobile app), the app package depends directly on
JoDija_reposatoryand configuresDataSourceConfigrationinside its own startup lifecycle with zero boilerplate.
🌟 Core Features & Capabilities (المزايا والقدرات الأساسية)
1. ⚙️ Multi-Environment Configuration Engine (DataSourceConfigration)
- Seamless Environment Switching: Effortlessly toggle between
local,remote_dev, andremote_prodstates. - Dedicated Image Server Routing: Independent resolution for API base URLs (
baseUrls) and media/image server URLs (imageBaseUrls). - JSON-Driven Setup: Bootstrap complete networking and Firebase environments from a single asset file via
backendRoutedInit(). - Programmatic Override: Direct runtime updates via
setToHttpUrlsEnveiroment().
2. 🌐 Advanced HTTP Client with Dio (HttpClient)
- Full HTTP Method Suite: Native support for
GET,POST,PUT,DELETE, andPATCH. - Automated Localization: Dynamic language header injection (
x-lang: ar/x-lang: en) managed globally viaHttpHeader().setLangHeader(). - Automatic JWT Bearer Token: Seamless authentication header binding (
Authorization: Bearer <token>). - Multipart Uploads & Cancellations: First-class handling of file uploads and request cancellation via
CancelToken.
3. 🛡️ Strongly-Typed Error Handling Hierarchy (BaseError)
- Automatic conversion of HTTP status codes and connection failures into 13+ strongly typed error classes:
400 BadRequestError•401 UnauthorizedError•403 ForbiddenError404 NotFoundError•409 ConflictError•500 InternalServerErrorTimeoutError•ConnectionError•SocketError•FormatError•CancelError
4. 📦 Result Pattern State Encapsulation (Result<Error, Data>)
- Eliminates unhandled runtime exceptions by encapsulating outcomes into type-safe
Result<T>andUserResultobjects.
5. 🔥 Firebase Ecosystem Integration (Firestore, Storage, Auth, FCM)
- Firestore CRUD: High-level and low-level Firestore connectors (
DataSourceFirebaseSource,FireStoreAction). - Real-Time Streaming: Reactive Firestore streaming with automatic model mapping (
StreamFirebaseDataSource). - Storage Utilities: Integrated image and file uploads to Firebase Storage (
StorageActions). - Authentication: Pre-built providers for Google Sign-In (
GoogleAuthSoucre) and Email/Password (EmailPassowrdAuthSource). - Push Notifications: Firebase Cloud Messaging setup and topic subscriptions (
FCMService).
6. 📊 Enterprise Logging & Performance Diagnostics (JDRepoConsole)
- Colorized Output: Distinct console styling with timestamps and icons for 5 log levels (
ERROR,WARN,INFO,DEBUG,SUCCESS). - Execution Profiling: Built-in performance timers (
JDRepoConsole.performance()). - Smart Release Mode: Suppresses verbose debug logs in production (
kReleaseMode) automatically.
7. 📑 Dynamic Data Grid & Table Models (Cell Models)
- Specialized data structures (
Cell<T>,RowofCells<T>,TableOfCells<T>) for dashboards, data tables, and dynamic forms.
🚀 Quick Start
1. Installation
Add jodija_repository to your pubspec.yaml:
dependencies:
jodija_repository: ^1.7.1
2. Configuration (assets/config/config.json)
Create an environment configuration file:
{
"baseUrls": {
"local": "http://10.0.2.2:5000/api/v1",
"remote_dev": "https://dev-api.matger.com/api/v1",
"remote_prod": "https://api.matger.com/api/v1"
},
"imageBaseUrls": {
"local": "http://10.0.2.2:5000/",
"remote_dev": "https://dev-api.matger.com/",
"remote_prod": "https://api.matger.com/"
},
"firebaseConfig": {
"dev": {
"apiKey": "AIzaSyDev...",
"appId": "1:12345:android:dev",
"messagingSenderId": "123456789",
"projectId": "matger-dev",
"storageBucket": "matger-dev.appspot.com"
},
"prod": {
"apiKey": "AIzaSyProd...",
"appId": "1:12345:android:prod",
"messagingSenderId": "987654321",
"projectId": "matger-prod",
"storageBucket": "matger-prod.appspot.com"
}
}
}
3. Bootstrap in App Startup
import 'package:flutter/material.dart';
import 'package:jodija_repository/jodija_repository.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// 1. Initialize configuration from asset
final config = AppConfiguration();
config.envType = EnvType.dev;
config.backendState = BackendState.remote_dev;
config.appType = AppType.App;
await config.backendRoutedInit('assets/config/config.json');
// 2. Set default language header
HttpHeader().setLangHeader(lang: 'ar');
JDRepoConsole.success('JoDija Repository successfully initialized');
runApp(const MyApp());
}
class AppConfiguration extends DataSourceConfigration {}
📖 Complete Documentation Portal
Explore detailed guides and reference documentation:
| Document | Description |
|---|---|
| 📄 Arabic Introduction (مقدمة باللغة العربية) | الشرح الكامل لفلسفة المكتبة وطبقاتها باللغة العربية. |
| 📄 English Introduction | Overview of layered architecture and core principles. |
| 🛠️ Matger Integration Guide (دليل التكامل مع متجر) | الدليل العملي لربط matger front logic مع matger express. |
| 🛠️ English Matger Integration Guide | Multi-solution integration guide for Matger business logic & Express backend. |
| ⚙️ DataSourceConfiguration | Environment routing, image URLs, and Firebase initialization. |
| 🌐 HttpClient & HttpHeader | Network requests (GET, POST, PUT, DELETE, PATCH) and language/auth headers. |
| 🖥️ JDRepoConsole Logging | Colored console logging, execution timing, and diagnostics. |
| 🛡️ HTTP Error Hierarchy | Strongly typed BaseError subclasses and failure handling. |
| 📚 Comprehensive Class Summary | Full breakdown of all repository interfaces and connectors. |
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
Libraries
- constes/api_urls
- constes/collections
- https/http_urls
- https/i_http_urls
- https/proudecBaseUrls
- interface/repo/crud_repo
- interface/sources/i_base_source
- interface/sources/i_base_stream
- interface/sources/i_json_base_source
- interface/sources/i_load_source
- interface/user/base/account
- interface/user/base/actions
- interface/user/firebase_acc
- interface/user/http_acc
- jodija
- jodija_configration
- jodija_repository
- A Flutter data repository and networking framework for single and multi-solution architectures with Dio HTTP client, Firebase integration, and strongly-typed error handling.
- model/user/base_model/base_user_module
- model/user/base_model/inhertid_models/user_model
- model/user/base_model/interface_userModel
- reposetory/load_data_reposatory
- reposetory/reposatory_stream
- reposetory/repsatory
- reposetory/user/auth_repo
- reposetory/user/profile_repo
- reposetory/user/users_repo
- source/firebase/crud_firebase_source
- source/firebase/stream_firebase
- source/http/crud_http_sources
- source/http/load_http_sources
- source/user/accountLoginLogout/firebase/auth_email_source
- source/user/accountLoginLogout/firebase/auth_google_source
- source/user/accountLoginLogout/firebase/proflle_actions
- source/user/accountLoginLogout/firebase/users_sourse
- source/user/accountLoginLogout/http/auth_http_acc
- utilis/errors/http_errors/bass_errors
- utilis/errors/http_errors/errors/bad_request_error
- utilis/errors/http_errors/errors/cancel_error
- utilis/errors/http_errors/errors/conflict_error
- utilis/errors/http_errors/errors/connection_error
- utilis/errors/http_errors/errors/custom_error
- utilis/errors/http_errors/errors/forbidden_error
- utilis/errors/http_errors/errors/format_error
- utilis/errors/http_errors/errors/internal_server_error
- utilis/errors/http_errors/errors/not_found_error
- utilis/errors/http_errors/errors/socket_error
- utilis/errors/http_errors/errors/timeout_error
- utilis/errors/http_errors/errors/unknown_error
- utilis/firebase/FCM
- utilis/firebase/firebase
- utilis/firebase/firebase_account
- utilis/firebase/firebase_and_storage_action
- utilis/firebase/fireBase_exception_consts
- utilis/firebase/firestore_inputs
- utilis/firebase/fuctions
- utilis/firebase/storage
- utilis/functions/functions
- utilis/functions/jd_repo_console
- utilis/http_remotes/http_client
- utilis/http_remotes/http_methos_enum
- utilis/json_reader/json_asset_reader
- utilis/models/base_data_model
- utilis/models/cell_models/cell
- utilis/models/cell_models/data-operations
- utilis/models/cell_models/modulscreateor
- utilis/models/cell_models/row_cells
- utilis/models/remote_base_model
- utilis/models/staus_model
- utilis/platform/io_stub
- utilis/result/result
- utilis/result/result_data_indecator
- utilis/result/user_result