Skip to main content

📦 12 Modules Architecture - MStore Mobile

🎯 Overview

MStore Mobile menggunakan 12 modul utama yang terorganisir dalam 2 layer:
  1. /core → Data layer (services, repositories, models)
  2. /features → Presentation layer (UI, pages, widgets, Bloc)

📋 12 Modul Lengkap (EXACT Structure)

⚠️ IMPORTANT: Numbered Folders

Untuk memastikan EXACT 12 modules, setiap folder diberi prefix nomor:
  • /core/01_core/ hingga /core/12_global/
  • /features/01_core/ hingga /features/12_global/
Ini memastikan tidak ada folder tambahan dan struktur tetap konsisten.

1️⃣ Core Module - Authentication & System

Scope: auth, roles, system, tenant, registry

/core/01_core/

lib/core/01_core/
├── services/
│   ├── auth_service.dart           # Authentication service
│   ├── role_service.dart           # Role management
│   ├── system_service.dart         # System configuration
│   ├── tenant_service.dart         # Multi-tenant management
│   └── registry_service.dart       # Registry & metadata
├── repositories/
│   ├── auth_repository.dart
│   ├── role_repository.dart
│   └── system_repository.dart
└── models/
    ├── auth_models.dart
    ├── role_models.dart
    └── tenant_models.dart

/features/core/

lib/features/core/
├── auth/
│   ├── bloc/
│   │   ├── auth_bloc.dart
│   │   ├── auth_event.dart
│   │   └── auth_state.dart
│   └── widgets/
│       ├── login_form.dart
│       └── register_form.dart
├── pages/
│   ├── login_page.dart
│   ├── register_page.dart
│   └── splash_page.dart
└── roles/
    ├── bloc/
    │   ├── role_bloc.dart
    │   ├── role_event.dart
    │   └── role_state.dart
    └── pages/
        └── role_selection_page.dart

2️⃣ Finance Module

Scope: invoice, payment, AR/AP, ledger, reconciliations

/core/finance/

lib/core/finance/
├── services/
│   ├── invoice_service.dart
│   ├── payment_service.dart
│   ├── ar_service.dart             # Accounts Receivable
│   ├── ap_service.dart             # Accounts Payable
│   ├── ledger_service.dart
│   └── reconciliation_service.dart
├── repositories/
│   ├── invoice_repository.dart
│   ├── payment_repository.dart
│   └── ledger_repository.dart
└── models/
    ├── invoice_models.dart
    ├── payment_models.dart
    └── ledger_models.dart

/features/finance/

lib/features/finance/
├── invoice/
│   ├── bloc/
│   ├── pages/
│   │   ├── invoice_list_page.dart
│   │   └── invoice_detail_page.dart
│   └── widgets/
│       └── invoice_card.dart
├── payment/
│   ├── bloc/
│   ├── pages/
│   │   └── payment_page.dart
│   └── widgets/
│       └── payment_method_selector.dart
├── ar/
│   └── pages/
│       └── ar_dashboard_page.dart
├── ap/
│   └── pages/
│       └── ap_dashboard_page.dart
└── reconciliation/
    └── pages/
        └── reconciliation_page.dart

3️⃣ Inventory Module

Scope: product, stock, goods receipt, adjustments

/core/inventory/

lib/core/inventory/
├── services/
│   ├── product_service.dart
│   ├── stock_service.dart
│   ├── goods_receipt_service.dart
│   └── adjustment_service.dart
├── repositories/
│   ├── product_repository.dart
│   └── stock_repository.dart
└── models/
    ├── product_models.dart
    ├── stock_models.dart
    └── adjustment_models.dart

/features/inventory/

lib/features/inventory/
├── product/
│   ├── bloc/
│   ├── pages/
│   │   ├── product_list_page.dart
│   │   └── product_detail_page.dart
│   └── widgets/
│       └── product_card.dart
├── stock/
│   ├── bloc/
│   ├── pages/
│   │   ├── stock_opname_page.dart
│   │   └── stock_movement_page.dart
│   └── widgets/
│       └── stock_card.dart
└── adjustment/
    └── pages/
        └── adjustment_page.dart

4️⃣ Procurement Module

Scope: PO, supplier, RFQ, approvals

/core/procurement/

lib/core/procurement/
├── services/
│   ├── po_service.dart             # Purchase Order
│   ├── supplier_service.dart
│   ├── rfq_service.dart            # Request for Quotation
│   └── approval_service.dart
├── repositories/
│   ├── po_repository.dart
│   └── supplier_repository.dart
└── models/
    ├── po_models.dart
    ├── supplier_models.dart
    └── rfq_models.dart

/features/procurement/

lib/features/procurement/
├── po/
│   ├── bloc/
│   ├── pages/
│   │   ├── po_list_page.dart
│   │   └── po_create_page.dart
│   └── widgets/
│       └── po_card.dart
├── supplier/
│   ├── bloc/
│   └── pages/
│       └── supplier_list_page.dart
└── approval/
    └── pages/
        └── approval_page.dart

