# harutojazz45/juku-salary-app architecture

> Architecture diagram of the GitHub repository harutojazz45/juku-salary-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/harutojazz45/juku-salary-app
- Repository: https://github.com/harutojazz45/juku-salary-app

## Overview

1. **Application shape**
   - This is a **single-page React 18 + TypeScript app** built with **Vite**.
   - There is no separate server in this repo; the client app owns most of the logic and talks directly to **Firebase** for auth and cloud sync.

2. **Entry and composition**
   - `src/main.tsx` boots the app and mounts `App.tsx`.
   - `App.tsx` is the top-level orchestrator: it wires together the dashboard, calendar, summary, and the various feature modals.

3. **Primary UI layout**
   - The UI is organized around a **main dashboard plus modal-driven workflows**.
   - Core visible widgets include `CalendarGrid`, `SummaryCard`, `TaxMonitor`, and `BadgeDisplay`.
   - Feature-specific dialogs are split into separate modal components such as `WorkModal`, `SettingsModal`, `AccountModal`, `AuthModal`, `AnalyticsModal`, `RankingModal`, `DataManagementModal`, `NewsModal`, `FeedbackModal`, and `BadgeHelpModal`.

4. **State and data management boundary**
   - The most important data boundary is `useSalaryData`.
   - This hook appears to be the central domain store for salary-related data such as work entries and settings, and it is the layer that UI components interact with rather than talking to storage directly.

5. **Offline-first persistence flow**
   - The app is designed to work **locally first** using **browser LocalStorage**.
   - User edits are saved immediately on the client, so the app remains responsive and usable offline.
   - When a user is authenticated, `useSalaryData` syncs those local changes to **Firestore** in the background.

6. **Firebase integration**
   - `src/lib/firebase.ts` centralizes Firebase SDK setup.
   - Firebase is used for:
     - **Authentication** via `useAuth`
     - **Firestore** for cloud backup, synchronization, and global ranking data
   - This creates a clear split between local-first usage and authenticated cloud-backed usage.

7. **Authentication boundary**
   - `useAuth` encapsulates login/session state and likely shields the UI from direct Firebase auth details.
   - Auth-related UI is isolated in `AuthModal` and `AccountModal`, keeping identity management separate from salary calculation and schedule entry.

8. **Business logic and pure computation**
   - Most domain calculations live in `src/utils/`, which is a key architectural boundary.
   - `calculator.ts` handles salary and allowance calculations.
   - `levelSystem.ts` handles XP/title progression.
   - `badges.ts` and `ranking.ts` support gamification and leaderboard-style features.
   - These utilities are intentionally separate from React, making the rules reusable and testable.

9. **Salary domain model**
   - The app’s core domain is teaching-work compensation:
     - lesson pay
     - office/admin pay
     - travel/transport-related adjustments
     - help-work adjustments
     - tax-related monitoring
   - The README indicates that the calculator accounts for class-based pay, prep time, break-time rules, and location-based adjustments.

10. **Gamification subsystem**
   - The app includes a lightweight progression system built around:
     - badges
     - XP / level calculation
     - titles or ranks
     - ranking views
   - These features are surfaced through `BadgeDisplay`, `RankingModal`, and the helper utilities in `levelSystem.ts`, `badges.ts`, and `ranking.ts`.

11. **Internationalization**
   - Language support is handled by `LanguageContext` plus static locale dictionaries in `src/locales/` for **Japanese, English, and Spanish**.
   - Translation data is separated from components, so the UI can switch languages without changing feature logic.

12. **Static data and content**
   - `src/data/news.ts` holds in-app news content, suggesting some content is bundled rather than fetched remotely.
   - This is another local-only data source, separate from salary state and Firebase-backed user data.

13. **Type and model layer**
   - Shared interfaces and domain types live in `src/types/`.
   - This keeps entry data, settings, and UI state shapes consistent across hooks, utilities, and components.

