All work

Dart

ExpenseTrackerMobile

A Flutter app for tracking monthly spending in MMK (Myanmar kyat). You can log expenses, set budgets per category, see a monthly report, and fill in an expense from a photo of a payment slip.

Stars0
LanguageDart
Last push2 Dec 2026

Expense Tracker

A Flutter app for tracking monthly spending in MMK (Myanmar kyat). You can log expenses, set budgets per category, see a monthly report, and fill in an expense from a photo of a payment slip. The app talks to a REST backend at /v1/api/....

Run it

flutter pub get
flutter run                                         # uses the default backend
flutter run --dart-define=API_BASE_URL=https://your-api.example.com
flutter test                                        # unit + widget tests
flutter analyze
  • Requires the Dart SDK ^3.13.5. The code uses the const new(...) constructor syntax.
  • API_BASE_URL defaults to https://messaging-socket-n24e.vercel.app. It's set in lib/main.dart.
  • iOS asks for camera and photo-library access the first time you scan a slip. The permission text is in ios/Runner/Info.plist.

Using the app

  1. Sign in with your email and password. The session stays saved until you log out or the server rejects the token.
  2. Home shows the month's budget card and how much of each category's budget you've used. Tap a category to see its transactions. Use the month pill to change months.
  3. Add an expense with the + button: amount, category, date and payment method. You can also tap Scan slip to take a photo, or From gallery to pick a screenshot. The server reads the slip and fills in the form for you to check before saving. Nothing is saved until you tap Save.
  4. Transactions lists the month's expenses grouped by day, 20 at a time, with a category filter. Tap a row to edit or delete it.
  5. Reports shows the monthly totals, spending by category as a donut chart, and spending by day.
  6. More has screens for managing budgets and categories, and the logout button.

If saving an expense takes a budget near or over its limit, a snackbar warns you. It turns red when the budget is exceeded.

Architecture

lib/
├─ main.dart            creates Api + AuthCubit; shows Login or Shell based on auth state
├─ core/                no app state
│  ├─ api_client.dart   HTTP, bearer token, 60s timeout, errors → ApiException(message)
│  ├─ money.dart        amounts as integer minor units (5000.00 → 500000), MMK formatting
│  ├─ month.dart        month keys and start/end ranges for queries
│  ├─ theme.dart        ThemeData built from Palette (light only)
│  ├─ palette.dart      colour and font tokens
│  └─ month_pill.dart, wallet_card.dart   shared widgets
├─ data/
│  ├─ api.dart          one method per endpoint; returns models or throws ApiException
│  ├─ models.dart       Expense, Category, Budget, BudgetStatus, MonthlyReport, SlipDraft …
│  └─ slip_reader.dart  image_picker → Api.scanSlip → SlipDraft
└─ features/
   ├─ fetch_cubit.dart  generic FetchCubit<T>: load one month's data, with loading and error state
   ├─ shell.dart        the four tabs; owns the shared cubits and _refreshAll()
   ├─ auth/             AuthCubit, LoginPage, SessionStore (flutter_secure_storage)
   ├─ home/             budget status for the month
   ├─ expenses/         ExpenseListCubit (paged), transactions page, add/edit sheet
   ├─ reports/          monthly report and charts
   └─ more/             budgets, categories, account

Dependencies only point one way: features → data → core. State management is flutter_bloc Cubits. HTTP calls use package:http.

How a screen gets its data

Page ──context.read──▶ Cubit ──▶ Api ──▶ ApiClient ──HTTP──▶ backend
  ▲                      │
  └──── BlocBuilder ◀── emit(FetchState{data, loading, error})
  • Shell creates four cubits and gives them to its tabs with BlocProvider.value:

    • StatusCubit – budget status
    • CategoriesCubit
    • ExpenseListCubit
    • ReportCubit

    StatusCubit, CategoriesCubit and ReportCubit are all FetchCubit<T> under different names.

  • When a cubit reloads, it keeps the old data on screen until the new data arrives, and it ignores a response that arrives after you've switched to another month.

  • Every error becomes an ApiException holding a message the user can read, and pages show it with a Retry button.

After you change something

Any change to an expense, budget or category ends with a call to Shell._refreshAll(). That reloads the budget status, the report and the transactions list. After a category change it also clears the transactions category filter, because the category may have been deleted. New screens that change data should take an onChanged callback and have Shell pass _refreshAll to it.

Sign-in and session

  1. AuthCubit.start() reads the token saved by SessionStore. If there is one, the app goes straight to Shell; otherwise it shows LoginPage.
  2. Signing in calls POST /v1/api/auth/login. The token is saved and attached to every request as Authorization: Bearer ….
  3. If the server answers 401 while you're signed in, ApiClient.onUnauthorized logs you out. App then closes any open page, sheet or dialog and shows the login screen again.

Money

Amounts are stored and passed around as int minor units (hundredths of a kyat), never double. money.dart converts between those integers and the API's decimal strings ("5000.00"), and formats them for display.

Backend endpoints

All endpoints below are under /v1/api/expenses.

UseMethod & path
Expenses (paged, by month and category)GET / · POST / · PUT /:id · DELETE /:id
CategoriesGET/POST /categories · PUT/DELETE /categories/:id
BudgetsGET/POST /budgets · PUT/DELETE /budgets/:id
Budget status for a monthGET /budgets/status?month=YYYY-MM
Monthly reportGET /reports/monthly?month=YYYY-MM
Read a slip photo (saves nothing)POST /scan with { image: base64 }

Creating or updating an expense can also return budgetWarnings, which the app shows as the snackbar.

Tests

test/ covers the money and month helpers, ApiClient's error handling, Api parsing, the cubits, and widget tests for the main pages. test/fakes.dart has the fake Api and storage they use. Run them with flutter test.

Fonts

Figtree (body text) and Bricolage Grotesque (titles and amounts) are included in fonts/ under the SIL Open Font License, so the app doesn't need to download them.