Skip to content

Basith-08/EcooLoop_Mart

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

EcoLoop Mart - Ekosistem Tukar Sampah Jadi Sembako

EcoLoop Mart Logo

Aplikasi Flutter dengan arsitektur MVVM untuk sistem tukar sampah menjadi poin yang dapat ditukar dengan sembako. Mendukung dua role: Admin dan Warga.

๐ŸŒ Multi-Platform Support

โœ… Android | โœ… iOS | โœ… Web | โœ… Windows | โœ… macOS | โœ… Linux

EcoLoop Mart sekarang mendukung SEMUA platform Flutter! Lihat MULTIPLATFORM.md untuk panduan lengkap build dan deployment di berbagai platform.


๐Ÿณ Development dengan Docker

Gunakan Docker untuk menjalankan lingkungan pengembangan tanpa harus memasang Flutter secara lokal.

  • Prasyarat: Docker Desktop/Engine dan Docker Compose terpasang.
  • Jalankan ./scripts/dev_docker.sh untuk build image dan menjalankan flutter run -d web-server pada http://localhost:8080.
  • Atau gunakan manual: docker compose -f docker/docker-compose.yml up --build.
  • Eksekusi perintah di dalam kontainer (mis. tes): docker compose -f docker/docker-compose.yml exec flutter_app flutter test.
  • Hot reload bekerja di dalam kontainer; edit kode di host dan gunakan shortcut Flutter di terminal yang menjalankan kontainer.
  • Build Android APK tanpa install Flutter lokal: ./scripts/docker_build_apk.sh (hasil: build/app/outputs/flutter-apk/app-release.apk).
  • Kontainer ini ditujukan untuk build; emulator/USB passthrough tidak dikonfigurasi. Untuk menjalankan di device, gunakan Flutter lokal atau sesuaikan Compose agar adb dapat melihat device host.
  • Jika saat flutter run muncul peringatan "SDK XML version ...", perbarui Android Command-line Tools ke versi terbaru (bisa lewat SDK Manager Android Studio atau rebuild Docker image yang sudah memakai tools terbaru).

๐Ÿ“ฑ Fitur Utama

๐Ÿ” Autentikasi

  • Login untuk Admin dan Warga
  • Registrasi akun baru (Warga)
  • Manajemen session dengan AuthViewModel
  • Default admin account: username: admin, password: admin123

๐Ÿ‘จโ€๐Ÿ’ผ Fitur Admin

Dashboard

  • Statistik: Total Warga dan Barang Mart
  • Input Setoran Sampah
    • Pilih warga dari dropdown
    • Pilih jenis sampah: Kardus Bekas (Rp 20/kg), Botol Plastik (Rp 35/kg), Kaleng Aluminium (Rp 50/kg), Minyak Jelantah (Rp 40/liter)
    • Input berat/jumlah
    • Kalkulasi otomatis estimasi poin
    • Proses setoran langsung update wallet user

Gudang/Warehouse

  • Manajemen stok barang mart
  • Tambah, Edit, Hapus produk
  • Tracking stok dan poin tiap produk
  • Kategori icon untuk produk

Manajemen Akun

  • Tambah akun Warga atau Admin baru
  • Edit data user
  • Hapus user (dengan proteksi admin terakhir)
  • Lihat daftar semua akun

๐Ÿ‘ฅ Fitur Warga/User

Mart (Toko)

  • Browse produk yang tersedia
  • Grid view dengan icon kategori
  • Tambah produk ke keranjang
  • Badge "PAKET LITE" untuk bundle
  • Checkout dengan validasi saldo
  • Update stok otomatis setelah pembelian

Dompet/Wallet

  • Tampilan saldo EcoPoin
  • Konversi ke Rupiah (1 poin = Rp 150)
  • QR Code ID Member
  • Info tentang EcoPoin
  • Tips hemat

