Sprint 4 - Moviles-G45/FlutterApp GitHub Wiki

๐Ÿ“Œ Value Proposition of the Personal Finance App

Our personal finance application offers a comprehensive and intelligent financial management solution tailored for everyday users who seek to gain control over their income, spending, and savings behavior. Designed with offline-first capabilities, smart notifications, and visual clarity, the app transforms complex financial tracking into a simple, engaging, and impactful experience.


โœ… Core Value Drivers

1. Feature-Rich Financial Control

The app empowers users through:

  • ๐Ÿ“Š Expense Grouping and Visualization: Users can easily track and understand their spending through category-based grouping and graphical representations, helping them identify habits and improve budgeting strategies.
  • ๐Ÿ“‚ Detailed Category Views: Each category displays a clear breakdown of individual transactions, even offline, supporting everyday financial decisions.
  • ๐ŸŽฏ Smart Budget Notifications: Custom alerts at 25%, 50%, 75%, and 100% progress encourage saving discipline and goal-oriented budgeting.

2. Offline-First Performance and Resilience

Thanks to SharedPreferences caching, the app maintains full usability even when offline. Budget data, expense logs, and transaction history remain accessible, ensuring continuity in financial monitoring regardless of internet availability.

3. Micro-Optimized Experience

Backend and frontend are optimized through:

  • Reduced object creation and memory usage.
  • Efficient API calls handled in isolates.
  • Lifecycle-aware coroutine scopes that eliminate memory leaks and support longer app uptime.

These improvements not only enhance responsiveness and speed but also ensure the app runs smoothly on a wide range of devices.


๐Ÿ” Implemented Business Questions

  • How are users spending across categories each month?
  • Which categories experience the highest variability in spending?
  • What percentage of income is allocated to savings, needs, and wants?
  • How frequently do users reach their budget goals?

The app collects and analyzes this data to generate actionable insights for both users and business development (e.g., targeted financial tips, budget coaching).


๐Ÿ’ธ Proposed Revenue Model

  • Freemium Access: Core functionalities remain free, with advanced analytics and automated suggestions behind a premium subscription tier.
  • Affiliate Partnerships: Integrations with savings tools, budgeting books, or financial services (like credit score tracking or investment platforms) offer referral commissions.
  • In-App Personal Finance Courses: Micro-learning modules and budget challenges monetized via in-app purchases.

๐Ÿ“ˆ Value for Stakeholders

  • For Users: Clarity, control, and motivation in their financial journeyโ€”backed by personalized data and offline access.
  • For the Business: Scalable data-driven monetization through subscriptions and partnerships.
  • For Partners: A highly engaged, financially-conscious user base with insights on spending behavior and budgeting trends.

2. ๐Ÿš€ New Functionalities

1.1 ๐Ÿ“Š Group Expenses by Category

This functionality allows users to group their expenses according to predefined categories such as food, transportation, entertainment, utilities, and more. It implements caching strategies to ensure that grouped data is retrieved efficiently, even when offline. Users can easily view a breakdown of their spending habits within each category, providing insights into where their money goes. This is particularly useful for identifying patterns and making more informed budgeting decisions.

1.2 ๐Ÿ“‚ View Expenses by Category

Users can view a detailed breakdown of expenses sorted by category. This view not only presents a clear visualization of spending patterns but also leverages local storage strategies to maintain data availability without relying on a constant internet connection. The data is automatically updated with each new entry, ensuring accuracy in financial tracking. The use of local storage optimizes app performance and provides a seamless user experience.

1.3 ๐Ÿ“ Modify Monthly Budget

This feature allows users to set or update their monthly budget allocation across the three main spending categories: Needs, Wants, and Savings.

๐Ÿ”ง Functional Workflow: Input Sliders: Users interact with three sliders to define the percentage allocation for each category. The system ensures the total always equals 100%.

Validation:

Real-time validation checks that the sum of Needs + Wants + Savings = 100%.

If the sum is incorrect, a warning message is displayed and the "Save" button is disabled.

image


๐Ÿงฉ Sprint 2 โ€“ Delivered Functionalities

๐Ÿšจ ATM Proximity Notification

We implemented a location-based notification system that detects when a user is near an ATM or a shopping mall. This feature leverages GPS and geofencing capabilities to trigger real-time alerts, prompting users to withdraw or manage money conveniently when they're in proximity to relevant financial services. This functionality helps support better decision-making in physical financial planning moments. image

โฐ Weekend Spending Reminder Notification

A contextual notification is sent on weekends to remind users to review their spending. The reminder is triggered every Saturday morning and encourages users to check if their expenses are within budget before weekend leisure spending begins. This promotes better financial awareness and reinforces budgeting habits during typically high-spending periods.

image

๐Ÿ  Home Screen and Core Features