14. **Practical architecture summary**
   - The repo is best understood as:
     - **React UI layer** for display and user interaction
     - **custom hooks** for auth and salary-data orchestration
     - **pure utility layer** for calculations and progression logic
     - **Firebase integration layer** for authenticated cloud sync
     - **LocalStorage** as the primary offline persistence mechanism
   - That separation is the key boundary to show in an architecture diagram.

Main entry points: [`src/App.tsx`](https://github.com/harutojazz45/juku-salary-app/blob/main/src/App.tsx) (App), [`src/hooks/useSalaryData.ts`](https://github.com/harutojazz45/juku-salary-app/blob/main/src/hooks/useSalaryData.ts) (useSalaryData), [`src/hooks/useAuth.ts`](https://github.com/harutojazz45/juku-salary-app/blob/main/src/hooks/useAuth.ts) (useAuth), [`src/components/BadgeDisplay.tsx`](https://github.com/harutojazz45/juku-salary-app/blob/main/src/components/BadgeDisplay.tsx) (Badges)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["UI Layer"]
  node_src_main_tsx(("main.tsx<br/>entrypoint<br/>[main.tsx]"))
  node_src_app_tsx["App<br/>orchestrator<br/>[App.tsx]"]
  node_calendar_grid["Calendar<br/>widget<br/>[CalendarGrid.tsx]"]
  node_summary_card["Summary<br/>widget<br/>[SummaryCard.tsx]"]
  node_tax_monitor["Tax Monitor<br/>widget<br/>[TaxMonitor.tsx]"]
  node_badge_display["Badges<br/>widget<br/>[BadgeDisplay.tsx]"]
  node_feature_modals["Feature Modals<br/>modal suite"]
end

subgraph group_state["App State"]
  node_use_salary_data["useSalaryData<br/>domain store<br/>[useSalaryData.ts]"]
  node_use_auth["useAuth<br/>auth hook<br/>[useAuth.ts]"]
  node_language_context["Language<br/>i18n context"]
end

subgraph group_domain["Domain Logic"]
  node_calculator["Calculator<br/>salary rules<br/>[calculator.ts]"]
  node_level_system["Levels<br/>progression rules<br/>[levelSystem.ts]"]
  node_badges_utils["Badges<br/>badge rules<br/>[badges.ts]"]
  node_ranking_utils["Ranking<br/>leaderboard rules<br/>[ranking.ts]"]
end

subgraph group_integration["Data Integration"]
  node_firebase_lib[("Firebase<br/>sdk setup<br/>[firebase.ts]")]
  node_news_data["News<br/>static content<br/>[news.ts]"]
  node_locales["Locales<br/>translation data"]
end

subgraph group_types["Shared Types"]
  node_shared_types["Types<br/>[index.ts]"]
end

node_src_main_tsx -->|"mounts"| node_src_app_tsx
node_src_app_tsx -->|"renders"| node_calendar_grid
node_src_app_tsx -->|"renders"| node_summary_card
node_src_app_tsx -->|"renders"| node_tax_monitor
node_src_app_tsx -->|"renders"| node_badge_display
node_src_app_tsx -->|"opens"| node_feature_modals
node_src_app_tsx -->|"uses"| node_use_salary_data
node_src_app_tsx -->|"uses"| node_use_auth
node_src_app_tsx -->|"uses"| node_language_context
node_feature_modals -->|"acts on"| node_use_salary_data
node_feature_modals -->|"auth flows"| node_use_auth
node_use_salary_data -->|"computes"| node_calculator
node_use_salary_data -->|"syncs"| node_firebase_lib
node_use_salary_data -->|"models"| node_shared_types
node_use_auth -->|"authenticates"| node_firebase_lib
node_language_context -->|"loads"| node_locales
node_calculator -->|"uses"| node_shared_types
node_level_system -->|"feeds"| node_badge_display
node_badges_utils -->|"feeds"| node_badge_display
node_ranking_utils -->|"feeds"| node_feature_modals
node_news_data -->|"shows"| node_feature_modals

click node_src_main_tsx "https://github.com/harutojazz45/juku-salary-app/blob/main/src/main.tsx"
click node_src_app_tsx "https://github.com/harutojazz45/juku-salary-app/blob/main/src/App.tsx"
click node_calendar_grid "https://github.com/harutojazz45/juku-salary-app/blob/main/src/components/CalendarGrid.tsx"
click node_summary_card "https://github.com/harutojazz45/juku-salary-app/blob/main/src/components/SummaryCard.tsx"
click node_tax_monitor "https://github.com/harutojazz45/juku-salary-app/blob/main/src/components/TaxMonitor.tsx"
click node_badge_display "https://github.com/harutojazz45/juku-salary-app/blob/main/src/components/BadgeDisplay.tsx"
click node_use_salary_data "https://github.com/harutojazz45/juku-salary-app/blob/main/src/hooks/useSalaryData.ts"
click node_use_auth "https://github.com/harutojazz45/juku-salary-app/blob/main/src/hooks/useAuth.ts"
click node_language_context "https://github.com/harutojazz45/juku-salary-app/blob/main/src/contexts/LanguageContext.tsx"
click node_firebase_lib "https://github.com/harutojazz45/juku-salary-app/blob/main/src/lib/firebase.ts"
click node_calculator "https://github.com/harutojazz45/juku-salary-app/blob/main/src/utils/calculator.ts"
click node_level_system "https://github.com/harutojazz45/juku-salary-app/blob/main/src/utils/levelSystem.ts"
click node_badges_utils "https://github.com/harutojazz45/juku-salary-app/blob/main/src/utils/badges.ts"
click node_ranking_utils "https://github.com/harutojazz45/juku-salary-app/blob/main/src/utils/ranking.ts"
click node_news_data "https://github.com/harutojazz45/juku-salary-app/blob/main/src/data/news.ts"
click node_locales "https://github.com/harutojazz45/juku-salary-app/tree/main/src/locales"
click node_shared_types "https://github.com/harutojazz45/juku-salary-app/blob/main/src/types/index.ts"

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_src_main_tsx,node_src_app_tsx,node_calendar_grid,node_summary_card,node_tax_monitor,node_badge_display,node_feature_modals toneBlue
class node_use_salary_data,node_use_auth,node_language_context toneAmber
class node_calculator,node_level_system,node_badges_utils,node_ranking_utils toneMint
class node_firebase_lib,node_news_data,node_locales toneRose
class node_shared_types toneIndigo
```

## Components

### UI Layer

React entry, dashboard widgets, and modal-driven feature screens.

- [main.tsx](https://github.com/harutojazz45/juku-salary-app/blob/main/src/main.tsx): entrypoint · Bootstraps React and mounts the app. · `src/main.tsx`
- [App](https://github.com/harutojazz45/juku-salary-app/blob/main/src/App.tsx): orchestrator · Top-level composition for dashboard, dialogs, and app-wide state wiring. · `src/App.tsx`
- [Calendar](https://github.com/harutojazz45/juku-salary-app/blob/main/src/components/CalendarGrid.tsx): widget · Primary schedule and work-entry view. · `src/components/CalendarGrid.tsx`
- [Summary](https://github.com/harutojazz45/juku-salary-app/blob/main/src/components/SummaryCard.tsx): widget · Salary and status summary display. · `src/components/SummaryCard.tsx`
- [Tax Monitor](https://github.com/harutojazz45/juku-salary-app/blob/main/src/components/TaxMonitor.tsx): widget · Shows tax-related alerts and thresholds. · `src/components/TaxMonitor.tsx`
- [Badges](https://github.com/harutojazz45/juku-salary-app/blob/main/src/components/BadgeDisplay.tsx): widget · Displays earned badges and progression cues. · `src/components/BadgeDisplay.tsx`
- **Feature Modals**: modal suite · Work, settings, account, auth, analytics, ranking, data, news, feedback, and badge-help dialogs.

### App State

Custom hooks and shared context that coordinate client state and language.

- [useSalaryData](https://github.com/harutojazz45/juku-salary-app/blob/main/src/hooks/useSalaryData.ts): domain store · Central salary-data boundary for local edits, settings, and sync orchestration. · `src/hooks/useSalaryData.ts`
- [useAuth](https://github.com/harutojazz45/juku-salary-app/blob/main/src/hooks/useAuth.ts): auth hook · Encapsulates session state and Firebase authentication. · `src/hooks/useAuth.ts`
- [Language](https://github.com/harutojazz45/juku-salary-app/blob/main/src/contexts/LanguageContext.tsx): i18n context · Provides active locale selection to the UI. · `src/contexts/LanguageContext.tsx`

### Domain Logic

Pure salary, progression, badge, and ranking computation.

- [Calculator](https://github.com/harutojazz45/juku-salary-app/blob/main/src/utils/calculator.ts): salary rules · Pure compensation and allowance calculations. · `src/utils/calculator.ts`
- [Levels](https://github.com/harutojazz45/juku-salary-app/blob/main/src/utils/levelSystem.ts): progression rules · XP, title, and level progression logic. · `src/utils/levelSystem.ts`
- [Badges](https://github.com/harutojazz45/juku-salary-app/blob/main/src/utils/badges.ts): badge rules · Badge award logic and unlock conditions. · `src/utils/badges.ts`
- [Ranking](https://github.com/harutojazz45/juku-salary-app/blob/main/src/utils/ranking.ts): leaderboard rules · Ranking and leaderboard computations. · `src/utils/ranking.ts`

### Data Integration

Firebase and bundled content/localization assets.

- [Firebase](https://github.com/harutojazz45/juku-salary-app/blob/main/src/lib/firebase.ts): sdk setup · Central Firebase initialization for auth and Firestore. · `src/lib/firebase.ts`
- [News](https://github.com/harutojazz45/juku-salary-app/blob/main/src/data/news.ts): static content · Bundled in-app news content. · `src/data/news.ts`
- [Locales](https://github.com/harutojazz45/juku-salary-app/tree/main/src/locales): translation data · Static dictionaries for Japanese, English, and Spanish. · `src/locales`

### Shared Types

Common domain interfaces used across hooks, UI, and utilities.

- [Types](https://github.com/harutojazz45/juku-salary-app/blob/main/src/types/index.ts): domain types · Shared interfaces and models for data and UI state. · `src/types/index.ts`

## Connections

- main.tsx → App: mounts · React bootstrapping hands off to the app shell.
- App → Calendar: renders · App composes the main schedule view.
- App → Summary: renders · App composes the summary area.
- App → Tax Monitor: renders · App includes tax monitoring in the dashboard.
- App → Badges: renders · App surfaces badge progression.
- App → Feature Modals: opens · App controls modal-driven workflows.
- App → useSalaryData: uses · App reads and mutates salary-domain state through the hook.
- App → useAuth: uses · App consults auth state for account and login flows.
- App → Language: uses · App participates in locale-aware rendering.
- Feature Modals → useSalaryData: acts on · Dialogs edit and inspect the central salary store.
- Feature Modals → useAuth: auth flows · Auth and account dialogs use session state.
- useSalaryData → Calculator: computes · Domain totals and adjustments are derived through calculation rules.
- useSalaryData → Firebase: syncs · Authenticated changes are backed up to Firestore.
- useSalaryData → Types: models · Store state is shaped by shared domain types.
- useAuth → Firebase: authenticates · Authentication is backed by Firebase SDK setup.
- Language → Locales: loads · Active language selects from bundled translation dictionaries.
- Calculator → Types: uses · Calculation inputs and outputs use shared models.
- Levels → Badges: feeds · Progression results are surfaced in the badge UI.
- Badges → Badges: feeds · Badge rules drive visible achievements.
- Ranking → Feature Modals: feeds · Ranking views rely on leaderboard calculations.
- News → Feature Modals: shows · News content is displayed through the modal layer.