Riwayat Transaksi

  • List semua transaksi (Setor Sampah & Tukar Barang)
  • Color-coded: Hijau untuk deposit (+), Merah untuk pembelian (-)
  • Detail jenis sampah atau produk
  • Tanggal transaksi

Profil

  • Info akun lengkap
  • Tanggal bergabung
  • Sisa saldo
  • Status akun (ACTIVE/INACTIVE)
  • Logout

QR Code

  • Generate QR code dengan user ID
  • Untuk scan di petugas loket
  • Tampilkan info user dan saldo

๐Ÿ—๏ธ Arsitektur MVVM

lib/
โ”œโ”€โ”€ core/
โ”‚   โ””โ”€โ”€ database/
โ”‚       โ”œโ”€โ”€ db_helper.dart           # SQLite helper
โ”‚       โ””โ”€โ”€ db_config.dart           # Database configuration
โ”‚
โ”œโ”€โ”€ data/
โ”‚   โ”œโ”€โ”€ models/
โ”‚   โ”‚   โ”œโ”€โ”€ user_model.dart          # User entity
โ”‚   โ”‚   โ”œโ”€โ”€ product_model.dart       # Product entity
โ”‚   โ”‚   โ”œโ”€โ”€ transaction_model.dart   # Transaction entity
โ”‚   โ”‚   โ”œโ”€โ”€ wallet_model.dart        # Wallet entity
โ”‚   โ”‚   โ””โ”€โ”€ cart_item_model.dart     # Cart item entity
โ”‚   โ”‚
โ”‚   โ””โ”€โ”€ repositories/
โ”‚       โ”œโ”€โ”€ user_repository.dart      # User CRUD + Auth
โ”‚       โ”œโ”€โ”€ product_repository.dart   # Product CRUD
โ”‚       โ”œโ”€โ”€ transaction_repository.dart  # Transaction CRUD
โ”‚       โ””โ”€โ”€ wallet_repository.dart    # Wallet CRUD
โ”‚
โ”œโ”€โ”€ state/
โ”‚   โ”œโ”€โ”€ auth_state.dart              # Authentication states
โ”‚   โ”œโ”€โ”€ user_state.dart              # User states
โ”‚   โ”œโ”€โ”€ product_state.dart           # Product states
โ”‚   โ”œโ”€โ”€ transaction_state.dart       # Transaction states
โ”‚   โ”œโ”€โ”€ wallet_state.dart            # Wallet states
โ”‚   โ””โ”€โ”€ cart_state.dart              # Cart states
โ”‚
โ”œโ”€โ”€ viewmodel/
โ”‚   โ”œโ”€โ”€ auth_viewmodel.dart          # Auth business logic
โ”‚   โ”œโ”€โ”€ user_viewmodel.dart          # User business logic
โ”‚   โ”œโ”€โ”€ product_viewmodel.dart       # Product business logic
โ”‚   โ”œโ”€โ”€ transaction_viewmodel.dart   # Transaction business logic
โ”‚   โ”œโ”€โ”€ wallet_viewmodel.dart        # Wallet business logic
โ”‚   โ””โ”€โ”€ cart_viewmodel.dart          # Cart business logic
โ”‚
โ”œโ”€โ”€ view/
โ”‚   โ”œโ”€โ”€ auth/
โ”‚   โ”‚   โ”œโ”€โ”€ login_page.dart          # Login UI
โ”‚   โ”‚   โ””โ”€โ”€ register_page.dart       # Register UI
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ admin/
โ”‚   โ”‚   โ”œโ”€โ”€ admin_home_page.dart     # Admin navigation
โ”‚   โ”‚   โ”œโ”€โ”€ admin_dashboard_page.dart   # Dashboard + Input Setoran
โ”‚   โ”‚   โ”œโ”€โ”€ admin_warehouse_page.dart   # Product management
โ”‚   โ”‚   โ””โ”€โ”€ admin_account_page.dart     # User management
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ warga/
โ”‚   โ”‚   โ”œโ”€โ”€ warga_home_page.dart     # User navigation
โ”‚   โ”‚   โ”œโ”€โ”€ mart_page.dart           # Shop + Cart
โ”‚   โ”‚   โ”œโ”€โ”€ wallet_page.dart         # Wallet + QR
โ”‚   โ”‚   โ”œโ”€โ”€ transaction_history_page.dart  # Transaction list
โ”‚   โ”‚   โ””โ”€โ”€ profile_page.dart        # User profile
โ”‚   โ”‚
โ”‚   โ””โ”€โ”€ widgets/
โ”‚       โ””โ”€โ”€ qr_code_dialog.dart      # QR code widget
โ”‚
โ””โ”€โ”€ main.dart                        # App entry point