The HomeScreen aggregates key financial insights and tools:

  • BalanceCard: Displays the current available balance.
  • ExpensesCard: Shows total expenses and breakdown by date or category.
  • TransactionFilterBar: Allows users to filter transactions by:
    • Date (Today, Week, Month)
  • TransactionList: Dynamically updates to reflect filter selections, showing detailed transactions.
  • Offline banner: Displays an offline message without disrupting the layout if there's no internet.

These components are modular and interact seamlessly through the MVVM architecture, enabling responsive and scalable UI updates. image


๐Ÿงฉ Sprint 3 โ€“ Delivered Functionalities

๐Ÿ’พ Home Screen Caching

To ensure functionality when offline, we implemented a caching strategy for the HomeScreen. All key financial dataโ€”such as balance, recent transactions, and expense summariesโ€”is stored locally using SharedPreferences. This means users can:

  • View data even without an internet connection
  • Avoid redundant API calls and reduce backend load
  • Experience faster app launch and smoother interaction

๐Ÿงต Isolate-Based Budget Processing

To improve performance, especially on low-end devices, we offloaded intensive budget validation and API communication to isolates. This keeps the UI thread responsive while:

  • Checking that budget allocations (Needs/Wants/Savings) sum to 100%
  • Sending/receiving budget data to/from the backend

This micro-optimization helps avoid frame drops and ANR (App Not Responding) issues by parallelizing heavy operations outside the main thread.


Let me know if you'd like this content exported as a Markdown file or added to your GitHub Wiki directly.

2. ๐Ÿ–ฅ๏ธ Views

2.1 ๐Ÿ—‚๏ธ Category Classification

This view provides a clean and organized interface to categorize expenses. Users can manually classify their expenses into categories or let the app suggest categorizations based on the expense type. The classification interface is intuitive, making it easy for users to add or edit categories as needed. This flexibility ensures that users can customize the app to their personal spending habits.

2.2 ๐Ÿ“ˆ Viewing Expenses by Category

This view provides a graphical representation of expenses by category, allowing users to quickly assess their spending habits. Users can select a specific category to see all related transactions, providing a detailed view of how their money was spent. This feature is especially useful for monitoring recurring expenses and adjusting the budget as needed.

2.3 ๐Ÿ’ฐ Monthly Budget Creation

The budget creation view allows users to set a personalized budget for each category, as well as an overall monthly budget. The user can input their desired savings goal and allocate amounts to each category.

๐Ÿ’ก Budget View Features:

  • ๐Ÿ“… Displays Current Month's Budget:
    • If a budget exists for the current month, it shows a message:

      "Your actual budget for this month is: [amount]"

    • If no budget exists, it displays:

      "No budget for this month."

  • ๐ŸŒ Offline Support:
    • If the user is offline, a banner appears to notify them.
    • When attempting to update or save the budget while offline, an alert will indicate the lack of connectivity.
    • Offline data is retrieved from local cache (using SharedPreferences).

๐Ÿ› ๏ธ Budget View Implementation Strategy:

๐ŸŒ 1. Eventual Connectivity:

  • The Budget View implements a strategy to handle network disruptions seamlessly:
    • If the user is online, the budget data is retrieved from the API.
    • If the user is offline, the budget data is loaded from SharedPreferences.
    • A banner will notify the user when the device is offline.
    • Trying to update the budget while offline will trigger an alert message.

๐Ÿงต 2. Multi-Threading/Concurrency:

To enhance responsiveness and performance, the Budget View leverages multithreading using the following techniques:

  • ๐Ÿงฉ Isolate for API Calls:
    • The saving and updating of the budget are handled in an isolate to ensure that the UI remains responsive.
    • This separation prevents the main UI thread from blocking during network communication.
  • โš™๏ธ Future with Handler for Budget Validation:
    • When the user submits a new budget, the app calculates the sum of percentages (needs, wants, savings) to ensure they equal 100%.
    • This calculation uses a Future with a handler to validate the inputs asynchronously.
    • If the sum does not equal 100%, an error message is displayed.

๐Ÿ’พ 3. Local Storage:

The budget data is stored locally using SharedPreferences to provide offline access. This cache is updated every time the budget is successfully retrieved or saved.

  • ๐Ÿš€ Saving the Budget:
    • When the budget is updated or created, it is stored in the local cache.
    • The data is serialized to JSON format for easy retrieval.
  • ๐Ÿ”„ Retrieving the Budget:
    • On startup or when accessing the Budget View, the app checks connectivity.
    • If offline, it loads the last saved budget from SharedPreferences.

๐Ÿ“ˆ Micro-optimizations

Kotlin

1. Avoid Creating Unnecessary Objects Every time a new object is instantiated, it consumes memory and increases pressure on the garbage collector. This can degrade performance, especially in loops or high-frequency operations. Micro-optimization involves avoiding redundant or short-lived object creation.

image

Here, "Bearer $token" creates a new String object on every call.

