Skip to content

Commit 0686d9e

Browse files
authored
refactor: convert from popup to new page (BREAKING CHANGE)
BREAKING CHANGE: - Complete dashboard - Complete GPA calculator - Complete study/exam schedule feature - Complete study roadmap - Redesign UI/UX - Improve popup for student portal interaction - Complete information and settings pages - Refactor popup architecture to tab - Testing and bug fixing (close #54)
1 parent 3867800 commit 0686d9e

158 files changed

Lines changed: 16706 additions & 3710 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
MPC_KEY="MPC"

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## Mô tả
2+
3+
<!-- Tóm tắt ngắn gọn thay đổi -->
4+
5+
## Loại thay đổi
6+
7+
- [ ] Sửa lỗi (bug fix)
8+
- [ ] Tính năng mới (feature)
9+
- [ ] Thay đổi lớn (breaking change)
10+
- [ ] Cải tiến hiệu năng
11+
- [ ] Tài liệu
12+
13+
## Checklist
14+
15+
- [ ] Đã test trên Chrome (`pnpm dev`)
16+
- [ ] Đã test trên Firefox (`pnpm dev:firefox`)
17+
- [ ] `pnpm ultracite:check` pass
18+
- [ ] `pnpm compile` pass
19+
- [ ] Commit theo Conventional Commits
20+
21+
## Ghi chú thêm
22+
23+
<!-- Ảnh chụp màn hình, log, hoặc thông tin bổ sung -->
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
description: Apply comprehensive project context, architecture details, and coding style rules for all coding and debugging tasks in the repository.
3+
applyTo: '**/*'
4+
---
5+
6+
# Project Context
7+
8+
This project is a **Manifest V3 browser extension** (Chrome + Firefox) built with **WXT**, **React 19**, **TypeScript**, and **Tailwind CSS v4**. It helps students track grades, schedules, and info by scraping university portal pages.
9+
10+
## Key Technologies & Architecture
11+
- **State Management**: Zustand stores persisted to `chrome.storage.sync` (global) and `chrome.storage.local` (per-user data).
12+
- **Storage tiers**: `sync:` for cross-device global settings; `local:{MSSV}:{suffix}` for per-user data (scores, info, calendar, userSettings); `local:{MSSV}:avatar` for avatar separately.
13+
- **Data Flow**: Side Panel UI -> Background Service Worker -> Content Scripts (DOM scraping).
14+
- **DOM Scrapers**: Injected inline via `browser.scripting.executeScript()`.
15+
16+
## Parameter System
17+
18+
When adding new computed values, thresholds, or configurable numbers:
19+
1. **Types first**: Define types in `types/point.ts` (or appropriate file under `types/`). NEVER put `export type` in `constants/`.
20+
2. **Defaults in `constants/default.ts`**: Only `export const _DEFAULT_*` values. Import types from `@/types`.
21+
3. **School-wide params**`useGlobalStore` (sync storage, editable in Settings)
22+
4. **Per-user params**`UserSettingsType``useUserSettingsStore` (local storage, scoped to MSSV)
23+
5. **Compute logic**`utils/academic-compute.ts` (pure functions, no side effects). Re-export via `utils/score.ts` for backward compat.
24+
6. **Update SettingsPage** with editable inputs for new params.
25+
7. **Update `assets/docs/cach_tinh_toan.md`** with `{{VAR_NAME}}` placeholders.
26+
8. **Update AboutUsPage** `calcParams` to pass current values to the markdown renderer.
27+
28+
## Specific Coding Standards
29+
30+
### General Rules
31+
- Explain **WHY**, not **WHAT**. Avoid obvious/verbose comments.
32+
- No `// ======` section dividers. Use brief `// ── section ──` with Unicode box-drawing chars only in large files.
33+
- Minimal JSDoc: public API methods get one-liner `/** Brief. */`; private methods are self-documenting.
34+
- Empty catch blocks: use an inline `/* reason */` block comment, never leave a bare `{}`.
35+
- Use `Promise.all` for parallel independent async work.
36+
- Use `Map` for in-memory caches with simple key patterns like `${a}:${b}`.
37+
38+
### Project-Specific Rules
39+
- **Formatting & Linting**: Use **Biome** (avoid ESLint/Prettier).
40+
- **Path Aliasing**: Use `@/*` to map to the repository root.
41+
- **Constants**: Always check the `constants/` directory (e.g., `constants/default.ts`) to reuse existing values or define new ones centrally. Types go in `types/`, not in `constants/`.
42+
- **Storage keys**: Use the builder functions from `constants/storage.ts` (`getPointKey`, `getCalendarKey`, etc.) — never hardcode `local:{MSSV}:*` strings.
43+
- **Error Handling**: Follow project patterns, especially considering content-script-to-background messaging.

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,5 @@ jobs:
3434
env:
3535
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
3636
HUSKY: 0
37+
MPC_KEY: ${{ secrets.MPC_KEY }}
3738
run: pnpm dlx semantic-release

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ lerna-debug.log*
99

1010
node_modules
1111
.output
12+
.test
1213
stats.html
1314
stats-*.json
1415
.wxt
@@ -24,3 +25,5 @@ web-ext.config.ts
2425
*.njsproj
2526
*.sln
2627
*.sw?
28+
.env
29+
.venv

CLAUDE.md

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,40 @@ Message type constants are defined in [constants/chrome.ts](constants/chrome.ts)
4343

4444
### State Management
4545

46-
Three Zustand stores, each persisted to `chrome.storage.local`:
46+
Zustand stores with tiered persistence:
4747

48-
| Store | File | Manages |
49-
|-------|------|---------|
50-
| Global config | [store/use-global-store.ts](store/use-global-store.ts) | Active tab, site URL, ignored subjects, fixed points |
51-
| Grade data | [entrypoints/sidepanel/PointTab/use-score-store.ts](entrypoints/sidepanel/PointTab/use-score-store.ts) | Semester scores, GPA calculations |
52-
| Calendar data | [entrypoints/sidepanel/CalendarTab/use-calendar-store.ts](entrypoints/sidepanel/CalendarTab/use-calendar-store.ts) | Class schedules, exam events |
48+
| Store | File | Storage | Manages |
49+
|-------|------|---------|---------|
50+
| Global config | [store/use-global-store.ts](store/use-global-store.ts) | `sync:global` | Theme, fixedPoint, ignoreList, siteURLMapping, school-wide params (retakeRatioLimit, maxCreditsPerSemester, minCreditsPerSemester, maxCreditsWarning, maxCreditsSummer, drlWarningThreshold) |
51+
| Current user | [store/use-current-user-store.ts](store/use-current-user-store.ts) | `local:currentUser` + `local:{MSSV}:avatar` | studentId, displayName, avatar (avatar stored in separate key, not in JSON) |
52+
| User settings | [store/use-user-settings-store.ts](store/use-user-settings-store.ts) | `local:{MSSV}:userSettings` | trainingSemesters, totalProgramCredits (per-MSSV, switches with effectiveStudentId) |
53+
| Grade data | [store/use-score-store.ts](store/use-score-store.ts) | `local:{MSSV}:pointData` | Semester scores, GPA calculations |
54+
| Info data | [store/use-info-store.ts](store/use-info-store.ts) | `local:{MSSV}:userData` | Student profile, course data |
55+
| Calendar data | [store/use-calendar-store.ts](store/use-calendar-store.ts) | `local:{MSSV}:calendarData` / `local:{MSSV}:examData` | Class schedules, exam events |
56+
57+
**Key pattern**: All per-user data stores use `effectiveStudentId` from `useCurrentUserStore` — supports view-only account switching.
58+
59+
### Academic Compute Module
60+
61+
[utils/academic-compute.ts](utils/academic-compute.ts) — pure functions, no side effects:
62+
- `computeSummary(data, trainingSemesters)` — GPA + DRL summary
63+
- `getAcademicRank(gpa4)` / `getTrainingRank(point)` — Vietnamese rank labels
64+
- `computeSemesterGPA(sem)` / `computeCumulativeGPA(data, idx)` — per-semester/cumulative
65+
- `countRetakeCredits(data)` / `getRetakeRisk(...)` — retake F credits + degree downgrade risk
66+
- `getDrlWarnings(data, threshold)` — DRL below threshold consecutive semester warnings
67+
- `getMaxCreditsForStudent(gpa4, ...)` — credit limits based on academic standing
68+
69+
Re-exported via [utils/score.ts](utils/score.ts) for backward compatibility.
70+
71+
### Parameter System (when adding new configurable values)
72+
73+
1. Define type in `types/point.ts`
74+
2. Add default in `constants/default.ts`
75+
3. School-wide → `useGlobalStore` (sync, editable in Settings); Per-user → `UserSettingsType``useUserSettingsStore`
76+
4. Compute logic → `utils/academic-compute.ts`
77+
5. Update `SettingsPage/index.tsx` with input
78+
6. Update `assets/docs/cach_tinh_toan.md` with `{{VAR}}` placeholders
79+
7. Update `AboutUsPage` `calcParams` for markdown rendering
5380

5481
### Content Scripts (DOM Scrapers)
5582

@@ -76,5 +103,6 @@ Defined in [constants/default.ts](constants/default.ts) (`_DEFAULT_SITE_URL_MAPP
76103
- **Linter/Formatter**: Biome (not ESLint/Prettier) — config in [biome.jsonc](biome.jsonc)
77104
- **Commits**: Conventional Commits enforced by commitlint + husky (required for semantic-release versioning)
78105
- **Path alias**: `@/*` maps to the repo root
106+
- **Constants & Definitions**: When coding magic numbers, defining thresholds, or adding constant configuration functions, ALWAYS check the `constants/` directory (e.g., `constants/default.ts`) to reuse existing values or define them centrally.
79107
- **Grade conversion**: 10-point → 4-point scale logic is in [utils/index.ts](utils/index.ts)
80108
- **Release**: Automated via semantic-release on push to `main`; updates `package.json`, `wxt.config.ts`, `CHANGELOG.md`, and `assets/data/info.json`

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,18 @@ After downloading, follow these instructions to install manually:
3434
git clone https://github.com/mpc-ou/mpc-extension.git
3535
cd mpc-extension
3636

37+
# Set up the encryption key (used for local data encryption)
38+
cp .env.example .env
39+
# Edit .env to set your own MPC_KEY, or keep the default for local dev
40+
3741
pnpm install
3842

3943
pnpm build
4044
pnpm build:firefox # For Firefox
4145
```
4246

47+
The `MPC_KEY` environment variable is injected at build time and used to encrypt locally stored data. The default value `"MPC"` is fine for local development. In CI/CD, this key is set via GitHub Secrets.
48+
4349
After building, the **.output** folder will be created. Inside, there are folders corresponding to each browser. Use these folders to install manually as described above.
4450

4551
## Core Technologies

README.vi.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,18 @@ Sau khi tải về, làm theo hướng dẫn sau để cài đặt thủ công:
3535
git clone https://github.com/mpc-ou/mpc-extension.git
3636
cd mpc-extension
3737

38+
# Thiết lập khóa mã hóa (dùng để mã hóa dữ liệu local)
39+
cp .env.example .env
40+
# Sửa .env để đặt MPC_KEY riêng, hoặc giữ mặc định cho dev
41+
3842
pnpm install
3943

4044
pnpm build
4145
pnpm build:firefox # Dành cho Firefox
4246
```
4347

48+
Biến môi trường `MPC_KEY` được inject lúc build và dùng để mã hóa dữ liệu lưu cục bộ. Giá trị mặc định `"MPC"` dùng tốt cho môi trường phát triển. Trên CI/CD, khóa này được đặt qua GitHub Secrets.
49+
4450
Sau khi build, folder **.output** sẽ được tạo ra. Bên trong có các folder tương ứng cho từng trình duyệt. Sử dụng folder này để cài đặt thủ công như hướng dẫn ở trên.
4551

4652
## Công nghệ chính của mã nguồn

assets/data/info.json

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
{
22
"credits": {
3-
"team": "MPC Team",
4-
"contributors": [
5-
"konnn04",
6-
"holedev",
7-
"antiennn",
8-
"quythanh"
9-
]
3+
"team": "MPC Club",
4+
"contributors": ["konnn04", "holedev", "antiennn", "quythanh"]
105
}
116
}

0 commit comments

Comments
 (0)