๐Ÿ’พ Database Schema

Table: users

CREATE TABLE users (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  name TEXT NOT NULL,
  username TEXT NOT NULL UNIQUE,
  password TEXT NOT NULL,
  role TEXT NOT NULL DEFAULT 'warga',        -- 'admin' or 'warga'
  email TEXT,
  phone TEXT,
  eco_points REAL NOT NULL DEFAULT 0.0,
  status TEXT NOT NULL DEFAULT 'active',      -- 'active' or 'inactive'
  created_at TEXT NOT NULL,
  updated_at TEXT NOT NULL
)

Table: products

CREATE TABLE products (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  name TEXT NOT NULL,
  description TEXT,
  price REAL NOT NULL,                        -- in EcoPoin
  stock INTEGER NOT NULL DEFAULT 0,
  image_url TEXT,
  category TEXT,                              -- for icon selection
  is_eco_friendly INTEGER DEFAULT 0,
  created_at TEXT NOT NULL,
  updated_at TEXT NOT NULL
)

Table: transactions

CREATE TABLE transactions (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  user_id INTEGER NOT NULL,
  product_id INTEGER,                         -- NULL for deposit
  quantity INTEGER NOT NULL,
  total_price REAL NOT NULL,                  -- points
  transaction_date TEXT NOT NULL,
  status TEXT NOT NULL,                       -- 'completed', 'pending', 'cancelled'
  type TEXT NOT NULL,                         -- 'deposit' or 'purchase'
  waste_type TEXT,                            -- for deposit: 'Kardus Bekas', etc.
  product_name TEXT,                          -- for purchase
  FOREIGN KEY (user_id) REFERENCES users (id),
  FOREIGN KEY (product_id) REFERENCES products (id)
)

Table: wallets

CREATE TABLE wallets (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  user_id INTEGER NOT NULL UNIQUE,
  eco_points REAL NOT NULL DEFAULT 0.0,
  rupiah_value REAL NOT NULL DEFAULT 0.0,     -- calculated: points ร— 150
  updated_at TEXT NOT NULL,
  FOREIGN KEY (user_id) REFERENCES users (id)
)

๐ŸŽจ Design System

Color Palette

  • Primary Green: #2D9F5D - Brand color, Warga theme
  • Orange: #FF8C42 - Admin theme, accents
  • Blue: #4169E1 - Info, statistics
  • Light Green: #F0F7F4 - Background
  • Success Green: #E8F5E9 - Success states
  • Error Red: #F44336 - Errors, negative values

Typography

  • Material 3 default typography
  • Bold weights for headers and buttons

Components

  • Cards: Rounded 12px, elevation 2
  • Buttons: Rounded 8px, padding 16px vertical
  • Inputs: Rounded 8px, filled white background
  • Bottom Navigation: Fixed type, 5 items max

๐Ÿ“ฆ Dependencies

dependencies:
  flutter:
    sdk: flutter

  # State Management
  provider: ^6.1.1

  # Database
  sqflite: ^2.3.0
  path: ^1.8.3

  # QR Code
  qr_flutter: ^4.1.0

  # Date Formatting
  intl: ^0.18.1

  # UI Components
  cupertino_icons: ^1.0.6

