Skip to content

About

Flutter e-commerce app for Android and iOS on a Django REST API: OTP sign-up, JWT auth, Paystack, Flutterwave and Stripe checkout, order tracking and push notifications.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

141 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Flutter E-Commerce App

A full-featured Flutter e-commerce mobile application with Django REST API backend integration. This app provides a complete shopping experience with multiple payment gateways, real-time notifications, and comprehensive order management.

πŸ“± Features

Authentication & Authorization

  • User Registration with email verification (OTP)
  • Login/Logout with JWT authentication
  • Remember Me functionality
  • Password Reset via email
  • Forgot Password flow
  • Token Auto-Refresh mechanism
  • Account activation via OTP

Product Management

  • Product Listing with pagination
  • Category-based Filtering
  • Brand Filtering
  • Advanced Search functionality
  • Multi-criteria Filters (price, rating, gender, newest, popular)
  • Product Details with image gallery
  • Product Reviews & Ratings (add, edit, view)
  • Related Products suggestions

Shopping Experience

  • Shopping Cart with real-time updates
  • Optimistic UI Updates for cart operations
  • Wishlist Management
  • Multiple Address Management
  • Set Default Address
  • Location Selection

Orders & Payments

  • Order Creation with address validation
  • Order History (Pending, Shipped, Delivered, Cancelled)
  • Order Details with product breakdown
  • Order Tracking
  • Multiple Payment Gateways:
    • PayStack
    • Flutterwave
    • Stripe
  • WebView Payment Integration
  • Payment Verification
  • Payment Success/Failure Handling

User Interface

  • Onboarding Screens
  • Splash Screen
  • Bottom Navigation Bar with badges
  • Pull-to-Refresh functionality
  • Shimmer Loading Effects
  • Image Sliders for promotions
  • Category Scroller
  • Product Grid/List Views
  • Filter Chips
  • Responsive Design

Notifications

  • Push Notifications integration
  • In-App Notifications
  • Notification Badge Counter
  • Mark as Read functionality

Profile Management

  • User Profile view and edit
  • Address Management (add, edit, delete, set default)
  • Order History
  • Wishlist Access
  • Logout

πŸ—οΈ Architecture

State Management

  • GetX for state management and dependency injection
  • Reactive programming with observables
  • Controllers for business logic separation

Network Layer

  • Custom MyRequest class for API calls
  • Automatic token refresh on 401 errors
  • Error handling with user-friendly messages
  • Request timeout management (60 seconds)
  • Support for GET, POST, PUT, PATCH, DELETE
  • Multipart file upload support

Authentication Flow

  • JWT-based authentication
  • Access & Refresh token management
  • Token expiry tracking
  • Automatic token refresh timer (55 minutes)
  • Remember Me with SharedPreferences
  • Secure token storage

πŸ”§ Project Structure

