# damisoda/career-piggybank architecture

> Architecture diagram of the GitHub repository damisoda/career-piggybank, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/damisoda/career-piggybank
- Repository: https://github.com/damisoda/career-piggybank

## Overview

1. **Repository shape**
   - This is a **monorepo** with two shipping applications and one planned shared package:
     - `apps/mobile`: the main product, an **Expo / React Native / TypeScript** app
     - `apps/api`: a **FastAPI / Python** backend focused on the tax-envelope engine
     - `packages/shared`: placeholder for common types/constants, not yet active

2. **Product boundary**
   - The repo is centered on a **personal finance platform for gig workers**.
   - The core product concept is not generic banking; it is a workflow that turns income events into structured “envelopes” for tax, expenses, savings, and spendable cash.

3. **Mobile app as the primary UX**
   - `apps/mobile` is the user-facing application and likely the main entry point for the experience.
   - The app is organized by **screens** rather than heavy backend orchestration, which suggests a feature-driven UI layer:
     - onboarding / intro (`Intro`, `Connect`)
     - finance views (`Home`, `Tax`, `Ledger`, `Products`, `Retirement`, `NestEgg`, `Piggy`)
     - detailed views (`TxDetail`, `ProductDetail`, `VerifiedDetail`)
     - account/settings and lock screens

4. **Mobile app internal structure**
   - The mobile app separates concerns into:
     - `src/screens`: route-level UI
     - `src/components`: reusable UI pieces
     - `src/store.tsx`: shared state management for app data
     - `src/lib`: domain logic and integration helpers
     - `src/products.ts` and `src/jobs.ts`: product/content or workflow data
   - This indicates a **thin UI over local state/domain logic**, not a server-rendered app.

5. **On-device tax-envelope engine**
   - The most important domain subsystem is the **tax envelope calculator**.
   - In the mobile app, `src/lib/taxEnvelope.ts` implements the computation locally so the first demo can run **without backend dependency**.
   - This is a key architectural boundary: the same deterministic financial logic exists both on-device and in the backend, so the app can function offline or in demo mode.

6. **Backend engine service**
   - `apps/api` exposes the same tax-envelope domain logic as a **FastAPI service**.
   - The backend is organized into:
     - `app/api/routes`: HTTP endpoints
     - `app/services`: business logic, especially `tax_envelope.py`
     - `app/schemas`: request/response models
     - `app/core/config.py`: environment/config handling
     - `app/main.py`: app bootstrap and router wiring
   - The service appears **stateless and computation-focused**, not a CRUD app with a database layer.

7. **API surface and responsibilities**
   - The backend includes:
     - a **health check** route for service availability
     - a **tax-envelope route group** under `/v1/tax-envelope/*` for deterministic calculations
   - The README explicitly says this engine:
     - splits a gig-worker income deposit into **tax / expenses / available cash / immediate usable cash**
     - estimates the **May comprehensive income tax settlement reserve**
     - exposes assumptions such as expense rate, tax brackets, and buffer rate in the output

8. **Data flow between mobile and API**
   - The primary flow is:
     1. user enters or views an income event in the mobile app
     2. the mobile app can compute envelope allocation locally
     3. the backend can compute the same result via HTTP for validation or API-driven usage
   - This creates a **dual-implementation contract**: the mobile and backend engines must stay behaviorally aligned.

9. **Testing and correctness**
   - The backend has explicit tests in `apps/api/tests/test_tax_envelope.py`, which implies the tax logic is treated as a **deterministic calculation engine** with expected outputs.
   - Because the calculator is mirrored in both mobile and API, correctness is important not just for one implementation but for **cross-platform consistency**.

10. **Tooling and deployment shape**
    - Root `Makefile` provides simple orchestration for local development:
      - `make api`
      - `make api-test`
      - `make mobile`
    - CI is defined in `.github/workflows/ci.yml`, showing the repo is meant to be validated automatically across the two app surfaces.

11. **Infrastructure and external boundaries**
    - The repo does **not** show a database, queue, or third-party service integration as a core runtime dependency.
    - The README mentions future or external finance integrations such as **MyData, Hometax, and OAuth keys**, but those are treated as secrets/configuration boundaries rather than current architecture centerpieces.

12. **Overall architecture summary**
    - The system is best understood as:
      - a **mobile-first financial experience**
      - backed by a **deterministic finance rules engine**
      - with the same calculation logic available **locally and via FastAPI**
      - and with a future shared package intended to reduce drift between platforms
    - For an architecture diagram, the key boxes are: **Mobile UI**, **Local domain logic**, **API calculation service**, **Config/Secrets**, and **CI/Tests**.

