How harutojazz45/juku-salary-app works
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: App.tsx App · useSalaryData.ts useSalaryData · useAuth.ts useAuth · BadgeDisplay.tsx Badges
Components 18
UI Layer
React entry, dashboard widgets, and modal-driven feature screens.
- main.tsx · Bootstraps React and mounts the app.
src/main.tsx - App · Top-level composition for dashboard, dialogs, and app-wide state wiring.
src/App.tsx - Calendar · Primary schedule and work-entry view.
src/components/CalendarGrid.tsx - Summary · Salary and status summary display.
src/components/SummaryCard.tsx - Tax Monitor · Shows tax-related alerts and thresholds.
src/components/TaxMonitor.tsx - Badges · Displays earned badges and progression cues.
src/components/BadgeDisplay.tsx - Feature Modals · 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 · Central salary-data boundary for local edits, settings, and sync orchestration.
src/hooks/useSalaryData.ts - useAuth · Encapsulates session state and Firebase authentication.
src/hooks/useAuth.ts - Language · Provides active locale selection to the UI.
src/contexts/LanguageContext.tsx
Domain Logic
Pure salary, progression, badge, and ranking computation.
- Calculator · Pure compensation and allowance calculations.
src/utils/calculator.ts - Levels · XP, title, and level progression logic.
src/utils/levelSystem.ts - Badges · Badge award logic and unlock conditions.
src/utils/badges.ts - Ranking · Ranking and leaderboard computations.
src/utils/ranking.ts
Data Integration
Firebase and bundled content/localization assets.
Shared Types
Common domain interfaces used across hooks, UI, and utilities.
- Types · Shared interfaces and models for data and UI state.
src/types/index.ts
Connections 21
- 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.