Finding furry friends their forever homes.
Pawsy is a Flutter application that connects pets with loving homes. The app allows users to browse adoptable pets, shop for pet supplies, and manage their pet-related activities all in one place.
- Pet Browsing: Browse adoptable dogs and cats with detailed information
- Pet Registration: Register new pets for adoption, lost pets, found pets, and volunteer opportunities
- Donations: Support pet shelters and organizations through donation screen
- E-commerce Store: Browse and purchase pet supplies and accessories
- Product Search: Search for products by name or category
- Shopping Cart: Add products to cart with quantity management
- Checkout: Complete purchases with address and payment information
- Promo Codes: Apply discount codes at checkout (TEST10 for 10% off, SAVE5 for $5 off, BIG20 for 20% off)
- Order Management: Create orders, view order history, and see order details
- User Authentication: Secure login, registration, and password recovery
- User Profile: Manage profile, view favorites, track orders, and change language preferences
- Favorites: Save favorite pets and products for quick access
- Multi-language Support: Switch between English and Icelandic
- Bottom Navigation: Easy navigation between Home, Pets, Store, and Profile
- Responsive Design: Beautiful UI with smooth animations
- Authentication Flow: Seamless login/logout with protected routes
- Real-time Updates: Live authentication state management
The app follows a feature-based architecture where each feature is self-contained with its own:
- Screens
- Widgets
- Providers (state management)
- Services (data layer)
- Models
lib/
βββ common/ # Shared utilities, widgets, and configurations
β βββ routes.dart # Navigation configuration
β βββ theme/ # App theming
β βββ widgets/ # Reusable widgets
β βββ validators/ # Form validation
βββ features/ # Feature modules
β βββ auth/ # Authentication
β βββ home/ # Home screen
β βββ pets/ # Pet browsing and management
β βββ store/ # E-commerce functionality
β βββ profile/ # User profile and settings
βββ main.dart # App entry point
-
Separation of Concerns
- Screens: UI layer
- Widgets: Reusable UI components
- Providers: State management
- Services: Business logic and API calls
- Models: Data structures
-
Dependency Injection
- Services are provided via Riverpod providers
- Easy to mock for testing
- Loose coupling between layers
-
Navigation
- Declarative routing with GoRouter
- StatefulShellRoute for bottom navigation persistence
- Route guards based on authentication state
The app uses Flutter Riverpod 3.0.3 for state management, providing:
- Type-safe dependency injection
- Automatic dependency tracking
- Easy testing and mocking
- Performance optimizations
- Reactive Updates: UI automatically updates when state changes
- Computed Values: Derived state (e.g., cart totals)
- Error Handling: AsyncValue for loading, data, and error states
- Optimistic Updates: Local state updates before server confirmation
- Flutter:
^3.9.2- Cross-platform UI framework - Dart: Modern language with strong typing
- flutter_riverpod:
^3.0.3- State management - go_router:
^16.3.0- Declarative routing - riverpod_lint:
^3.0.3- Linting rules for Riverpod
- supabase_flutter:
^2.12.0- Backend-as-a-Service- Authentication
- Database (PostgreSQL)
- Real-time subscriptions
- Row Level Security (RLS) policies
- Edge Functions (for secure payment processing)
- flutter_stripe:
^12.1.1- Stripe payment integration- Secure payment processing via Stripe Payment Sheet
- Server-side payment intent creation using Supabase Edge Functions
- Test mode support for development
The app uses Supabase PostgreSQL with the following key tables:
- users: User authentication (managed by Supabase Auth)
- profiles: User profile information and delivery addresses
- pets: Adoptable pets information
- products: Store products catalog
- cart_items: Shopping cart items
- orders: Order history with products, addresses, and payment methods
- promocodes: Promo code definitions with discount rules
- promo_code_usage: Tracks promo code usage per user and order
- favorites: User favorites for pets and products
- lost_pets: Lost pet registrations
- found_pets: Found pet registrations
- volunteers: Volunteer registrations
The app uses Supabase Storage for file uploads:
- lost-pets: Storage bucket for lost pet images
- google_fonts:
^6.3.2- Typography - flutter_animate:
^4.5.2- Animations - cached_network_image:
^3.4.1- Image caching - flutter_svg:
^2.2.3- SVG support - shimmer:
^3.0.0- Loading placeholders - smooth_page_indicator:
^2.0.1- Page indicators - wolt_modal_sheet:
^0.11.0- Modal sheets - flutter_spinkit:
^5.2.2- Loading spinners - dropdown_button2:
^2.3.9- Enhanced dropdown buttons - device_preview:
^1.3.1- Device preview for development
- intl:
^0.20.2- Internationalization - easy_localization:
^3.0.8- Translations - flutter_dotenv:
^5.2.1- Environment variable management - shared_preferences:
^2.5.4- Local storage - image_picker:
^1.2.1- Image selection for pet registration - url_launcher:
^6.3.2- URL handling - phone_form_field:
^10.0.16- Phone number input with validation - collection:
^1.19.1- Collection utilities
- build_runner:
^2.10.4- Code generation - json_serializable:
^6.11.2- JSON serialization - json_annotation:
^4.9.0- JSON annotations - flutter_lints:
^6.0.0- Linting rules - flutter_launcher_icons:
^0.14.4- App icon generation
lib/
βββ common/
β βββ api_key.dart # API configuration
β βββ app_config.dart # App configuration
β βββ spacing_constants.dart # Spacing constants
β βββ text_constants.dart # Text constants
β βββ extensions.dart # Dart extensions
β βββ root.dart # Root navigation shell
β βββ routes.dart # Route definitions
β βββ data/ # Shared data models
β βββ theme/ # Theme configuration
β βββ validators/ # Form validators
β βββ widgets/ # Reusable widgets
β
βββ features/
β βββ auth/ # Authentication feature
β β βββ auth_screen.dart # Auth screen
β β βββ login/ # Login screen & logic
β β βββ register/ # Registration
β β βββ forgot_password/ # Password recovery
β β βββ provider/ # Auth state providers
β β βββ shared/ # Shared auth widgets
β β
β βββ home/ # Home screen feature
β β βββ home_screen.dart
β β βββ donation_screen.dart # Donation screen
β β βββ models/ # Home-specific models (pet registration, volunteer, etc.)
β β βββ service/ # Home services (registration, donation)
β β βββ provider/ # Home state providers
β β βββ local_data/ # Local data and extensions
β β βββ widgets/ # Home widgets (forms, lists, banners)
β β
β βββ pets/ # Pet browsing feature
β β βββ pet_screen.dart
β β βββ pet_description_screen.dart
β β βββ models/ # Pet models
β β βββ provider/ # Pet state providers
β β βββ service/ # Pet services
β β βββ local_data/ # Pet local data
β β βββ widgets/ # Pet widgets
β β
β βββ store/ # E-commerce feature
β β βββ store_screen.dart
β β βββ search_screen.dart # Product search screen
β β βββ model/ # Product models
β β βββ provider/ # Store providers (products, search)
β β βββ service/ # Store services
β β βββ widgets/ # Store widgets
β β βββ cart/ # Shopping cart
β β β βββ cart_screen.dart
β β β βββ model/ # Cart models
β β β βββ provider/ # Cart state management
β β β βββ service/ # Cart services
β β β βββ widgets/ # Cart widgets
β β βββ checkout/ # Checkout flow
β β β βββ checkout_screen.dart
β β β βββ model/ # Checkout/Order models
β β β βββ provider/ # Checkout state management
β β β βββ service/ # Order creation service
β β β βββ widgets/ # Checkout widgets
β β β βββ delivery_section.dart
β β β βββ payment_section.dart
β β β βββ payment_confirmation_sheet.dart
β β β βββ summary_section.dart
β β
β βββ profile/ # User profile feature
β βββ profile_screen.dart
β βββ favorite/ # Favorites management
β β βββ favorite_screen.dart
β β βββ favorite_pet_screen.dart
β β βββ favorite_product_screen.dart
β β βββ model/ # Favorite models
β β βββ provider/ # Favorite state management
β β βββ service/ # Favorite services
β β βββ widgets/ # Favorite widgets
β βββ order/ # Order history
β β βββ order_screen.dart # Order list screen
β β βββ widgets/ # Order widgets
β β βββ order_list.dart # Order details modal
β βββ local_data/ # Profile local data
β βββ provider/ # Profile providers
β βββ service/ # Profile services
β βββ widgets/ # Profile widgets (language selector, edit form, etc.)
β
βββ main.dart # App entry point
The app implements a secure authentication flow using Supabase:
- Landing Screen: Initial screen for unauthenticated users
- Login/Register: User authentication
- Password Recovery: Forgot password flow with email reset
- Protected Routes: Profile tab only visible when authenticated
- Auto-redirect: Authenticated users redirected from auth screens
- Uses
StreamProviderto listen to Supabase auth state changes - GoRouter automatically refreshes on auth state changes
- Route guards prevent unauthorized access
- User adds products to cart
- Navigates to checkout screen
- Selects/enters delivery address
- Optionally applies promo code for discount
- Confirms payment via Stripe:
- Payment intent created securely via Supabase Edge Function
- Stripe Payment Sheet presented to user
- User completes payment (or can cancel)
- Order is created (only after successful payment):
- Unique order number (ORD-XXXXX)
- Current timestamp
- All cart products
- Delivery address snapshot
- Payment method (Credit Card via Stripe)
- Applied promo code (if any)
- Discount amount (if promo code applied)
- Total amount (after discount)
- Cart is automatically cleared after successful order creation
- Order confirmation modal displays order details
The app uses Stripe for secure payment processing with a server-side architecture:
- Client-side (Flutter app):
- Presents Stripe Payment Sheet UI
- Stores only publishable key (safe to expose)
- Server-side (Supabase Edge Function):
- Creates payment intents with Stripe secret key
- Secret key stored securely in Supabase secrets
- Never exposed in client code
1. User initiates checkout
2. Flutter app β Supabase Edge Function (create-payment-intent)
3. Edge Function β Stripe API (create payment intent)
4. Stripe β Edge Function (client secret)
5. Edge Function β Flutter app (client secret)
6. Flutter app presents Stripe Payment Sheet
7. User completes payment
8. On success β Order created in database
9. On cancel β User returns to checkout
- Use test card: 4242 4242 4242 4242
- Any future expiry date
- Any CVC
- Order List: View all past orders in profile section
- Order Details: Tap any order to view complete information
- Empty States: Friendly messages when no orders exist
- Error Handling: Graceful error messages for failed operations
Each order contains:
user_id: User who placed the orderorder_number: Unique identifier (e.g., ORD-12345)order_placed_date: Timestamp of order creationtotal: Total order amount (after discount)products: JSON array of product detailsdelivery_address: JSON object with address informationpayment_method: Selected payment methodpromo_code_id: ID of applied promo code (if any)discount_amount: Discount amount applied from promo code
- Browse Products: View available pet supplies by category
- Search Products: Use search functionality to find specific products
- Add to Cart: Select products and quantities
- Cart Management: Update quantities, remove items, view cart total
- Checkout: Enter delivery address and payment method
- Apply Promo Code: Enter promo code at checkout to receive discounts
- Order Creation: Create order with unique order number
- Order Confirmation: View order details and confirmation
- Order History: View all past orders in profile section
- Order Details: Tap any order to view full details in a modal
The app supports promotional discount codes that can be applied during checkout:
- TEST10: 10% discount on your order (no minimum order amount)
- SAVE5: $5 fixed discount on orders over $20 (each user can use up to 3 times)
- BIG20: 20% discount on orders over $30 (limited to 500 total uses)
- Discount Types: Supports both percentage and fixed amount discounts
- Validation: Promo codes are validated for:
- Active status
- Validity dates (valid_from and valid_until)
- Maximum uses (if set)
- Maximum uses per user
- Minimum order amount requirements
- Automatic Calculation: Discounts are automatically calculated and applied to order total
- Usage Tracking: Promo code usage is tracked per user and order
- Real-time Updates: Discount amount updates automatically when cart total changes
- Add items to cart
- Navigate to checkout screen
- Scroll to "Promo Code" section
- Enter promo code (e.g., TEST10, SAVE5, or BIG20)
- Tap "Apply" to validate and apply the discount
- Discount will be reflected in the order summary
- Complete checkout to use the promo code
The app supports multiple types of pet-related registrations:
-
New Pet Registration: Register pets available for adoption
- Pet details (name, category, gender, description)
- Image upload
- Location information
-
Lost Pet Registration: Report lost pets
- Pet information and description
- Image upload to Supabase Storage
- Automatic image URL generation
-
Found Pet Registration: Report found pets
- Similar to lost pet registration
- Helps reunite pets with owners
-
Volunteer Registration: Register as a volunteer
- Personal information (name, email, phone)
- Location selection
- Contact information for organizations
The app supports two languages:
- English (default)
- Icelandic (Γslenska)
Users can switch languages from the profile screen. Language preferences are stored locally using shared_preferences.
The app uses a custom theme defined in lib/common/theme/:
- Light Theme: Primary color scheme
- Custom Colors: Brand-specific color palette
- Typography: Google Fonts integration
- Consistent Styling: Reusable theme components
- Home (
/) - Main dashboard with pet listings, registration options, and donation - Pets (
/pets) - Browse adoptable pets with detailed descriptions - Store (
/store) - E-commerce section with product browsing and search - Profile (
/profile) - User profile, favorites, orders, and settings (authenticated only)
- Landing (
/landing) - Initial screen for unauthenticated users - Login (
/login) - User authentication - Register (
/register) - User registration - Forgot Password (
/login/forgot_password) - Password recovery flow (In progress) - Donation (
/donation) - Donation screen - Search (
/store/search) - Product search screen - Cart (
/store/cart) - Shopping cart - Checkout (
/store/checkout) - Checkout and order creation
The app requires the following Supabase tables to be set up:
-
orders - Stores order information
id(BIGSERIAL PRIMARY KEY)user_id(UUID, references auth.users)order_number(TEXT, UNIQUE)order_placed_date(TIMESTAMPTZ)total(DECIMAL) - Final total after discountproducts(JSONB)delivery_address(JSONB)payment_method(TEXT)promo_code_id(UUID, NULLABLE, references promocodes)discount_amount(DECIMAL, DEFAULT 0) - Discount applied from promo codecreated_at(TIMESTAMPTZ)updated_at(TIMESTAMPTZ)
-
lost_pets - Stores lost pet registrations
id(BIGSERIAL PRIMARY KEY)name(TEXT)category(TEXT) - Pet category (dog/cat)gender(TEXT) - Pet genderdescription(TEXT)img_url(TEXT) - URL to uploaded imagecreated_at(TIMESTAMPTZ)
-
found_pets - Stores found pet registrations
- Similar structure to lost_pets
-
volunteers - Stores volunteer registrations
id(BIGSERIAL PRIMARY KEY)full_name(TEXT)email(TEXT)phone(TEXT)location_code(TEXT)location_name(TEXT)created_at(TIMESTAMPTZ)
The app uses flutter_dotenv for secure credential management. To set up:
-
Copy the example file:
cp .env.example .env
-
Fill in your credentials in
.env:STRIPE_PUBLISHABLE_KEY=pk_test_your_key_here SUPABASE_URL=https://your-project.supabase.co SUPABASE_ANON_KEY=your_anon_key_here
-
Never commit
.envto git (already in.gitignore)
For payment processing to work, you need to deploy the Supabase Edge Function:
-
Install Supabase CLI:
brew install supabase/tap/supabase
-
Login and link your project:
supabase login supabase link --project-ref YOUR_PROJECT_REF
-
Set Stripe secret key:
supabase secrets set STRIPE_SECRET_KEY=sk_test_your_secret_key -
Deploy the Edge Function:
supabase functions deploy create-payment-intent
For detailed setup instructions, see SUPABASE_SETUP.md.
# Install dependencies
flutter pub get
# Run the app
flutter run- SUPABASE_SETUP.md - Supabase Edge Functions deployment guide
- STRIPE_MIGRATION_SUMMARY.md - Payment integration security improvements
pawsy.mov
Made with β€οΈ for pets and their future families πΎ