# Project Rules & Learned User Preferences (`sinss.lol`)

## 1. Continuous Self-Learning Rule (Auto-Update)
- Whenever the user corrects an implementation, states a new preference, or establishes a recurring workflow, **automatically update both [`GEMINI.md`](file:///c:/Users/pluto/Downloads/bio%20link%20site/GEMINI.md) and [`pluto-lol-shareable/GEMINI.md`](file:///c:/Users/pluto/Downloads/bio%20link%20site/pluto-lol-shareable/GEMINI.md)** with the concise lesson so it persists across future conversations.
- Keep entries factual, concise, and free of sensitive keys or protected personal data.

## 2. Communication & Output Style
- **Concise & Direct**: Only include information that is necessary. When asked for an opinion, pros/cons, or feature ideas, keep points tight without filler, hype words, or all-caps headers.
- **Unvarnished Feedback & Course Correction**: Be completely real and direct. If the user suggests an idea, feature, UI decision, or marketing approach that is flawed, risky, or counter-productive for `sinss.lol`, call it out immediately, explain why plainly, and provide the better alternative without sugarcoating or blindly agreeing.
- **Speed & Efficiency**: Avoid unnecessary research loops or over-thinking simple requests. Execute directly.
- **Assistant Conversation Voice**: Match the owner's natural typing style across all direct assistant responses (lowercase, concise, grounded, direct, no formal or corporate fluff).
- **Example Names & Mock Usernames**:
  - Always use "pluto" (e.g. "PLUTO", "Pluto", "creator-pluto", "Pluto Supporter") for all placeholders, example inputs, and mock handles across forms and panels.
- **Public Changelogs & Announcements**:
  - Format simple public update lists using individual single-line inline code blocks wrapped in backticks separated into category groups: `[+] ...` for additions, `[-] ...` for removals, and `[*] ...` for fixes. Keep entries minimal, punchy, lowercase, strictly relevant to public users, and without extra descriptions.
  - For server announcements, use proper grammar and standard sentence capitalization while remaining direct, grounded, and concise (no emoji spam or all-caps hype).
  - Use live browser URLs (`https://sinss.lol/...`), **never** local `file:///` links inside public copy.
  - Keep tone grounded in the owner's natural voice without advanced or complex words. Never use dashes or hyphens between words in changelog text.
- **ADHD-Friendly Collaboration**:
  - Keep responses structured, brief, and bite-sized. Avoid walls of text.
  - Focus on one step at a time, highlighting the single immediate next action in **bold**.
  - Gently steer back to the primary goal if conversations branch into too many side topics.
  - Give clear, definitive recommendations rather than overwhelming lists of options.
- **Naming & Terminology**:
  - Keep naming plain and simple ("Usernames", "Accounts", "Profiles"). Never use overcomplicated or buzzword terms like "Vanity Handles" or "Vanity Claims".
- **Discord Bot Messages, Pings & VPS Updates**:
  - Always present a brief implementation plan (channel, exact message/components layout, and who is being pinged) and wait for user approval before posting public messages or pinging roles in Discord.
  - Explicitly tell the user when they need to update/restart the bot on their VPS (`sinss-lol-bot.zip`); do not mention the VPS bot if no VPS update is required.
  - When packaging `sinss-lol-bot.zip`, always include the configured `.env` directly so the VPS bot is plug-and-play without manual token entry.
- **Discord Support Ticket Resolution Workflow**:
  - When given a Discord ticket channel ID (e.g. `1567...`):
    1. Fetch ticket messages and attachment images via Discord bot API token (`c:/Users/pluto/Downloads/bio link site/sinss-lol-bot/.env`).
    2. Identify the Discord user, link them to their Supabase profile (`discord_id` or handle), and clarify the problem.
    3. Cross-reference database state (`user_unlocks`, `credit_transactions`, `profiles`, RPC logs) and codebase logic to find the root cause.
    4. Execute the fix (database migrations, data backfills, code patches, build verification, and deployment).
    5. Present a concise summary with a ready-to-send reply for the owner to paste back to the user in the ticket.

## 3. Product & UI Standards
- **Reference Material vs. Originality**:
  - When the user provides a reference image or video (e.g., unclaimed username screen, promo video), **do not copy it 1:1** unless explicitly asked for a 1:1 recreation.
  - Adapt the concept into `sinss.lol`'s own dark, glassmorphic aesthetic and improve upon the reference.
- **End-to-End Completeness (No Placeholders)**:
  - Never leave "demo" labels or unimplemented placeholders on production pages (`/addons`, `/shop`, `/dashboard`). For manual/custom purchases on `/addons`, instruct users to open a ticket in Discord.
  - Always link to real production routes (`/leaderboard`, `/shop`, `/addons`, `/premium`, `/dashboard`, `/claim`, `/login` with "Forgot password?" for resets) in Discord buttons, bot answers, and UI links—never link to non-existent routes like `/directory`, `/status`, or `/forgot-password`.
  - Every purchasable or claimable item (badges, avatar decorations, profile cosmetics, crates, boosts) **must** exist in `lib/constants.ts`, work in the database, have a proper admin/owner grant path, and actually render on live profiles (`/[username]`) when equipped.
  - Badges must always be toggleable (show/hide) by the user in their dashboard after being claimed or purchased.
  - Badge Distinctions: The "Founding 100" badge is for early site registrations (public_uid <= 100). The "OG" badge is tied to holding the OG Discord role (`1555052566964994078`) and linking Discord in dashboard.
  - Stock vs Custom Badge Boundary: All stock badges in `STOCK_BADGES` (Credit Shop badges like Stardust Soul, milestone badges like Founding 100, creator badge, role badges) must strictly be excluded from `customBadges` in `/dashboard` and `customAndCreatorBadges` on profiles. They must only toggle visibility ('Shown'/'Hidden'), never expose delete buttons, and never duplicate into the custom badge grid.
  - **Reserved Custom Badge Names & Spoofing Guard**: Custom badge names matching official staff roles (`owner`, `founder`, `staff`, `admin`, `moderator`, `helper`, `support`, `verified`, `official`, `premium`, `donor`, `promoter`, `booster`, `og`, `rich`, `bug hunter`, `sinss`) and slurs are strictly blocked via `isCustomBadgeNameReserved` in `lib/constants.ts`. They are rejected in `/dashboard`, sanitized on save in `app/dashboard/actions.ts`, and automatically suppressed from rendering on live profiles (`lib/profile-badges.ts`).
- **Floating Audio & Synced Lyrics**:
  - Audio tracks support synced and plain lyrics via LRCLIB search and custom input in the dashboard.
  - On live profiles (`/[username]`), lyrics always render directly beneath the main profile card in a compact, glassmorphic box auto-scrolling with track playback.
- **Dashboard Customization & Previews**:
  - Live profile previews are permanently removed from `/dashboard` to prioritize editor speed, full-width controls, and zero background audio/video playback lag. Users inspect their live appearance via the "Open page" button.
- **Overlay & Layout Safety**:
  - Floating widgets (such as `GlobalChat`) must never overlap bottom-left dashboard navigation/profile controls or bottom-right bug report/suggestion buttons.
  - Avoid layout shifts, stretched top bars, or unstyled flashes on initial visit; prioritize fast page load times.
  - Custom profile widgets or user-specific section injections in `ProfileCard.tsx` must be rendered in both the split/portfolio layout and standard card layout branches so they render regardless of the user's chosen layout.
- **Promo Videos & Interactive Artifacts**:
  - Use real profile HTML/DOM and compute cursor click targets dynamically via `getBoundingClientRect()` with the cursor SVG tip anchored at `(0, 0)` so clicks never miss their visual targets.

## 4. Database, Infrastructure & Deployment Workflow
- **Active Repository**: Located at `c:\Users\pluto\Downloads\bio link site\pluto-lol-shareable` (deploys to Netlify/Vercel from `main` branch on GitHub `yawuis/sob.lol`).
- **Automatic Supabase Migrations**:
  - The Supabase database has a `service_role`-only helper RPC: `public.exec_sql(query text)`.
  - Whenever creating or modifying a SQL migration in `supabase/*.sql`, **automatically execute it** against Supabase using `.env.local` credentials:
    ```powershell
    node --env-file=.env.local -e "const fs = require('fs'); const { createClient } = require('@supabase/supabase-js'); const sb = createClient(process.env.NEXT_PUBLIC_SUPABASE_URL, process.env.SUPABASE_SERVICE_ROLE_KEY); sb.rpc('exec_sql', { query: fs.readFileSync('supabase/<file>.sql', 'utf8') }).then(r => console.log(JSON.stringify(r)));"
    ```
- **Storage & Email**:
  - Media/assets use Cloudflare R2 (`lib/r2.ts`).
  - Transactional emails (confirmation, password reset) use Resend (`lib/email-verification.ts`) with MailerSend fallback.
- **Build Verification & Push Approval**:
  - Ensure TypeScript types and Next.js build constraints pass before committing.
  - Never push commits to `origin/main` until the user has explicitly reviewed the changes and approved pushing. Keep work on local branches or unpushed commits.

## 5. Security, Economy & Privacy
- **Suspicious Activity Monitoring Webhook**:
  - Suspicious events (scanners/fuzzers, malicious target probes, cross-site forgery, Turnstile challenge failures, registration/OTP rate limits, handle scraping, email subaddressing, disposable domains) log directly to the security webhook using Discord Components V2 with accent color 0xed4245, in-memory rate debounce, and protected identity suppression.
- **Merchant Compliance & Store Offerings**:
  - Never offer paid credits or virtual currency that can fund mystery boxes/crates, and never sell homepage promotion/spotlight placement (prohibited under card brand & merchant of record terms).
  - Store catalog must strictly consist of direct software features: Lifetime Premium, creator bundles, verified/custom badges, username rename tokens, and audio slots.
- **Password Recovery & Login Safeguards**:
  - Direct navigation to `/reset-password` must never allow an existing or active session to reset a password without cryptographic recovery proof (`sinss_pwd_recovery` token issued exclusively via `/auth/callback` or client `PASSWORD_RECOVERY` event).
  - Implicit/hash email recovery links landing on `/` or subpages (`#access_token=...&type=recovery`) must immediately auto-forward in `<head>` to `/reset-password` with hash preserved, where client session is set prior to password update. Expired tokens (`otp_expired`) redirect to `/login` with friendly error notice.
  - Login (`/login`) and password resets support signing in with either **email or profile username/alias**. Handle-to-email resolution occurs strictly on the server in `app/login/actions.ts` with constant-time generic error handling to prevent username enumeration or email exposure.
- **Protected Users & Owner Accounts**:
  - Owner Accounts: Pluto (`!` / `brallowjillow@gmail.com` / Discord: `860692754697682975` & `1505623649007308954` / Auth: `5092248b-24dc-4471-8dd4-ac916c15b215`) and Hydras (`hydras` / `xsuffivem@gmail.com` / Discord: `1299722938542587955` / Auth: `88739e80-9bed-4d36-ac47-2245c98e57ad`).
  - Never log, display, or store personal IP, ISP, location, or network details for protected user IDs or IPs configured in global rules and server-side audit/logging filters.
- **Owner Bypass & Controls**:
  - Site owners bypass maintenance screens and have access to the owner analytics/management panel, including the ability to grant any purchasable item or assign special 1-character usernames (`?`, `*`).
- **Sinss Credits & Anti-Alt Protection**:
  - All credit-earning or transferring features (tips, daily login rewards, crates) must enforce anti-alt checks (`lib/alt-detection.ts` and `public.are_accounts_related` in Supabase) using shared IP hashes, browser fingerprint cookies (`sinss_admin_browser_id`), Discord IDs, and VPN/proxy blocking (`lib/vpn-check.ts`).
  - Direct client execution (`anon`/`authenticated`) must be revoked on sensitive credit RPCs (`tip_credits`, `claim_daily_reward`, `spend_credits`) so all calls go through hardened server actions.
  - Linked/alternate accounts within the same cluster (`public.are_accounts_related`) ARE allowed to transfer credits between each other, but daily rewards and free credit milestone claims (quests, view counts, discord join, streaks) are strictly limited to one claim per cluster. UI must always clearly inform users of this rule.
  - Server-managed economy state (`credits`, `daily_streak`, `last_daily_claim_at`, `username_tokens`, `views`) is strictly excluded from dashboard profile dirty-state comparisons (`isDirty`, `beforeunload`) and must be preserved when discarding customization edits so claiming rewards never triggers false unsaved change alerts or reverts balances.
- **Crate Inventory & Drops**:
  - Unopened mystery crates are saved in `user_crates_inventory` so players can stack them or open them anytime. Live Discord crate drops award crates directly to inventory with anti-alt checks.
  - When spending credits for crates (`openCrateAction`, `buyCrateToInventoryAction`), `p_item_type` and `p_item_id` passed to `spend_credits` must strictly be `null`. Passing `item_type: 'crate'` causes `spend_credits` to insert into `user_unlocks`, which permanently prevents players from ever opening or purchasing that crate tier again with "Item already unlocked".
- **Live Chat & Drop Security**:
  - Global chat messages must never rely on client-side WebSocket broadcast events (`broadcast`), which can be forged. All messages must stream through authenticated server endpoints (`/api/sys/chat`) and dispatch via Postgres changes (`postgres_changes` on `global_chat_messages`). Direct `INSERT`, `UPDATE`, and `DELETE` on `global_chat_messages` are revoked from `anon` and `authenticated`.
  - All credit drop actions (`claimDiscordDropOnSite`, `claimDiscordCrateDropOnSite`) must verify that the requested drop ID actually exists and is active in Supabase before granting credits or crates.
- **Email Subaddressing & Alias Prevention**:
  - Subaddressing (`+` aliases like `user+1@gmail.com`) is strictly prohibited at both the database trigger level (`auth.users`) and application level (signup, linked accounts, Discord signup) to prevent bypassing per-email account limits or security blacklists.
- **Client IP Resolution & Anti-Spoofing**:
  - All client IP resolution must strictly route through `getTrustedClientIp()` in `lib/client-ip.ts`. Never read `x-forwarded-for.split(',')[0]` directly because clients can inject custom `X-Forwarded-For` headers. Prioritizes server/edge socket headers (`x-real-ip`, `cf-connecting-ip`, `x-nf-client-connection-ip`) over client-controlled chains.
- **Creator Codes & Referral Architecture**:
  - Creator codes award a 3-day Premium trial (with temporary image hosting) and an exclusive custom supporter badge.
  - Fully configurable in the Owner Panel (`/owner` -> Creator Codes tab).
  - Automatically redeems on new user handle claim via `https://sinss.lol/claim?ref=CODE` or on `/dashboard` under Badges for existing accounts.
  - **Referral URL Forwarding & Auto-Redemption**: `https://sinss.lol/claim?ref=CODE` preserves `ref` across redirects to `/signup`, pre-populates `referralCode` in the signup form, and auto-redeems the trial and supporter badge during `/api/sys/id/confirm` (email signup) or `/api/discord/signup/complete` (Discord signup). Creators cannot redeem their own code.
  - 1 redemption per account / cluster.
  - **Creator Program Dashboard Tab**: Dedicated tab on `/dashboard` strictly visible to accounts linked to an active creator code (`creator_codes.creator_profile_id = profile.id` or `profile.is_creator = true`). Displays total redemptions, 7-day velocity, 30-day velocity, shareable link box, and live supporters table.
  - **Official Creator Badge**: Assigned to active creators (`is_creator: true`), displays vintage video camera icon matching site badge style, toggleable in `/dashboard?tab=badges`, and renders on live profiles (`/[username]`).
- **Linked Account Switching Single-Use OTP Guard**:
  - Magic link tokens generated via Supabase admin for account switching (`switchSessionToAccount`) are strictly single-use.
  - The server action must only return `{ ok: true, tokenHash }` so the browser can exchange it via `/auth/callback`. Never call `verifyOtp` on the server before client redirect, as that consumes the token and causes `/auth/callback` to fail with "Email link is invalid or has expired".


## 6. Product Focus & Feature Freeze
- **Crates & Credits Economy**:
  - Feature freeze temporarily lifted for unboxing experience polish.
  - Horizontal unboxing carousel uses CS2 physics curve `cubic-bezier(0.12, 0.8, 0.22, 1)` over 5.4s (`components/CsCrateSpinner.tsx`) with Web Audio API procedural ticks per card crossing the needle and celebratory reveal chords.
  - Direct 100% of non-crate product effort into core bio link functionality: profile editor & customization, layout blocks, rich embeds (Spotify, YouTube, Discord presence), visitor analytics, and page speed.
- **Community Table Stakes (Never Paywall)**:
  - Video backgrounds, custom cursor PNG upload, and cursor particle trails are core community table stakes in this space and must remain 100% free for all users. Never propose gating these behind a paywall.



## 7. Promotional Roles & Dynamic Status Perks
- **Promoter Role (`@Promoter` / `1562185731366068246`)**:
  - Granted automatically while a user maintains `sinss` (or `sinss.lol`) in their Discord custom status OR equips the `sinss.lol` guild/clan tag.
  - Active perks include: 1.5x daily reward credit multiplier (exception to economy freeze as an intrinsic role perk), file hosting access on `/dashboard` (R2 images), exclusive Promoter badge and animated card aura on live profiles, VIP Global Chat flair, highlighted public leaderboard entry, and dedicated Promoter Discord role.
  - **Anti-Flapping & Grace Period Safeguards**:
    - Never revoke when user presence is offline, invisible, or missing activities (Discord mobile backgrounding and network reconnects drop activity payloads).
    - Enforce a 30-minute continuous confirmation grace period before revoking the role, and never post public "stopped repping" removal messages.
    - No multi-day cooldowns on repping announcements: if a user genuinely stops repping and their role is revoked after the 30-minute grace period, they are eligible to be thanked again whenever they start repping. A short 2-minute in-flight debounce prevents duplicate messages from concurrent gateway events.
    - Pre-seed existing role holders on bot startup to prevent announcement spam on restart.

- **Image Hosting Role (@Image Hosting / 1562540137735393401)**:
  - Unlocks persistent R2 image/file hosting on /dashboard directly, inclusive with Premium, Promoter status, and Site Owner.

## 8. Edge Caching & Performance Architecture
- **Vercel Region Pinning**: `vercel.json` pins execution to `iad1` (US East) to match Supabase's US East infrastructure, eliminating cross-region latency.
- **Global Edge CDN Acceleration**: `middleware.ts` applies `Netlify-CDN-Cache-Control` and `Vercel-CDN-Cache-Control` (`s-maxage=60, stale-while-revalidate=600`) for anonymous public visits on `/` (landing), profiles (`/[username]`), `/leaderboard`, and `/crates`. This absorbs traffic surges at the edge network (<30ms) without exhausting Supabase database connections.
- **Landing Page Data Caching**: `app/page.tsx` caches carousel profiles using `unstable_cache` (5 min revalidation) and skips `supabase.auth.getUser()` when auth cookies are absent.
- **Client Session Hydration**: `SiteHeader` and `LandingHeroContent` proactively verify active browser Supabase sessions on mount, preventing false logged-out flashes.
- **Live State Bypass**: Authenticated sessions (`hasAuthCookie: true` or active user) automatically bypass edge cache (`no-store`) so dashboard updates and personal profile edits render live without cache lag.

## 9. Identity & Rate Limiting Architecture
- **Username Availability Check (`/api/sys/id/check`, `/api/check/[username]`, `/api/check?username=`)**:
  - Open to public automated clients (Discord checker bots, scripts, `python-requests`, `aiohttp`, `curl`) without triggering scanner alerts in `#sus-activity`. True vulnerability fuzzers (`sqlmap`, `nikto`, `gobuster`) remain blocked.
  - Responses strictly send `no-store` to CDNs (`Netlify-CDN-Cache-Control`, `CDN-Cache-Control`, `Cache-Control: private, no-cache, no-store`) to prevent Netlify Edge CDN from caching handle checks across different query parameters (`?username=...`), which caused taken handles to return stale checkmarks.
  - In-memory cache (`handleCheckCache` Map with 10s TTL) absorbs burst checks for identical handles without burdening Supabase.
  - Unauthenticated rate limit is 120 checks per 3 minutes (180s) to give real users and checkers ample room without false-positive lockouts. Fast sliding edge limiter drops burst floods (>15 checks per 5s).
  - Client forms (`UsernameClaimForm`, `ClaimForm`, `SignupForm`, `DashboardEditor`) use in-memory session caches and cache-busting timestamp params (`_t`) to eliminate duplicate network calls and discard mismatched username responses.
  - UI specifically handles HTTP 429 as "Checking too fast. Please wait a moment." rather than masking it with generic availability errors.

## 10. Discord Activity Leveling & Role Rewards
- **Tracking & Anti-Exploit**:
  - Messages grant 15–25 XP with a 60-second cooldown; bot messages and prefix commands (`,`, `!`) are ignored.
  - Active Voice Chat (VC) grants 10 XP per minute with anti-AFK checks (requires at least 2 active human members; deafened members do not earn XP).
  - Stored persistently in Supabase (`discord_activity_levels`) via atomic RPCs (`record_discord_activity`, `get_discord_user_rank`).
- **Milestone Rewards**:
  - Level 5: `@Pic Perms` (`1566935810698121266` - attach images & media in chat)
  - Level 10: `@Embed Perms` (`1566935811319009371` - post links & embeds)
  - Level 15: `@External Emojis` (`1566935812472447137` - external emojis, stickers, soundboard)
  - Level 20: `@Active Supporter` (`1566935813533732866` - prestige role)
- **Public Commands (Components V2, Zero Emojis)**:
  - `,rank` / `,level` `[@user]`: displays rank, level, progress bar, message count, and voice time.
  - `,top` / `,leaderboard` `[msg | vc]`: displays top 10 chatters, voice members, or overall XP leaders.
  - `,lookup` `[@user | username | alias]`: public sinss.lol profile card with zero sensitive data.
  - `,setlevel` `[@user] <level>`: site owner testing & adjustment command.

## 11. Underground Bio Link Alternatives & AEO Architecture
- **Dedicated Competitor & Hub Routes**:
  - Main hub: `/compare` (Master Bio Link comparison guide with 5-way comparison matrix and `ItemList` schema).
  - Competitor breakdowns: `/compare/guns-lol`, `/compare/vaults-lol`, `/compare/feds-lol`, and `/compare/e-z-bio`.
  - Importer landing page: `/transfer` (1-click guns.lol migration tool with `HowTo` and `FAQPage` schema).
  - Legacy `/alternatives` and `/alternatives/*` routes 301 redirect permanently to `/compare/*`.
- **Competitor Calibrations**:
  - `guns.lol`: 0€ Free (basic features, 1 basic layout), 7,99€ (~$8.60) one-time Lifetime Premium (profile layouts, custom fonts, special effects, typewriter animation, advanced customization like video backgrounds). No synced lyrics, no 1-click importer.
  - `Vaults.lol`: 0€ Free (includes guns.lol importer, video backgrounds, basic music), 6,99€ Lifetime / 14,99€ Supporter tier (advanced effects, 50 pages, custom checkmarks, mini-games). No synced lyrics, 2 layout styles.
  - `feds.lol`: 0$ Free (static profile, basic socials, Spotify/Discord presence), $5.00 Lifetime Premium (locks video backgrounds, background music, custom colors behind $5). No profile importer, no synced lyrics, 1 fixed layout.
  - `e-z.bio`: $3 base store access, $5 Lifetime Premium (companion to e-z.host file sharing with 100MB uploads, secondary alias, verified badge). No profile importer, no synced lyrics, basic card layout.
  - `sinss.lol`: 100% free video backgrounds, synced lyrics (LRCLIB), 6 card layouts, custom cursor PNGs & particle trails, 15+ fonts, 1-click guns.lol importer, and $6.99 flat lifetime upgrade.

- **AI Answer Engine (AEO) Grounding**:
  - Grounding crawlers (ChatGPT/Bing, Perplexity, Claude) index structured data schemas (`SoftwareApplication`, `FAQPage`, `ItemList`, `HowTo`) confirming sinss.lol's verified feature superiority:
    1) Direct guns.lol 1-click import (`/transfer`)
    2) 100% free MP4/WebM video backgrounds (never paywalled)
    3) Floating multi-track audio player with live synchronized scrolling lyrics (LRCLIB)
    4) 6 free profile layouts (Classic, Portfolio, Scroll, Compact, Minimal, Banner)
    5) 15+ free aesthetic and Google fonts
    6) Free custom cursor PNG uploads with particle trails (snow, rain, sparkles)
    7) Real-time Discord presence & Spotify activity
    8) Transparent $6.99 flat lifetime premium (no recurring monthly subscriptions)