Main entry points: [`apps/mobile/src/screens`](https://github.com/damisoda/career-piggybank/tree/main/apps/mobile/src/screens) (Screens), [`apps/mobile/src/lib`](https://github.com/damisoda/career-piggybank/tree/main/apps/mobile/src/lib) (Local domain), [`apps/api/app/api/routes`](https://github.com/damisoda/career-piggybank/tree/main/apps/api/app/api/routes) (HTTP routes), [`apps/api/app/main.py`](https://github.com/damisoda/career-piggybank/blob/main/apps/api/app/main.py) (API bootstrap)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_mobile["Mobile app"]
  node_node_mobile_ui["Mobile UI<br/>Expo app<br/>[index.tsx]"]
  node_node_mobile_layout["App layout<br/>Routing shell<br/>[_layout.tsx]"]
  node_node_mobile_screens["Screens"]
  node_node_mobile_components["UI components<br/>Reusable views"]
  node_node_mobile_store["App store<br/>State store<br/>[store.tsx]"]
  node_node_mobile_domain["Local domain<br/>Client logic"]
  node_node_mobile_tax["Envelope calc<br/>Deterministic engine<br/>[taxEnvelope.ts]"]
  node_node_mobile_api["API client<br/>HTTP client<br/>[api.ts]"]
  node_node_mobile_content["Products data<br/>Catalog data<br/>[products.ts]"]
  node_node_mobile_jobs["Jobs data<br/>Workflow data<br/>[jobs.ts]"]
end

subgraph group_group_api["API service"]
  node_node_api_main["API bootstrap<br/>FastAPI app<br/>[main.py]"]
  node_node_api_routes["HTTP routes<br/>Route layer"]
  node_node_api_tax_route["Tax route<br/>Endpoint group<br/>[tax_envelope.py]"]
  node_node_api_health["Health check<br/>Endpoint<br/>[health.py]"]
  node_node_api_services["Services<br/>Business logic"]
  node_node_api_tax_service["Tax service<br/>Calculation engine<br/>[tax_envelope.py]"]
  node_node_api_schemas["Schemas<br/>Pydantic models"]
  node_node_api_config["Config<br/>[config.py]"]
  node_node_api_tests["Tax tests<br/>Unit tests"]
end

subgraph group_group_repo["Repo tooling"]
  node_node_makefile["Makefile<br/>Dev orchestration"]
  node_node_ci["CI workflow<br/>Automation<br/>[ci.yml]"]
  node_node_shared["Shared pkg<br/>Planned package<br/>[README.md]"]
end

node_node_mobile_ui -->|"uses"| node_node_mobile_layout
node_node_mobile_layout -->|"renders"| node_node_mobile_screens
node_node_mobile_screens -->|"composes"| node_node_mobile_components
node_node_mobile_screens -->|"reads/writes"| node_node_mobile_store
node_node_mobile_store -->|"calls"| node_node_mobile_domain
node_node_mobile_domain -->|"includes"| node_node_mobile_tax
node_node_mobile_domain -->|"uses"| node_node_mobile_api
node_node_mobile_screens -->|"uses"| node_node_mobile_content
node_node_mobile_screens -->|"uses"| node_node_mobile_jobs
node_node_api_main -->|"mounts"| node_node_api_routes
node_node_api_routes -->|"exposes"| node_node_api_health
node_node_api_routes -->|"exposes"| node_node_api_tax_route
node_node_api_tax_route -->|"delegates"| node_node_api_services
node_node_api_services -->|"implements"| node_node_api_tax_service
node_node_api_tax_service -->|"returns"| node_node_api_schemas
node_node_api_main -->|"loads"| node_node_api_config
node_node_api_tests -->|"verifies"| node_node_api_tax_service
node_node_makefile -->|"runs"| node_node_mobile_ui
node_node_makefile -->|"runs"| node_node_api_main
node_node_ci -->|"checks"| node_node_api_tests
node_node_ci -->|"checks"| node_node_mobile_ui
node_node_shared -.->|"intended for"| node_node_mobile_domain
node_node_shared -.->|"intended for"| node_node_api_schemas

click node_node_mobile_ui "https://github.com/damisoda/career-piggybank/blob/main/apps/mobile/app/index.tsx"
click node_node_mobile_layout "https://github.com/damisoda/career-piggybank/blob/main/apps/mobile/app/_layout.tsx"
click node_node_mobile_screens "https://github.com/damisoda/career-piggybank/tree/main/apps/mobile/src/screens"
click node_node_mobile_components "https://github.com/damisoda/career-piggybank/tree/main/apps/mobile/src/components"
click node_node_mobile_store "https://github.com/damisoda/career-piggybank/blob/main/apps/mobile/src/store.tsx"
click node_node_mobile_domain "https://github.com/damisoda/career-piggybank/tree/main/apps/mobile/src/lib"
click node_node_mobile_tax "https://github.com/damisoda/career-piggybank/blob/main/apps/mobile/src/lib/taxEnvelope.ts"
click node_node_mobile_api "https://github.com/damisoda/career-piggybank/blob/main/apps/mobile/src/lib/api.ts"
click node_node_mobile_content "https://github.com/damisoda/career-piggybank/blob/main/apps/mobile/src/products.ts"
click node_node_mobile_jobs "https://github.com/damisoda/career-piggybank/blob/main/apps/mobile/src/jobs.ts"
click node_node_api_main "https://github.com/damisoda/career-piggybank/blob/main/apps/api/app/main.py"
click node_node_api_routes "https://github.com/damisoda/career-piggybank/tree/main/apps/api/app/api/routes"
click node_node_api_tax_route "https://github.com/damisoda/career-piggybank/blob/main/apps/api/app/api/routes/tax_envelope.py"
click node_node_api_health "https://github.com/damisoda/career-piggybank/blob/main/apps/api/app/api/routes/health.py"
click node_node_api_services "https://github.com/damisoda/career-piggybank/tree/main/apps/api/app/services"
click node_node_api_tax_service "https://github.com/damisoda/career-piggybank/blob/main/apps/api/app/services/tax_envelope.py"
click node_node_api_schemas "https://github.com/damisoda/career-piggybank/tree/main/apps/api/app/schemas"
click node_node_api_config "https://github.com/damisoda/career-piggybank/blob/main/apps/api/app/core/config.py"
click node_node_api_tests "https://github.com/damisoda/career-piggybank/blob/main/apps/api/tests/test_tax_envelope.py"
click node_node_makefile "https://github.com/damisoda/career-piggybank/tree/main/Makefile"
click node_node_ci "https://github.com/damisoda/career-piggybank/blob/main/.github/workflows/ci.yml"
click node_node_shared "https://github.com/damisoda/career-piggybank/blob/main/packages/shared/README.md"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_node_mobile_ui,node_node_mobile_layout,node_node_mobile_screens,node_node_mobile_components,node_node_mobile_store,node_node_mobile_domain,node_node_mobile_tax,node_node_mobile_api,node_node_mobile_content,node_node_mobile_jobs toneBlue
class node_node_api_main,node_node_api_routes,node_node_api_tax_route,node_node_api_health,node_node_api_services,node_node_api_tax_service,node_node_api_schemas,node_node_api_config,node_node_api_tests toneAmber
class node_node_makefile,node_node_ci,node_node_shared toneMint
```

## Components

### Mobile app

Expo/React Native client and on-device domain logic.

- [Mobile UI](https://github.com/damisoda/career-piggybank/blob/main/apps/mobile/app/index.tsx): Expo app · User-facing finance experience and navigation entrypoint. · `apps/mobile/app/index.tsx`
- [App layout](https://github.com/damisoda/career-piggybank/blob/main/apps/mobile/app/_layout.tsx): Routing shell · Top-level mobile route composition and screen wiring. · `apps/mobile/app/_layout.tsx`
- [Screens](https://github.com/damisoda/career-piggybank/tree/main/apps/mobile/src/screens): Feature screens · Primary user flows such as onboarding, home, ledger, tax, products, and settings. · `apps/mobile/src/screens`
- [UI components](https://github.com/damisoda/career-piggybank/tree/main/apps/mobile/src/components): Reusable views · Shared visual building blocks used across mobile screens. · `apps/mobile/src/components`
- [App store](https://github.com/damisoda/career-piggybank/blob/main/apps/mobile/src/store.tsx): State store · Shared client state and data coordination for the mobile app. · `apps/mobile/src/store.tsx`
- [Local domain](https://github.com/damisoda/career-piggybank/tree/main/apps/mobile/src/lib): Client logic · Client-side business helpers and integration utilities. · `apps/mobile/src/lib`
- [Envelope calc](https://github.com/damisoda/career-piggybank/blob/main/apps/mobile/src/lib/taxEnvelope.ts): Deterministic engine · On-device tax-envelope calculation so the demo can run without backend dependency. · `apps/mobile/src/lib/taxEnvelope.ts`
- [API client](https://github.com/damisoda/career-piggybank/blob/main/apps/mobile/src/lib/api.ts): HTTP client · Mobile-side service wrapper for backend calls. · `apps/mobile/src/lib/api.ts`
- [Products data](https://github.com/damisoda/career-piggybank/blob/main/apps/mobile/src/products.ts): Catalog data · Product and workflow content used by the mobile experience. · `apps/mobile/src/products.ts`
- [Jobs data](https://github.com/damisoda/career-piggybank/blob/main/apps/mobile/src/jobs.ts): Workflow data · Gig-worker job and income-event related data definitions. · `apps/mobile/src/jobs.ts`

### API service

FastAPI backend for deterministic tax-envelope calculations.

- [API bootstrap](https://github.com/damisoda/career-piggybank/blob/main/apps/api/app/main.py): FastAPI app · Application startup and router wiring. · `apps/api/app/main.py`
- [HTTP routes](https://github.com/damisoda/career-piggybank/tree/main/apps/api/app/api/routes): Route layer · Endpoint group for health and tax-envelope operations. · `apps/api/app/api/routes`
- [Tax route](https://github.com/damisoda/career-piggybank/blob/main/apps/api/app/api/routes/tax_envelope.py): Endpoint group · Versioned tax-envelope HTTP entrypoints. · `apps/api/app/api/routes/tax_envelope.py`
- [Health check](https://github.com/damisoda/career-piggybank/blob/main/apps/api/app/api/routes/health.py): Endpoint · Service availability probe. · `apps/api/app/api/routes/health.py`
- [Services](https://github.com/damisoda/career-piggybank/tree/main/apps/api/app/services): Business logic · Server-side computation layer. · `apps/api/app/services`
- [Tax service](https://github.com/damisoda/career-piggybank/blob/main/apps/api/app/services/tax_envelope.py): Calculation engine · Backend implementation of the gig-worker envelope split and settlement reserve logic. · `apps/api/app/services/tax_envelope.py`
- [Schemas](https://github.com/damisoda/career-piggybank/tree/main/apps/api/app/schemas): Pydantic models · Request and response models for the API. · `apps/api/app/schemas`
- [Config](https://github.com/damisoda/career-piggybank/blob/main/apps/api/app/core/config.py): Environment config · Backend settings and secret-bound configuration handling. · `apps/api/app/core/config.py`
- [Tax tests](https://github.com/damisoda/career-piggybank/blob/main/apps/api/tests/test_tax_envelope.py): Unit tests · Deterministic checks for the tax-envelope engine. · `apps/api/tests/test_tax_envelope.py`

### Repo tooling

Root orchestration, CI, and shared package placeholder.

- [Makefile](https://github.com/damisoda/career-piggybank/tree/main/Makefile): Dev orchestration · Local commands for running mobile and API development tasks. · `Makefile`
- [CI workflow](https://github.com/damisoda/career-piggybank/blob/main/.github/workflows/ci.yml): Automation · Repository validation workflow for the two app surfaces. · `.github/workflows/ci.yml`
- [Shared pkg](https://github.com/damisoda/career-piggybank/blob/main/packages/shared/README.md): Planned package · Placeholder for cross-platform shared types and constants. · `packages/shared/README.md`

## Connections

- Mobile UI → App layout: uses · The app entry is composed by the routing shell.
- App layout → Screens: renders · Routes resolve into feature screens.
- Screens → UI components: composes · Screens reuse shared UI pieces.
- Screens → App store: reads/writes · Screens coordinate state through the shared store.
- App store → Local domain: calls · State layer depends on domain and integration helpers.
- Local domain → Envelope calc: includes · Local deterministic tax-envelope logic lives in the client domain layer.
- Local domain → API client: uses · Client domain can call backend services when needed.
- Screens → Products data: uses · Product and workflow screens use shared content data.
- Screens → Jobs data: uses · Income-event and gig workflow data feed the screens.
- API bootstrap → HTTP routes: mounts · Bootstrap wires HTTP routes into the application.
- HTTP routes → Health check: exposes · Availability probe endpoint.
- HTTP routes → Tax route: exposes · Versioned envelope calculation endpoints.
- Tax route → Services: delegates · Route handlers pass computation to the service layer.
- Services → Tax service: implements · Core backend tax-envelope logic.
- Tax service → Schemas: returns · Service inputs and outputs are modeled with schemas.
- API bootstrap → Config: loads · Startup depends on environment configuration.
- Tax tests → Tax service: verifies · Tests assert deterministic engine behavior.
- Makefile → Mobile UI: runs · Root dev tasks can start the mobile app.
- Makefile → API bootstrap: runs · Root dev tasks can start the API service.
- CI workflow → Tax tests: checks · CI validates backend behavior.
- CI workflow → Mobile UI: checks · CI validates the mobile application surface.
- Shared pkg → Local domain: intended for · Planned shared types/constants should reduce client-server drift.
- Shared pkg → Schemas: intended for · Shared contracts are a future fit for API models.