image

If this value is reused multiple times in the same context, it could be stored in a variable

2. Prefer Primitive Types Over Wrapper Classes Wrapper classes (Integer, Double, etc.) involve additional memory and CPU overhead due to object allocation and boxing/unboxing. Primitive types (int, double) are more efficient and should be used when nullability is not needed.

image

These are nullable Int? types. If categoryId and userId are guaranteed to be non-null in practice, they can be declared as non-nullable Int primitives to avoid unnecessary overhead:

image

3. Use Lifecycle-Aware Scopes to Prevent Memory Leaks Using viewModelScope to launch coroutines in the ViewModel ensures that any ongoing tasks are automatically canceled when the ViewModel is cleared. This prevents potential memory leaks and wasted CPU cycles from background operations continuing after the screen is destroyed. It also promotes better app stability and battery efficiency by respecting the component lifecycle.

image

Results Before: image

After: image

1. Memory Allocations

  • Before: The malloc method accounted for 29,509 allocations with a total memory footprint of approximately 169 MB.
  • After: The malloc allocations dropped drastically to 344, and the total memory footprint reduced significantly to approximately 2.14 MB.

Despite the substantial drop in allocations, the remaining memory (i.e., memory still retained post-GC) also dropped from ~9.2 MB to just ~123 KB, indicating more efficient memory management and object lifecycle handling.

2. Deallocations and Memory Retention

  • Before: 2,488 active allocations remained in memory after GC, with about 9.2 MB still retained.
  • After: Only 10 active allocations remained in memory, with ~123 KB retained.

This shows a vast improvement in memory release patterns. Objects are now deallocated more quickly, reducing memory leaks and improving app stability.

3. Allocation Size

  • Before: Total allocation size through malloc was approximately 169 MB.
  • After: Allocation size dropped to just ~2.14 MB, reflecting a 98.7% reduction.

This increase could reflect better or more complete test coverage during the session or higher UI interaction. Importantly, the system successfully released most of the allocated memory.

4. CPU Time (Total Cost)

  • Before: malloc operations consumed about 10 ms of CPU time.
  • After: This rose to approximately 2.4 seconds, due to increased coverage or user interaction during testing.

While CPU usage increased, the memory remained well-managed. This implies the app scaled effectively under heavier load and handled tasks without memory regression.

5. Heap Usage Breakdown The breakdown of allocation methods (malloc, calloc, realloc) showed:

  • A sharp drop in realloc usage, which typically indicates fewer unnecessary memory resizing operations.
  • calloc and posix_memalign usage remained minimal and stable.

Flutter:

Micro-Optimization -- Flutter

๐Ÿ“ˆ Business Questions (BQs)

# Business Question Persona Sprint
1 How many consecutive months has the user successfully stayed within their monthly spending limit in the current year? Gabriela Sprint 2
2 Which expense categories has the user exceeded their allocated budget for this month, and by what percentage? Juanda Obando Sprint 2
3 Which are the categories of type โ€˜needsโ€™ in which the users spend the most? Juanda Castillo Sprint 2
4 What are the months in which the users spend the most? Santiago Sprint 2
5 How many consecutive months has the user successfully stayed within a fixed monthly spending limit? Miguel Sprint 2
6 How many days have passed since the last record of expenses of a user? Julian Sprint 2
7 How much has the user contributed to a saving goal this month? Gabriela Sprint 3
8 Which are the categories of type needs in which the users spend the most? Juanda Obando Sprint 3
9 How many users have an average daily expenditure between <50, 50 - 150, >150? Juanda Castillo Sprint 3
10 Which are the categories of type โ€˜savingsโ€™ in which the users spend the most? Santiago Sprint 3
11 Which are the categories of type โ€˜wantsโ€™ in which the users spend the most? Miguel Sprint 3
12 What is the age distribution of our app users? Julian Sprint 3
13 What percentage of monthly income is being allocated to each spending category (WANTS, NEEDS, SAVINGS) for each user in the current year? Gabriela Sprint 4
14 Which are the most prevalent budget percentage combination of Wants, Needs, and Savings utilized by users in the current month? Juanda Obando Sprint 4
15 What is the average percentage that users adjust for the "needs" budget in the last month? Juan Castillo Sprint 4
16 What is the average spending distribution across category types (e.g., Needs, Wants, Savings) for users with an active budget compared to users without one, during a specific period? Julian Escobar Sprint 4
17 What is the trend in average monthly net balance (income - expenses) for users, segmented by their tenure in the application (e.g., 0-3 months, 4-6 months, 7-12 months, +12 months) and observed over different months? Santiago Paez Sprint 4
18 What is the correlation between usersโ€™ expense transaction frequency and their monthly budget adherence rate over the last quarter? Miguel Ariza Sprint 4

๐ŸŽฅ Ethics Reflection Video

  • Youtube video: link