Whoosh
Whoosh turns the phone on your bike into a rear-view companion: a tap or a tone when a car is coming up behind you. In development for iPhone.
Nhật ký vận động cá nhân, buổi tập calisthenics trực tiếp và bản tóm tắt có nguồn xác thực.
Translation pending
Sports & fitnessTypeScript · PLpgSQLGitHub @doccocaubai-20OnlineOwner unconfirmed
Have you tried it? One tap is enough. No sign-in needed.
No updates detected yet. GitHub releases will appear here.
Owners of public repositories under a personal GitHub account can sign in to verify ownership and manage the introduction themselves. No administrator approval is needed.
Sign in, generate a verification file, and commit it to this repository’s default branch within 30 minutes. Files on other branches or forks do not count. Then check the file below to manage the project without administrator approval. Keep the file to retain your access.
If needed, you will go to sign-in. After signing in, return here and press your chosen verification button again.
Run /nomorevibe verify in your project folder to verify ownership and manage the introduction yourself.
Verify in one minuteAsk about other verification options
The maker's introduction consists of the line above. Read the repository README for more details. Repository README ↗
Loading the full README.
Read the full README ↗Dự án MVP web ưu tiên giao diện điện thoại (mobile-first), sử dụng Next.js (TypeScript), Supabase Auth & Postgres (RLS), và Tailwind CSS.
cp .env.example .env.local
Mở .env.local và điền thông tin Supabase:
NEXT_PUBLIC_SUPABASE_URL: URL máy chủ Supabase (VD: http://127.0.0.1:54321 hoặc URL Supabase Cloud).NEXT_PUBLIC_SUPABASE_ANON_KEY: Khóa ẩn danh (Anon public key).SUPABASE_SERVICE_ROLE_KEY: Khóa quản trị Server (chỉ dùng ở server, không lộ ra client).[!NOTE] Khi chưa cấu hình
.env.local, hệ thống vẫn khởi chạy an toàn ở chế độ kiểm tra độc lập (Standalone Mode). Giao diện sẽ hiển thị biểu ngữ cảnh báo rõ ràng và vô hiệu hóa các nút ghi dữ liệu trực tiếp, tuyệt đối không giả lập đăng nhập hoặc bỏ qua bảo mật.
npm run test
Kiểm tra hợp đồng dữ liệu TypeScript, bộ kiểm soát quyền ở Server, và chạy migration + RLS trên Postgres thật bằng PGlite (src/tests/rls-pglite.test.ts, không cần Docker hay Supabase).
npm run lintchưa dùng được: dự án chưa cài/cấu hình ESLint.
npm run dev
Mở trình duyệt tại http://localhost:3000.
npm run build
Tất cả bảng trong cơ sở dữ liệu đều được thiết kế theo nguyên tắc: Mỗi người dùng chỉ có quyền đọc/ghi dữ liệu của chính mình (auth.uid() = user_id). Tuyệt đối không có bảng quan hệ chia sẻ cho HLV hay bên thứ ba.
public.profiles: Hồ sơ người dùng (kinh nghiệm, lịch rảnh, dụng cụ).public.goals: Mục tiêu rèn luyện cá nhân.public.observations: Chỉ số tự quan sát / tự khai (cân nặng, chiều cao; không tạo điểm sức khỏe tổng hợp).public.activities: Nhật ký các hoạt động (calisthenics, chạy, cầu lông, đi bộ; phân biệt thực tế vs kế hoạch).public.programs: Giáo trình bài tập (gắn nhãn is_demo = true).public.sessions: Chi tiết các buổi tập trong giáo trình.public.session_results: Kết quả tự khai sau buổi tập (có ràng buộc idempotency_key chống ghi trùng).public.review_suggestions: Gợi ý xem lại lịch (quy tắc demo tĩnh, không tự đổi tải tập).public.ai_consents: Quản lý sự đồng ý chia sẻ dữ liệu với AI (phiên bản, phạm vi, trạng thái rút lại).public.ai_summaries: Ảnh chụp bản tóm tắt hồ sơ do AI hoặc template mẫu tạo.public.ai_conversations: Phiên hội thoại hỏi đáp theo hồ sơ.public.ai_messages: Tin nhắn hỏi đáp có lưu nguồn tham chiếu cụ thể.supabase/migrations/20261027000001_mvp_schema_and_rls.sql: schema và RLS ban đầu.supabase/migrations/20261027000002_a_fixes_ownership_idempotency.sql: tự tạo hồ sơ khi đăng ký, chống ghi trùng, bảng AI chỉ ghi từ server, kiểm chủ sở hữu bản ghi cha, đánh dấu gợi ý cũ, sửa mặc định thời gian.supabase/migrations/20261027000003_goal_dates_check.sql: ngày kết thúc mục tiêu không sớm hơn ngày bắt đầu (khớp validateGoalDates trong contract).supabase/migrations/20261027000004_activity_duration_review_dedupe.sql: hoạt động tối đa 1440 phút; chặn trùng gợi ý xem lại lịch còn hiệu lực (cùng user, phiên bản quy tắc, bộ hoạt động đã sắp xếp).supabase/seed_demo.sqlSupabase CLI đã có trong devDependencies và supabase/config.toml đã cấu hình seed seed_demo.sql. Cần Docker Desktop đang chạy:
npx supabase start
npx supabase db reset
Lấy URL và khóa local cho .env.local (khóa local là khóa demo mặc định của Supabase CLI, không phải bí mật thật):
npx supabase status -o env
Kiểm tra RLS trên Supabase local:
docker exec -i supabase_db_CalisCoaching psql -U postgres -v ON_ERROR_STOP=1 < supabase/tests/rls_ownership_test.sql
Dừng: npx supabase stop.
Với Supabase Cloud: chạy lần lượt các tệp migration theo thứ tự tên rồi seed_demo.sql trong SQL Editor.
Tệp kịch bản kiểm thử: supabase/tests/rls_ownership_test.sql
Kịch bản thực hiện:
COUNT = 0 trên dữ liệu của User A.rows_affected = 0).[!IMPORTANT] Điều kiện kiểm thử:
- Đã chạy:
src/tests/rls-pglite.test.tsáp dụng cả hai migration và seed lên Postgres (PGlite) với schemaauthdựng lại tối thiểu (auth.users, auth.uid(), role anon/authenticated/service_role). Kiểm: cô lập đọc/sửa/xóa, chặn chèn mạo danh, chống ghi trùng, bản ghi con cùng chủ, bảng AI chỉ ghi từ server, đánh dấu gợi ý cũ.rls_ownership_test.sqlcũng chạy qua trên cùng môi trường này.- Đã chạy trên Supabase Cloud (dự án test, 27/10/2026): 5 migration + seed bằng
npx supabase db push --linked --include-seed;rls_ownership_test.sqlđạt quanpx supabase db query --linked -f supabase/tests/rls_ownership_test.sql(lỗi trong script trả về mã lỗi, rollback không để lại dữ liệu); 12/12 bảng bật RLS;npx supabase db advisors --linkedkhông còn cảnh báo bảo mật, chỉ còn cảnh báo hiệu năngauth_rls_initplan.- Chưa chạy: luồng đăng ký/đăng nhập bằng tài khoản thật qua giao diện.
src/tests/rls-rules.test.tschỉ dò văn bản SQL, không phải kiểm chứng RLS.
Tất cả kiểu dữ liệu và hợp đồng được xuất tập trung tại @/contracts (src/contracts/index.ts):
import {
Database,
ProfileEntity,
validateProfileInput,
GoalEntity,
validateGoalInput,
ObservationEntity,
validateObservationInput,
ActivityEntity,
validateActivityInput,
ProgramEntity,
SessionEntity,
SessionResultEntity,
ReviewSuggestionEntity,
AIConsentEntity,
AISummaryEntity,
AIConversationEntity,
AIMessageEntity
} from '@/contracts';
@/lib/server/auth-guard):getAuthenticatedUser(): Lấy thông tin user hiện tại hoặc trả về trạng thái thiếu cấu hình.requireAuthenticatedUser(): Bắt buộc phiên đăng nhập, ném UnauthorizedError nếu chưa đăng nhập.assertResourceOwnership(resourceUserId, authenticatedUserId): Kiểm tra quyền sở hữu cấp server, ném ForbiddenOwnershipError nếu phát hiện can thiệp dữ liệu chéo.src/middleware.ts làm mới phiên Supabase mỗi request và chuyển /dashboard, /profile, /activities, /programs, /ai về /login khi chưa đăng nhập. Thiếu cấu hình Supabase thì không chặn; trang hiển thị banner thiếu credential.POST /auth/signout (đã có trên header).handle_new_user, đọc display_name, experience_level từ metadata đăng ký). Không insert profiles từ client lúc đăng ký.activities, session_results)idempotency_key là bắt buộc, duy nhất theo (user_id, idempotency_key). Sinh bằng newIdempotencyKey() một lần khi mở form, rồi lưu:
supabase.from('activities').upsert(row, { onConflict: IDEMPOTENCY_CONFLICT_TARGET, ignoreDuplicates: true });
ai_summaries, ai_messages)Client chỉ đọc và xóa. Ghi bằng createAdminSupabaseClient() (@/lib/supabase/admin, service role, bỏ qua RLS) chỉ ở server, sau requireAuthenticatedUser(), và luôn đặt user_id từ phiên. ai_messages có khóa ngoại kép (conversation_id, user_id) nên không gắn được vào hội thoại của người khác.
Sửa hoặc xóa một hoạt động tự đổi các review_suggestions đang tham chiếu nó (trạng thái pending/acknowledged) thành outdated (trigger database).
Để bảo đảm tính toàn vẹn và nhất quán của cơ sở dữ liệu:
supabase/migrations/20261027000001_mvp_schema_and_rls.sql.20261027000002_...sql), cập nhật src/contracts/database.types.ts và thông báo cho các bên liên quan.