๐Ÿš€ Installation & Setup

Prasyarat

  • Flutter SDK >= 3.0.0
  • Dart SDK
  • Android Studio / VS Code
  • Android Emulator atau Physical Device

Langkah Instalasi

  1. Clone atau navigasi ke project

    cd "/home/asfine/Basith/Semeseter 5/pemrograman_android/EcoLoop_Mart"
  2. Install dependencies

    flutter pub get
  3. Run aplikasi

    Mobile:

    # Android
    flutter run -d android
    
    # iOS (macOS only)
    flutter run -d ios

    Web:

    flutter run -d chrome
    # atau
    ./scripts/run_web.sh

    Desktop:

    # Windows
    flutter run -d windows
    
    # macOS
    flutter run -d macos
    
    # Linux
    flutter run -d linux

    Auto-detect (default):

    flutter run

First Time Setup

Saat aplikasi pertama kali dijalankan:

  1. Database akan otomatis dibuat
  2. Admin default akan dibuat:
    • Username: admin
    • Password: admin123
    • Role: admin
  3. Gunakan akun admin untuk:
    • Menambah produk ke warehouse
    • Membuat akun warga
    • Input setoran sampah

๐Ÿ“ฑ User Flow

Flow Warga

  1. Register โ†’ Buat akun dengan nama lengkap, username, password
  2. Login โ†’ Tab WARGA, masukkan username & password
  3. Kumpulkan Sampah โ†’ Bawa ke petugas loket
  4. Scan QR โ†’ Petugas scan QR code user
  5. Admin Input Setoran โ†’ Admin input jenis & berat sampah
  6. Poin Masuk โ†’ Wallet user otomatis bertambah
  7. Belanja di Mart โ†’ Pilih produk, tambah ke cart, checkout
  8. Poin Berkurang โ†’ Wallet terpotong sesuai harga

Flow Admin

  1. Login โ†’ Tab ADMIN, username: admin, password: admin123
  2. Dashboard โ†’ Lihat statistik, input setoran warga
  3. Gudang โ†’ Kelola stok produk (tambah/edit/hapus)
  4. Akun โ†’ Kelola user (tambah/edit/hapus warga & admin)

๐Ÿ”„ Business Logic

Sistem Poin

  • 1 EcoPoin = Rp 150
  • Jenis Sampah & Harga:
    • Kardus Bekas: Rp 20/kg โ†’ 0.13 poin/kg
    • Botol Plastik: Rp 35/kg โ†’ 0.23 poin/kg
    • Kaleng Aluminium: Rp 50/kg โ†’ 0.33 poin/kg
    • Minyak Jelantah: Rp 40/liter โ†’ 0.27 poin/liter

Transaksi Setoran (Deposit)

// Admin inputs:
- User (warga)
- Waste type (jenis sampah)
- Weight (berat dalam kg)

// System calculates:
points = (waste_price ร— weight) / 150

// System updates:
1. Create transaction (type: 'deposit')
2. Add points to user's wallet
3. Update user's eco_points

Transaksi Pembelian (Purchase)

// User selects:
- Products โ†’ Add to cart
- Checkout

// System validates:
if (user_points >= total_cart_price) {
  // Process purchase
  1. Deduct points from wallet
  2. Decrease product stock
  3. Create transaction (type: 'purchase')
  4. Clear cart
} else {
  // Show error: insufficient balance
}

๐Ÿงช Testing

Manual Testing Checklist

Authentication

  • Login as admin
  • Login as warga
  • Register new warga account
  • Logout

Admin Features

  • Input setoran sampah
  • Add new product
  • Edit product
  • Delete product
  • Add new user (warga)
  • Add new admin
  • Edit user
  • Delete user
  • View statistics

Warga Features

  • View wallet balance
  • View QR code
  • Browse products in Mart
  • Add product to cart
  • Remove from cart
  • Checkout with sufficient balance
  • Checkout with insufficient balance (should fail)
  • View transaction history
  • View profile