lib/
β”œβ”€β”€ auth/
β”‚   β”œβ”€β”€ controllers/
β”‚   β”‚   β”œβ”€β”€ login_controller.dart
β”‚   β”‚   β”œβ”€β”€ register_controller.dart
β”‚   β”‚   β”œβ”€β”€ otp_controller.dart
β”‚   β”‚   └── password_controller.dart
β”‚   β”œβ”€β”€ service/
β”‚   β”‚   └── auth_service.dart
β”‚   └── views/
β”‚       β”œβ”€β”€ sign_in.dart
β”‚       β”œβ”€β”€ sign_up.dart
β”‚       β”œβ”€β”€ sign_up_otp_code.dart
β”‚       β”œβ”€β”€ forgot_password.dart
β”‚       └── reset_password.dart
β”‚
β”œβ”€β”€ products/
β”‚   β”œβ”€β”€ controllers/
β”‚   β”‚   β”œβ”€β”€ product_controller.dart
β”‚   β”‚   β”œβ”€β”€ category_controller.dart
β”‚   β”‚   └── review_controller.dart
β”‚   β”œβ”€β”€ models/
β”‚   β”‚   β”œβ”€β”€ product_model.dart
β”‚   β”‚   β”œβ”€β”€ category_model.dart
β”‚   β”‚   └── review_model.dart
β”‚   β”œβ”€β”€ service/
β”‚   β”‚   β”œβ”€β”€ product_service.dart
β”‚   β”‚   └── review_service.dart
β”‚   └── views/
β”‚       β”œβ”€β”€ product_detail.dart
β”‚       β”œβ”€β”€ product_list_by_category.dart
β”‚       β”œβ”€β”€ product_search_screen.dart
β”‚       β”œβ”€β”€ product_filter.dart
β”‚       └── category_list.dart
β”‚
β”œβ”€β”€ cart/
β”‚   β”œβ”€β”€ controllers/
β”‚   β”‚   β”œβ”€β”€ cart_controller.dart
β”‚   β”‚   └── address_controller.dart
β”‚   β”œβ”€β”€ models/
β”‚   β”‚   β”œβ”€β”€ cart_model.dart
β”‚   β”‚   β”œβ”€β”€ create_cart_model.dart
β”‚   β”‚   └── address_model.dart
β”‚   └── views/
β”‚       β”œβ”€β”€ cart_screen.dart
β”‚       └── checkout_screen.dart
β”‚
β”œβ”€β”€ wishlist/
β”‚   β”œβ”€β”€ controllers/
β”‚   β”‚   └── wishlist_controller.dart
β”‚   β”œβ”€β”€ models/
β”‚   β”‚   └── wishlist_model.dart
β”‚   └── views/
β”‚       └── wishlist.dart
β”‚
β”œβ”€β”€ orders/
β”‚   β”œβ”€β”€ controllers/
β”‚   β”‚   └── order_controller.dart
β”‚   β”œβ”€β”€ models/
β”‚   β”‚   └── order_model.dart
β”‚   β”œβ”€β”€ service/
β”‚   β”‚   └── order_service.dart
β”‚   └── views/
β”‚       β”œβ”€β”€ order_screen.dart
β”‚       └── order_detail.dart
β”‚
β”œβ”€β”€ payment/
β”‚   β”œβ”€β”€ controllers/
β”‚   β”‚   └── payment_controller.dart
β”‚   β”œβ”€β”€ models/
β”‚   β”‚   └── payment_request_model.dart
β”‚   └── views/
β”‚       β”œβ”€β”€ payment_method_screen.dart
β”‚       β”œβ”€β”€ payment_webview.dart
β”‚       └── payment_success_screen.dart
β”‚
β”œβ”€β”€ notification/
β”‚   β”œβ”€β”€ controllers/
β”‚   β”‚   └── notification_controller.dart
β”‚   └── views/
β”‚       └── notification_screen.dart
β”‚
β”œβ”€β”€ profile/
β”‚   └── views/
β”‚       └── profile_screen.dart
β”‚
β”œβ”€β”€ home/
β”‚   └── views/
β”‚       β”œβ”€β”€ home_screen.dart
β”‚       └── location_screen.dart
β”‚
β”œβ”€β”€ onboarding/
β”‚   └── views/
β”‚       β”œβ”€β”€ splash_screen.dart
β”‚       └── welcome_screen.dart
β”‚
β”œβ”€β”€ base/
β”‚   β”œβ”€β”€ res/
β”‚   β”‚   β”œβ”€β”€ base_url.dart
β”‚   β”‚   β”œβ”€β”€ media.dart
β”‚   β”‚   └── styles/
β”‚   β”‚       └── app_styles.dart
β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   β”œβ”€β”€ my_request.dart
β”‚   β”‚   β”œβ”€β”€ snackbar.dart
β”‚   β”‚   └── token.dart
β”‚   └── widgets/
β”‚       β”œβ”€β”€ app_double_text.dart
β”‚       β”œβ”€β”€ category_scroller.dart
β”‚       β”œβ”€β”€ category_shimmer.dart
β”‚       β”œβ”€β”€ filter_card.dart
β”‚       β”œβ”€β”€ image_sliders.dart
β”‚       β”œβ”€β”€ product_card.dart
β”‚       └── product_shimmer.dart
β”‚
└── bottom_nav_bar.dart

πŸš€ Getting Started

Prerequisites

  • Flutter SDK (latest stable version)
  • Dart SDK
  • Android Studio / VS Code
  • Django backend API running

Backend Requirements

The app requires a Django REST API with the following endpoints:

Authentication

  • POST /auth/users/ - User registration
  • POST /auth/login/ - User login
  • POST /auth/activate-otp/ - OTP verification
  • POST /auth/resend-otp/ - Resend OTP
  • POST /auth/jwt/refresh/ - Token refresh
  • POST /auth/jwt/verify/ - Token verification
  • POST /auth/password/reset/ - Password reset request
  • POST /auth/password/reset/confirm/ - Password reset confirmation

Products

  • GET /products/ - Get all products
  • GET /products/{id}/ - Get product details
  • GET /products/category/{id}/ - Get products by category
  • GET /products/search/ - Search products

Cart

  • GET /cart/me/ - Get user cart
  • POST /cart/add/ - Add to cart
  • PATCH /cart/update/{id}/ - Update cart item
  • DELETE /cart/delete/{id}/ - Remove from cart
  • DELETE /cart/clear/ - Clear cart

Wishlist

  • GET /wishlist/me/ - Get user wishlist
  • POST /wishlist/add/ - Add to wishlist
  • DELETE /wishlist/remove/{id}/ - Remove from wishlist