5️⃣ Sales/POS Module

Scope: SO, POS, receipts, pricing, discounts

/core/sales/

lib/core/sales/
├── services/
│   ├── so_service.dart             # Sales Order
│   ├── pos_service.dart
│   ├── receipt_service.dart
│   ├── pricing_service.dart
│   └── discount_service.dart
├── repositories/
│   ├── sales_repository.dart
│   └── pos_repository.dart
└── models/
    ├── sales_models.dart
    ├── pos_models.dart
    └── receipt_models.dart

/features/sales/

lib/features/sales/
├── pos/
│   ├── bloc/
│   │   ├── checkout_bloc.dart
│   │   ├── cart_bloc.dart
│   │   └── payment_bloc.dart
│   ├── pages/
│   │   ├── cashier_home_page.dart
│   │   ├── checkout_page.dart
│   │   └── payment_page.dart
│   └── widgets/
│       ├── product_grid.dart
│       ├── cart_widget.dart
│       └── payment_method_widget.dart
├── so/
│   └── pages/
│       └── sales_order_page.dart
└── receipt/
    └── pages/
        └── receipt_history_page.dart

6️⃣ HR Module

Scope: employee, payroll, attendance, leave

/core/hr/

lib/core/hr/
├── services/
│   ├── employee_service.dart
│   ├── payroll_service.dart
│   ├── attendance_service.dart
│   └── leave_service.dart
├── repositories/
│   ├── employee_repository.dart
│   └── attendance_repository.dart
└── models/
    ├── employee_models.dart
    ├── payroll_models.dart
    └── attendance_models.dart

/features/hr/

lib/features/hr/
├── employee/
│   ├── bloc/
│   └── pages/
│       └── employee_list_page.dart
├── attendance/
│   ├── bloc/
│   └── pages/
│       └── attendance_page.dart
└── payroll/
    └── pages/
        └── payroll_page.dart

7️⃣ Marketing & CRM Module

Scope: campaign, leads, CRM automation, segmentation

/core/crm/

lib/core/crm/
├── services/
│   ├── campaign_service.dart
│   ├── lead_service.dart
│   ├── customer_service.dart
│   ├── automation_service.dart
│   └── segmentation_service.dart
├── repositories/
│   ├── campaign_repository.dart
│   └── customer_repository.dart
└── models/
    ├── campaign_models.dart
    ├── lead_models.dart
    └── customer_models.dart

/features/crm/

lib/features/crm/
├── campaign/
│   ├── bloc/
│   └── pages/
│       └── campaign_page.dart
├── lead/
│   ├── bloc/
│   └── pages/
│       └── lead_page.dart
└── customer/
    └── pages/
        └── customer_page.dart

8️⃣ Customer Service Module

Scope: ticketing, SLA, chat integration

/core/cs/

lib/core/cs/
├── services/
│   ├── ticket_service.dart
│   ├── sla_service.dart
│   └── chat_service.dart
├── repositories/
│   ├── ticket_repository.dart
│   └── chat_repository.dart
└── models/
    ├── ticket_models.dart
    └── sla_models.dart

/features/cs/

lib/features/cs/
├── ticket/
│   ├── bloc/
│   └── pages/
│       ├── ticket_list_page.dart
│       └── ticket_detail_page.dart
└── chat/
    └── pages/
        └── chat_page.dart

9️⃣ Audit & Compliance Module

Scope: audit logs, SoD engine, report export

/core/audit/

lib/core/audit/
├── services/
│   ├── audit_log_service.dart
│   ├── sod_service.dart            # Segregation of Duties
│   ├── compliance_service.dart
│   └── report_export_service.dart
├── repositories/
│   ├── audit_repository.dart
│   └── compliance_repository.dart
└── models/
    ├── audit_models.dart
    └── compliance_models.dart

/features/audit/

lib/features/audit/
├── logs/
│   ├── bloc/
│   └── pages/
│       └── audit_log_page.dart
├── compliance/
│   └── pages/
│       └── compliance_dashboard_page.dart
└── export/
    └── pages/
        └── report_export_page.dart

🔟 Analytics/BI Module

Scope: dashboards, KPI, forecast, exports

/core/analytics/

lib/core/analytics/
├── services/
│   ├── dashboard_service.dart
│   ├── kpi_service.dart
│   ├── forecast_service.dart
│   └── export_service.dart
├── repositories/
│   ├── analytics_repository.dart
│   └── kpi_repository.dart
└── models/
    ├── dashboard_models.dart
    ├── kpi_models.dart
    └── forecast_models.dart

/features/analytics/

lib/features/analytics/
├── dashboard/
│   ├── bloc/
│   └── pages/
│       └── analytics_dashboard_page.dart
├── kpi/
│   └── pages/
│       └── kpi_page.dart
└── forecast/
    └── pages/
        └── forecast_page.dart

1️⃣1️⃣ Holding/Multi-Entity Module

Scope: entity registry, consolidation, intercompany tx

/core/holding/

lib/core/holding/
├── services/
│   ├── entity_service.dart
│   ├── consolidation_service.dart
│   └── intercompany_service.dart
├── repositories/
│   ├── entity_repository.dart
│   └── consolidation_repository.dart
└── models/
    ├── entity_models.dart
    └── consolidation_models.dart

/features/holding/

lib/features/holding/
├── entity/
│   ├── bloc/
│   └── pages/
│       └── entity_page.dart
└── consolidation/
    └── pages/
        └── consolidation_page.dart

1️⃣2️⃣ Global/Security Module

Scope: IAM, SSO, OPA/Policy, ESG & legal notices

/core/global/

lib/core/global/
├── services/
│   ├── iam_service.dart            # Identity & Access Management
│   ├── sso_service.dart            # Single Sign-On
│   ├── policy_service.dart         # OPA Policy
│   ├── esg_service.dart            # ESG compliance
│   └── legal_service.dart
├── repositories/
│   ├── iam_repository.dart
│   └── policy_repository.dart
└── models/
    ├── iam_models.dart
    └── policy_models.dart

/features/global/

lib/features/global/
├── iam/
│   ├── bloc/
│   └── pages/
│       └── iam_page.dart
├── policy/
│   └── pages/
│       └── policy_page.dart
└── esg/
    └── pages/
        └── esg_dashboard_page.dart

📊 Current vs Target Structure

Current Structure Issues:

❌ Mixed naming: cashier_pos, operations, ops → should be sales
❌ Scattered modules: dashboard, dashboard_kpi → should be in analytics
❌ Missing modules: procurement, holding, global
❌ Inconsistent structure between /core and /features

Target Structure (12 Modules):

1. core - auth, roles, system, tenant, registry
2. finance - invoice, payment, AR/AP, ledger, reconciliations
3. inventory - product, stock, goods receipt, adjustments
4. procurement - PO, supplier, RFQ, approvals
5. sales - SO, POS, receipts, pricing, discounts
6. hr - employee, payroll, attendance, leave
7. crm - campaign, leads, CRM automation, segmentation
8. cs - ticketing, SLA, chat integration
9. audit - audit logs, SoD engine, report export
10. analytics - dashboards, KPI, forecast, exports
11. holding - entity registry, consolidation, intercompany tx
12. global - IAM, SSO, OPA/Policy, ESG & legal notices

🔄 Migration Plan

Phase 1: Rename & Consolidate

# Rename modules
mv lib/core/cashier_pos lib/core/sales
mv lib/features/cashier lib/features/sales

# Consolidate analytics
mv lib/core/dashboard_kpi/* lib/core/analytics/
mv lib/core/dashboard/* lib/core/analytics/

# Consolidate operations → inventory
mv lib/core/operations/* lib/core/inventory/
mv lib/features/operations/inventory/* lib/features/inventory/

Phase 2: Create Missing Modules

# Create procurement
mkdir -p lib/core/procurement/{services,repositories,models}
mkdir -p lib/features/procurement/{po,supplier,approval}

# Create holding
mkdir -p lib/core/holding/{services,repositories,models}
mkdir -p lib/features/holding/{entity,consolidation}

# Create global
mkdir -p lib/core/global/{services,repositories,models}
mkdir -p lib/features/global/{iam,policy,esg}

Phase 3: Standardize Structure

Setiap modul harus follow pattern:
/core/{module}/
  ├── services/
  ├── repositories/
  └── models/

/features/{module}/
  ├── {sub-feature}/
  │   ├── bloc/
  │   ├── pages/
  │   └── widgets/

📝 Naming Conventions

Core Layer

  • Services: {entity}_service.dart (e.g., invoice_service.dart)
  • Repositories: {entity}_repository.dart (e.g., invoice_repository.dart)
  • Models: {entity}_models.dart (e.g., invoice_models.dart)

Features Layer

  • Bloc: {feature}_bloc.dart, {feature}_event.dart, {feature}_state.dart
  • Pages: {feature}_{action}_page.dart (e.g., invoice_list_page.dart)
  • Widgets: {feature}_{component}.dart (e.g., invoice_card.dart)

🎯 Benefits

1. Clear Separation of Concerns

  • /core → Business logic & data
  • /features → UI & presentation

2. Scalable Architecture

  • Easy to add new features per module
  • Independent development per team

3. Consistent Structure

  • Same pattern across all 12 modules
  • Easy onboarding for new developers

4. Aligned with Backend

  • Matches backend domain structure
  • Easier API integration


📌 Status

  • Documentation: Complete
  • 🔄 Implementation: In Progress
  • Migration: Pending
Last Updated: 2025-11-06