๐Ÿ›ก๏ธ Security Considerations

Implemented

  • Username uniqueness validation
  • Password storage (currently plain text - see below)
  • Role-based access control
  • Account status checking (active/inactive)
  • Balance validation before purchase
  • Stock validation before adding to cart
  • Protection against deleting last admin

Recommendations for Production

// TODO: Implement password hashing
import 'package:crypto/crypto.dart';
import 'dart:convert';

String hashPassword(String password) {
  var bytes = utf8.encode(password);
  var digest = sha256.convert(bytes);
  return digest.toString();
}

// In user_repository.dart:
// Replace plain password storage with:
'password': hashPassword(password)

// Replace login query with:
'password': hashPassword(password)

๐Ÿ› Known Issues & Limitations

  1. Password Security: Passwords stored in plain text (implement hashing before production)
  2. No Image Upload: Product images use icon categories only
  3. No Network: Fully offline SQLite-based
  4. No Sync: No cloud backup or multi-device sync
  5. QR Scanner: QR code dialog shows code but no scanner implementation
  6. No Email Verification: Email field exists but not validated
  7. No Forgot Password: Must reset through admin

๐Ÿ”ฎ Future Enhancements

High Priority

  • Password hashing (bcrypt/SHA256)
  • Email validation & verification
  • Forgot password functionality
  • Image picker for product photos
  • QR code scanner implementation
  • Push notifications for successful deposits

Medium Priority

  • Export transaction history to PDF/CSV
  • Data analytics dashboard for admin
  • Monthly reports
  • Leaderboard (top contributors)
  • Reward system/badges
  • Product categories & filters
  • Search functionality in Mart

Low Priority

  • Dark mode
  • Multi-language support (Bahasa & English)
  • Cloud sync (Firebase)
  • Social sharing features
  • Tutorial/onboarding flow

๐Ÿ“„ License

Project ini dibuat untuk keperluan pembelajaran Pemrograman Android - Semester 5.


๐Ÿ‘ฅ Credits

Developer: Basith Project: EcoLoop Mart - Sustainable Shopping App Institution: Semester 5 - Pemrograman Android

Technologies Used

  • Flutter - UI Framework
  • Provider - State Management
  • SQLite - Local Database
  • QR Flutter - QR Code Generation
  • Intl - Date Formatting

๐Ÿ“ž Support & Contact

Jika ada pertanyaan atau issues:

  1. Check dokumentasi ini terlebih dahulu
  2. Review kode di folder yang relevan
  3. Test di emulator atau device
  4. Check database dengan SQLite viewer

๐ŸŽฏ Quick Start Guide

Untuk Dosen/Reviewer

  1. Install & Run

    flutter pub get
    flutter run
  2. Login as Admin

    • Tab: ADMIN
    • Username: admin
    • Password: admin123
  3. Setup Initial Data

    • Go to Gudang โ†’ Add products
    • Go to Akun โ†’ Add warga users
  4. Test User Flow

    • Logout
    • Login as warga OR register new account
    • View wallet (should be 0 poin)
  5. Test Deposit Flow

    • Login as admin
    • Go to Dashboard
    • Select warga from dropdown
    • Select waste type (e.g., Kardus Bekas)
    • Input weight (e.g., 10 kg)
    • Click Proses Setoran
    • Check warga's wallet (should increase)
  6. Test Purchase Flow

    • Login as warga
    • Go to Mart
    • Add products to cart
    • Click Checkout
    • Confirm purchase
    • Check wallet (should decrease)
    • Check Riwayat (should show transaction)

Happy Coding & Green Living! โ™ป๏ธ๐ŸŒฑ

About

Aplikasi Flutter dengan arsitektur MVVM untuk sistem tukar sampah menjadi poin yang dapat ditukar dengan sembako. Mendukung dua role: Admin dan Warga.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages