Files
worker/PROJECT_STRUCTURE.md
Phuoc Nguyen 4ecb236532 update payment
2025-12-01 10:03:24 +07:00

13 KiB

Worker App Project Structure

lib/
  core/
    constants/
      api_constants.dart          # API endpoints, timeouts
      app_constants.dart          # App config, defaults, loyalty tiers
      ui_constants.dart           # Spacing, sizes, colors
      storage_constants.dart      # Hive box names, keys
    theme/
      app_theme.dart              # Material 3 theme (primary blue #005B9A)
      colors.dart                 # Brand color schemes
      typography.dart             # Roboto text styles
    network/
      dio_client.dart             # HTTP client setup
      api_interceptor.dart        # Auth token, logging interceptors
      network_info.dart           # Connectivity status
    errors/
      exceptions.dart             # Custom exceptions
      failures.dart               # Failure classes
    utils/
      formatters.dart             # Currency, date, phone formatters
      validators.dart             # Form validation (Vietnamese phone, email)
      extensions.dart             # Dart extensions
      qr_generator.dart           # QR code generation for member cards
    widgets/
      custom_button.dart          # Primary, secondary buttons
      loading_indicator.dart      # Loading states
      error_widget.dart           # Error displays
      empty_state.dart            # Empty list UI
      bottom_nav_bar.dart         # Main bottom navigation
      floating_chat_button.dart   # FAB for chat

  features/
    auth/
      data/
        datasources/
          auth_remote_datasource.dart    # Login, OTP, register APIs
          auth_local_datasource.dart     # Token storage
        models/
          user_model.dart                # User with tier info
          otp_response_model.dart
        repositories/
          auth_repository_impl.dart
      domain/
        entities/
          user.dart                      # id, name, phone, email, tier, points
        repositories/
          auth_repository.dart
        usecases/
          login_with_phone.dart
          verify_otp.dart
          register_user.dart
          logout.dart
          get_current_user.dart
      presentation/
        providers/
          auth_provider.dart
          otp_timer_provider.dart
        pages/
          login_page.dart                # Phone input
          otp_verification_page.dart     # 6-digit OTP
          register_page.dart             # Full registration form
        widgets/
          phone_input_field.dart
          otp_input_field.dart           # Auto-focus 6 digits
          user_type_selector.dart        # Contractor/Architect/etc

    home/
      data/
        datasources/
          member_card_local_datasource.dart
        models/
          member_card_model.dart
      presentation/
        providers/
          member_card_provider.dart
        pages:
          home_page.dart                 # Main dashboard
        widgets:
          diamond_member_card.dart       # Gradient card with QR
          platinum_member_card.dart
          gold_member_card.dart
          quick_action_grid.dart

    loyalty/
      data/
        datasources:
          loyalty_remote_datasource.dart
          loyalty_local_datasource.dart
        models:
          loyalty_points_model.dart
          loyalty_transaction_model.dart
          reward_model.dart
          gift_model.dart
          referral_model.dart
        repositories:
          loyalty_repository_impl.dart
      domain:
        entities:
          loyalty_points.dart            # currentPoints, tier, nextTierPoints
          loyalty_transaction.dart       # id, type, amount, description, date
          reward.dart                    # id, title, pointsCost, image, expiry
          gift.dart                      # id, code, status, validFrom, validTo
          referral.dart                  # code, link, totalReferrals, pointsEarned
        repositories:
          loyalty_repository.dart
        usecases:
          get_loyalty_points.dart
          get_points_history.dart
          redeem_reward.dart
          get_available_rewards.dart
          get_my_gifts.dart
          get_referral_info.dart
          share_referral.dart
      presentation:
        providers:
          loyalty_points_provider.dart
          points_history_provider.dart
          rewards_provider.dart
          gifts_provider.dart
          referral_provider.dart
        pages:
          loyalty_page.dart              # Progress bar, tier info
          rewards_page.dart              # Grid of redeemable rewards
          points_history_page.dart       # Transaction list
          referral_page.dart             # Referral link & code
          my_gifts_page.dart             # Tabs: Active/Used/Expired
        widgets:
          tier_progress_bar.dart
          points_badge.dart
          reward_card.dart
          gift_card.dart
          referral_share_sheet.dart

    products/
      data:
        datasources:
          product_remote_datasource.dart
          product_local_datasource.dart
        models:
          product_model.dart             # Tile/construction products
          category_model.dart
        repositories:
          product_repository_impl.dart
      domain:
        entities:
          product.dart                   # id, name, sku, price, images, category
          category.dart
        repositories:
          product_repository.dart
        usecases:
          get_all_products.dart
          search_products.dart
          get_products_by_category.dart
          get_product_details.dart
      presentation:
        providers:
          products_provider.dart
          product_search_provider.dart
          categories_provider.dart
        pages:
          products_page.dart             # Grid with search & filters
          product_detail_page.dart
        widgets:
          product_grid.dart
          product_card.dart
          product_search_bar.dart
          category_filter_chips.dart

    cart/
      data:
        datasources:
          cart_local_datasource.dart     # Hive persistence
        models:
          cart_item_model.dart
        repositories:
          cart_repository_impl.dart
      domain:
        entities:
          cart_item.dart                 # productId, quantity, price
        repositories:
          cart_repository.dart
        usecases:
          add_to_cart.dart
          remove_from_cart.dart
          update_quantity.dart
          clear_cart.dart
          get_cart_items.dart
          calculate_cart_total.dart
      presentation:
        providers:
          cart_provider.dart
          cart_total_provider.dart
        pages:
          cart_page.dart
          checkout_page.dart
          order_success_page.dart
        widgets:
          cart_item_card.dart
          cart_summary.dart
          quantity_selector.dart
          payment_method_selector.dart

    orders/
      data:
        datasources:
          order_remote_datasource.dart
          order_local_datasource.dart
        models:
          order_model.dart
          order_item_model.dart
          payment_model.dart
        repositories:
          order_repository_impl.dart
      domain:
        entities:
          order.dart                     # orderNumber, items, total, status
          order_item.dart
          payment.dart
        repositories:
          order_repository.dart
        usecases:
          create_order.dart
          get_orders.dart
          get_order_details.dart
          get_payments.dart
      presentation:
        providers:
          orders_provider.dart
          order_filter_provider.dart
          payments_provider.dart
        pages:
          orders_page.dart               # Tabs by status
          order_detail_page.dart
          payments_page.dart
        widgets:
          order_card.dart
          order_status_badge.dart
          order_timeline.dart
          payment_card.dart

    projects/
      data:
        datasources:
          project_remote_datasource.dart
          project_local_datasource.dart
        models:
          project_model.dart
          quote_model.dart
        repositories:
          project_repository_impl.dart
      domain:
        entities:
          project.dart                   # name, client, location, progress, status
          quote.dart                     # number, client, amount, validity, status
        repositories:
          project_repository.dart
        usecases:
          create_project.dart
          get_projects.dart
          update_project_progress.dart
          create_quote.dart
          get_quotes.dart
      presentation:
        providers:
          projects_provider.dart
          project_form_provider.dart
          quotes_provider.dart
        pages:
          projects_page.dart             # List with progress bars
          project_create_page.dart       # Form
          project_detail_page.dart
          quotes_page.dart
          quote_create_page.dart
        widgets:
          project_card.dart
          project_progress_bar.dart
          quote_card.dart
          project_form.dart

    chat/
      data:
        datasources:
          chat_remote_datasource.dart    # WebSocket/REST
          chat_local_datasource.dart
        models:
          message_model.dart
          chat_room_model.dart
        repositories:
          chat_repository_impl.dart
      domain:
        entities:
          message.dart                   # id, text, senderId, timestamp, isRead
          chat_room.dart
        repositories:
          chat_repository.dart
        usecases:
          send_message.dart
          get_messages.dart
          mark_as_read.dart
      presentation:
        providers:
          chat_provider.dart
          messages_provider.dart
          typing_indicator_provider.dart
        pages:
          chat_page.dart
        widgets:
          message_bubble.dart
          message_input.dart
          typing_indicator.dart
          chat_app_bar.dart

    account/
      data:
        datasources:
          profile_remote_datasource.dart
          profile_local_datasource.dart
          address_datasource.dart
        models:
          profile_model.dart
          address_model.dart
        repositories:
          profile_repository_impl.dart
          address_repository_impl.dart
      domain:
        entities:
          profile.dart                   # Extended user info
          address.dart                   # Delivery addresses
        repositories:
          profile_repository.dart
          address_repository.dart
        usecases:
          get_profile.dart
          update_profile.dart
          upload_avatar.dart
          change_password.dart
          get_addresses.dart
          add_address.dart
          update_address.dart
          delete_address.dart
      presentation:
        providers:
          profile_provider.dart
          avatar_provider.dart
          addresses_provider.dart
        pages:
          account_page.dart              # Menu
          profile_edit_page.dart
          addresses_page.dart
          address_form_page.dart
          password_change_page.dart
        widgets:
          profile_header.dart
          account_menu_item.dart
          address_card.dart
          avatar_picker.dart

    promotions/
      data:
        datasources:
          promotion_remote_datasource.dart
        models:
          promotion_model.dart
        repositories:
          promotion_repository_impl.dart
      domain:
        entities:
          promotion.dart                 # title, description, discount, validity
        repositories:
          promotion_repository.dart
        usecases:
          get_active_promotions.dart
      presentation:
        providers:
          promotions_provider.dart
        pages:
          promotions_page.dart
        widgets:
          promotion_card.dart
          promotion_banner.dart

    notifications/
      data:
        datasources:
          notification_remote_datasource.dart
          notification_local_datasource.dart
        models:
          notification_model.dart
        repositories:
          notification_repository_impl.dart
      domain:
        entities:
          notification.dart              # title, body, type, isRead, timestamp
        repositories:
          notification_repository.dart
        usecases:
          get_notifications.dart
          mark_as_read.dart
          clear_all.dart
      presentation:
        providers:
          notifications_provider.dart
          notification_badge_provider.dart
        pages:
          notifications_page.dart        # Tabs: All/Orders/System/Promos
        widgets:
          notification_card.dart
          notification_badge.dart

  shared/
    widgets/
      custom_app_bar.dart
      gradient_card.dart                 # For member cards
      status_badge.dart
      price_display.dart
      vietnamese_phone_field.dart
      date_picker_field.dart

  main.dart
  app.dart                               # Root widget with ProviderScope

test/
  unit/
    features/
      auth/
      loyalty/
      products/
      cart/
      orders/
      projects/
  widget/
    widgets/
  integration/