# roihanafh/linechip architecture

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

- Interactive diagram: https://gitdiagram.com/roihanafh/linechip
- Repository: https://github.com/roihanafh/linechip

## Overview

Linechip is a math-learning web app with interactive number-line and chip-model lessons, games, accounts, rankings, and an admin panel. The main learner flow is to enter a learning activity or game, work through its visual math interaction, and build a score that can appear on the leaderboard. The tree identifies the major product areas; sampled sources confirm the chip-animation logic, authentication/session flow, and several admin data operations. Wiring between unsampled pages, game scoring, and leaderboard services is therefore left out where it cannot be established.

Main entry points: [`features/auth/services/firebase.admin.ts`](https://github.com/roihanafh/linechip/blob/master/features/auth/services/firebase.admin.ts) (Firebase Admin), [`app/admin/page.tsx`](https://github.com/roihanafh/linechip/blob/master/app/admin/page.tsx) (Admin Panel), [`features/auth/services/authService.ts`](https://github.com/roihanafh/linechip/blob/master/features/auth/services/authService.ts) (Authentication Service), [`app/api/admin/users/route.ts`](https://github.com/roihanafh/linechip/blob/master/app/api/admin/users/route.ts) (User Management API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_learning["Math Activities"]
  node_home["Home<br/>[page.tsx]"]
  node_materials["Learning Materials<br/>[page.tsx]"]
  node_numberline["Number Line<br/>[page.tsx]"]
  node_chips["Chip Model<br/>[page.tsx]"]
  node_chipstate["Chip State"]
  node_chipanimation["Chip Animation"]
  node_subtraction["Chip Subtraction"]
end

subgraph group_games["Games and Scores"]
  node_numberlinegame["Number Line Game<br/>[page.tsx]"]
  node_virusgame["Virus Game<br/>[page.tsx]"]
  node_scoring["Game Scoring<br/>[scoreService.ts]"]
end

subgraph group_accounts["Accounts"]
  node_login["Login and Registration<br/>[LoginClient.tsx]"]
  node_authservice["Authentication Service<br/>[authService.ts]"]
  node_sessionapi["Session API<br/>[route.ts]"]
  node_profile["Profile<br/>[ProfileClient.tsx]"]
  node_profiledata["Profile Service<br/>[profileService.ts]"]
end

subgraph group_ranking["Rankings"]
  node_leaderboard["Leaderboard<br/>[page.tsx]"]
  node_leaderboardservice["Leaderboard Service"]
end

subgraph group_admin["Administration"]
  node_adminui["Admin Panel<br/>[page.tsx]"]
  node_adminusers["User Management API<br/>[route.ts]"]
  node_adminuserdetail["User Detail API<br/>[route.ts]"]
  node_adminstats["Admin Statistics API<br/>[route.ts]"]
  node_resetapi["Leaderboard Reset API<br/>[route.ts]"]
end

node_learner(("Learner"))
node_firebaseauth{{"Firebase Authentication"}}
node_adminfirebase{{"Firebase Admin<br/>[firebase.admin.ts]"}}
node_firestore[("Firestore")]

node_learner -->|"opens"| node_home
node_learner -->|"studies"| node_materials
node_learner -->|"practices"| node_numberline
node_learner -->|"practices"| node_chips
node_learner -->|"plays"| node_numberlinegame
node_learner -->|"plays"| node_virusgame
node_learner -->|"signs in"| node_login
node_learner -->|"views"| node_profile
node_learner -->|"checks"| node_leaderboard
node_chips -->|"uses state"| node_chipstate
node_chipanimation -->|"updates state"| node_chipstate
node_chipanimation -->|"builds battle plan"| node_adminfirebase
node_subtraction -->|"delegates battle"| node_chipanimation
node_login -->|"submits credentials"| node_authservice
node_authservice -->|"authenticates"| node_firebaseauth
node_authservice -->|"creates session"| node_sessionapi
node_sessionapi -->|"verifies token"| node_adminfirebase
node_profile -->|"loads profile"| node_profiledata
node_leaderboard -->|"loads rankings"| node_leaderboardservice
node_adminui -->|"manages users"| node_adminusers
node_adminui -->|"edits user"| node_adminuserdetail
node_adminui -->|"requests statistics"| node_adminstats
node_adminui -->|"resets scores"| node_resetapi
node_adminusers -->|"uses admin access"| node_adminfirebase
node_adminuserdetail -->|"uses admin access"| node_adminfirebase
node_adminstats -->|"uses admin access"| node_adminfirebase
node_resetapi -->|"uses admin access"| node_adminfirebase
node_adminusers -->|"reads and writes users"| node_firestore
node_adminuserdetail -->|"reads and updates users"| node_firestore
node_adminstats -->|"queries users"| node_firestore
node_resetapi -->|"resets scores"| node_firestore

click node_home "https://github.com/roihanafh/linechip/blob/master/app/page.tsx"
click node_materials "https://github.com/roihanafh/linechip/blob/master/app/materi/page.tsx"
click node_numberline "https://github.com/roihanafh/linechip/blob/master/app/garis-bilangan/page.tsx"
click node_numberlinegame "https://github.com/roihanafh/linechip/blob/master/app/intline-run/page.tsx"
click node_chips "https://github.com/roihanafh/linechip/blob/master/app/model-chip/page.tsx"
click node_chipstate "https://github.com/roihanafh/linechip/blob/master/hooks/model-chip/useModelChipState.ts"
click node_chipanimation "https://github.com/roihanafh/linechip/blob/master/hooks/model-chip/useAnimationOrchestrator.ts"
click node_subtraction "https://github.com/roihanafh/linechip/blob/master/hooks/model-chip/useSubtractionOrchestrator.ts"
click node_virusgame "https://github.com/roihanafh/linechip/blob/master/app/game-virus/page.tsx"
click node_scoring "https://github.com/roihanafh/linechip/blob/master/features/game/scoreService.ts"
click node_login "https://github.com/roihanafh/linechip/blob/master/app/login/LoginClient.tsx"
click node_authservice "https://github.com/roihanafh/linechip/blob/master/features/auth/services/authService.ts"
click node_sessionapi "https://github.com/roihanafh/linechip/blob/master/app/api/auth/session/route.ts"
click node_profile "https://github.com/roihanafh/linechip/blob/master/app/profile/ProfileClient.tsx"
click node_profiledata "https://github.com/roihanafh/linechip/blob/master/features/profile/services/profileService.ts"
click node_leaderboard "https://github.com/roihanafh/linechip/blob/master/app/leaderboard/page.tsx"
click node_leaderboardservice "https://github.com/roihanafh/linechip/blob/master/features/leaderboard/leaderboardService.ts"
click node_adminui "https://github.com/roihanafh/linechip/blob/master/app/admin/page.tsx"
click node_adminusers "https://github.com/roihanafh/linechip/blob/master/app/api/admin/users/route.ts"
click node_adminuserdetail "https://github.com/roihanafh/linechip/blob/master/app/api/admin/users/%5Buid%5D/route.ts"
click node_adminstats "https://github.com/roihanafh/linechip/blob/master/app/api/admin/stats/route.ts"
click node_resetapi "https://github.com/roihanafh/linechip/blob/master/app/api/admin/leaderboard/reset/route.ts"
click node_adminfirebase "https://github.com/roihanafh/linechip/blob/master/features/auth/services/firebase.admin.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_home,node_materials,node_numberline,node_chips,node_chipstate,node_chipanimation,node_subtraction toneBlue
class node_numberlinegame,node_virusgame,node_scoring,node_firestore toneAmber
class node_login,node_authservice,node_sessionapi,node_profile,node_profiledata toneMint
class node_leaderboard,node_leaderboardservice toneRose
class node_adminui,node_adminusers,node_adminuserdetail,node_adminstats,node_resetapi,node_learner,node_firebaseauth toneIndigo
class node_adminfirebase toneTeal
```

## Components

### Math Activities

- [Home](https://github.com/roihanafh/linechip/blob/master/app/page.tsx): `app/page.tsx`
- [Learning Materials](https://github.com/roihanafh/linechip/blob/master/app/materi/page.tsx): `app/materi/page.tsx`
- [Number Line](https://github.com/roihanafh/linechip/blob/master/app/garis-bilangan/page.tsx): `app/garis-bilangan/page.tsx`
- [Chip Model](https://github.com/roihanafh/linechip/blob/master/app/model-chip/page.tsx): `app/model-chip/page.tsx`
- [Chip State](https://github.com/roihanafh/linechip/blob/master/hooks/model-chip/useModelChipState.ts): `hooks/model-chip/useModelChipState.ts`
- [Chip Animation](https://github.com/roihanafh/linechip/blob/master/hooks/model-chip/useAnimationOrchestrator.ts): `hooks/model-chip/useAnimationOrchestrator.ts`
- [Chip Subtraction](https://github.com/roihanafh/linechip/blob/master/hooks/model-chip/useSubtractionOrchestrator.ts): `hooks/model-chip/useSubtractionOrchestrator.ts`

### Games and Scores

- [Number Line Game](https://github.com/roihanafh/linechip/blob/master/app/intline-run/page.tsx): `app/intline-run/page.tsx`
- [Virus Game](https://github.com/roihanafh/linechip/blob/master/app/game-virus/page.tsx): `app/game-virus/page.tsx`
- [Game Scoring](https://github.com/roihanafh/linechip/blob/master/features/game/scoreService.ts): `features/game/scoreService.ts`

### Accounts

- [Login and Registration](https://github.com/roihanafh/linechip/blob/master/app/login/LoginClient.tsx): `app/login/LoginClient.tsx`
- [Authentication Service](https://github.com/roihanafh/linechip/blob/master/features/auth/services/authService.ts): `features/auth/services/authService.ts`
- [Session API](https://github.com/roihanafh/linechip/blob/master/app/api/auth/session/route.ts): `app/api/auth/session/route.ts`
- [Profile](https://github.com/roihanafh/linechip/blob/master/app/profile/ProfileClient.tsx): `app/profile/ProfileClient.tsx`
- [Profile Service](https://github.com/roihanafh/linechip/blob/master/features/profile/services/profileService.ts): `features/profile/services/profileService.ts`

### Rankings

- [Leaderboard](https://github.com/roihanafh/linechip/blob/master/app/leaderboard/page.tsx): `app/leaderboard/page.tsx`
- [Leaderboard Service](https://github.com/roihanafh/linechip/blob/master/features/leaderboard/leaderboardService.ts): `features/leaderboard/leaderboardService.ts`

### Administration

- [Admin Panel](https://github.com/roihanafh/linechip/blob/master/app/admin/page.tsx): `app/admin/page.tsx`
- [User Management API](https://github.com/roihanafh/linechip/blob/master/app/api/admin/users/route.ts): `app/api/admin/users/route.ts`
- [User Detail API](https://github.com/roihanafh/linechip/blob/master/app/api/admin/users/%5Buid%5D/route.ts): `app/api/admin/users/[uid]/route.ts`
- [Admin Statistics API](https://github.com/roihanafh/linechip/blob/master/app/api/admin/stats/route.ts): `app/api/admin/stats/route.ts`
- [Leaderboard Reset API](https://github.com/roihanafh/linechip/blob/master/app/api/admin/leaderboard/reset/route.ts): `app/api/admin/leaderboard/reset/route.ts`

### Other components

- **Learner**
- **Firebase Authentication**
- [Firebase Admin](https://github.com/roihanafh/linechip/blob/master/features/auth/services/firebase.admin.ts): `features/auth/services/firebase.admin.ts`
- **Firestore**

## Connections

- Learner → Home: opens
- Learner → Learning Materials: studies
- Learner → Number Line: practices
- Learner → Chip Model: practices
- Learner → Number Line Game: plays
- Learner → Virus Game: plays
- Learner → Login and Registration: signs in
- Learner → Profile: views
- Learner → Leaderboard: checks
- Chip Model → Chip State: uses state
- Chip Animation → Chip State: updates state
- Chip Animation → Firebase Admin: builds battle plan
- Chip Subtraction → Chip Animation: delegates battle
- Login and Registration → Authentication Service: submits credentials
- Authentication Service → Firebase Authentication: authenticates
- Authentication Service → Session API: creates session
- Session API → Firebase Admin: verifies token
- Profile → Profile Service: loads profile
- Leaderboard → Leaderboard Service: loads rankings
- Admin Panel → User Management API: manages users
- Admin Panel → User Detail API: edits user
- Admin Panel → Admin Statistics API: requests statistics
- Admin Panel → Leaderboard Reset API: resets scores
- User Management API → Firebase Admin: uses admin access
- User Detail API → Firebase Admin: uses admin access
- Admin Statistics API → Firebase Admin: uses admin access
- Leaderboard Reset API → Firebase Admin: uses admin access
- User Management API → Firestore: reads and writes users
- User Detail API → Firestore: reads and updates users
- Admin Statistics API → Firestore: queries users
- Leaderboard Reset API → Firestore: resets scores