Orders

  • POST /orders/add/ - Create order
  • GET /orders/status/{status}/ - Get orders by status
  • GET /orders/{id}/ - Get order details

Payments

  • POST /payments/initiate-paystack-payment/ - Initiate PayStack payment
  • GET /payments/verify-paystack-payment/{reference}/ - Verify PayStack payment
  • POST /payments/initiate-flutterwave-payment/ - Initiate Flutterwave payment
  • GET /payments/verify-flutterwave-payment/{reference}/ - Verify Flutterwave payment
  • POST /payments/initiate-stripe-payment/ - Initiate Stripe payment
  • GET /payments/verify-stripe-payment/{session_id}/ - Verify Stripe payment

Address

  • GET /address/addresslist/ - Get user addresses
  • POST /address/add/ - Add address
  • PATCH /address/set-default/?id={id} - Set default address
  • DELETE /address/delete/?id={id} - Delete address

Notifications

  • GET /notifications/ - Get user notifications
  • PATCH /notifications/mark-read/{id}/ - Mark notification as read

Installation

  1. Clone the repository:
git clone <repository-url>
cd ecom_app
  1. Install dependencies:
flutter pub get
  1. Configure base URL:

    • Navigate to lib/base/res/base_url.dart
    • Update the baseUrl constant with your Django API URL:
    const String baseUrl = 'https://your-api-url.com';
  2. Run the app:

flutter run

πŸ”‘ Key Features Implementation

Token Refresh Mechanism

The app implements automatic token refresh:

  • Tokens are checked every 55 minutes
  • On 401 errors, tokens are automatically refreshed
  • If refresh fails, user is logged out
  • Remember Me option stores refresh token persistently

Optimistic UI Updates

Cart and wishlist operations use optimistic updates:

  • UI updates immediately on user action
  • Changes are rolled back if API call fails
  • Provides smooth user experience

Payment Flow

  1. User selects payment method (PayStack/Flutterwave/Stripe)
  2. Order is created on backend
  3. Payment gateway session is initiated
  4. User is redirected to WebView for payment
  5. Payment is verified on callback
  6. Order status is updated
  7. User sees success screen with order details

Error Handling

  • Network errors show "Check your internet" message
  • Timeout errors (60s) show appropriate message
  • API errors display server-provided error messages
  • Validation errors are shown inline

πŸ“± Screens

Public Screens

  • Splash Screen
  • Onboarding/Welcome Screen
  • Sign In
  • Sign Up
  • OTP Verification
  • Forgot Password
  • Reset Password

Protected Screens

  • Home (with categories, products, search)
  • Product Details
  • Product List (by category/filter)
  • Search Results
  • Cart
  • Checkout
  • Wishlist
  • Orders (Pending/Delivered/Cancelled)
  • Order Details
  • Payment Selection
  • Payment WebView
  • Payment Success
  • Notifications
  • Profile
  • Address Management
  • Location Selection

🎨 UI Components

Reusable Widgets

  • ProductCard - Product display card
  • CategoryScroller - Horizontal category list
  • FilterCard - Filter chips
  • AppDoubleText - Section header with "View All"
  • ImageSliders - Banner carousel
  • Shimmer loading placeholders

Bottom Navigation

  • Home
  • Wishlist (with badge)
  • Cart (with badge)
  • Profile

πŸ”’ Security Features

  • JWT token authentication
  • Secure token storage using SharedPreferences
  • Automatic token refresh
  • Session expiry handling
  • Form validation
  • OTP verification for account activation
  • Password reset via email

πŸ“Š State Management

Controllers manage:

  • Loading states (isLoading, isLoad)
  • Error messages (errorMessage)
  • Data lists (products, cart items, orders, etc.)
  • Selected items (address, filters)
  • Form state (rating, review text)

πŸ§ͺ Testing Considerations

To test the app:

  1. Ensure Django backend is running
  2. Configure correct baseUrl
  3. Test authentication flow (register β†’ OTP β†’ login)
  4. Test cart operations with optimistic updates
  5. Test payment gateways (use test credentials)
  6. Test token refresh by waiting 55+ minutes
  7. Test offline behavior

πŸ› Known Issues & Limitations

  • Payment gateway test credentials required
  • Push notifications require Firebase setup
  • Image uploads limited to specific formats
  • No offline data caching (requires internet)

πŸ“„ License

This project is part of a commercial application. All rights reserved.

πŸ‘₯ Contributors

Developed by Arinze Timothy

About

Flutter e-commerce app for Android and iOS on a Django REST API: OTP sign-up, JWT auth, Paystack, Flutterwave and Stripe checkout, order tracking and push notifications.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages