Commit Graph

42 Commits

Author SHA1 Message Date
hobokenchicken 86a8c7d89a feat(economy): tighten credit earning + deduct on request
Credit economy changes:
- creditsPerMinute: 10 -> 2 (45min episode = 90 COOP vs 450)
- movieRequestCost: 100 -> 500 (~5.5 episodes per movie)
- tvRequestCost: 200 -> 1000 (~11 episodes per season)
- tvPerSeasonCost: 50 -> 250

Race condition fix:
- Credits now deducted immediately at request time
- No more multiple requests before approval
- On DECLINED: automatic refund with ADJUSTMENT transaction
- On APPROVED: no extra deduction (already paid)

Updated schema defaults and all code fallbacks.
2026-04-21 15:50:18 -04:00
hobokenchicken fee4d8ce1b fix(balance): use database credits instead of on-chain balance
Balance checks were reading on-chain Solana token balance (0
during db-only mode). Now wallet and overseer routes return
user.totalEarned - user.totalSpent as the usable credit balance.
This makes credits spendable even when devnet faucet is dry.

- /wallet returns dbBalance, with onChainBalance as extra info
- /overseer/balance returns dbBalance for request eligibility
- /overseer/request checks dbBalance before approving spend
- /wallet/admin returns dbBalance
2026-04-21 15:37:06 -04:00
hobokenchicken 5dbee115ad chore(solana): silence devnet airdrop retry spam
Catch and swallow airdrop errors quietly. Logs were flooded with
429 retry messages. Now fails fast and lets DB-only credits take
over when devnet faucet is dry.
2026-04-21 15:31:19 -04:00
hobokenchicken 31d89f049b fix(solana): graceful fallback to DB-only credits when blockchain unavailable
Devnet airdrop faucet rate-limited. mintTokens() now returns a
db-only signature instead of failing when Solana is unreachable,
unfunded, or mint creation fails. This lets watch events and
backfill still credit users in the database. Blockchain minting
will resume automatically once SOL is available.
2026-04-21 15:25:21 -04:00
hobokenchicken 871c01c79e fix(solana): airdrop SOL to mint authority before creating mint
Mint authority had zero SOL balance on devnet, causing
'Attempt to debit an account but found no record of a prior
credit' error. Now getTokenMint() checks balance, airdrops 2 SOL
if needed, then creates the SPL token mint. Also added caching
so mint is only created once.
2026-04-21 15:18:45 -04:00
hobokenchicken 9b5d477852 fix(solana): auto-create token mint on devnet if not configured
getTokenMint() was a stub returning null. Now checks SOLANA_MINT_ADDRESS
env var first, then auto-creates a new SPL token mint on devnet using
the existing mint authority keypair. This enables actual token minting
for backfill and live watch events.
2026-04-21 15:13:56 -04:00
hobokenchicken a20927913f fix(docker): use host network mode for backend
Backend couldn't reach Tautulli (172.20.1.255) or Overseer
(172.20.1.225) from Docker bridge network. Switched to host
network mode so backend can access local network services.
Updated DATABASE_URL and REDIS_URL to use localhost.
2026-04-21 15:08:36 -04:00
hobokenchicken c38117fbe7 fix(backfill): map Plex username to Tautulli user ID before fetching history
Tautulli get_history requires internal user_id, not Plex ID.
Now queries get_users first, matches by username/email/friendly_name,
then uses matched user's ID for history fetch.
2026-04-21 15:00:28 -04:00
hobokenchicken 946b81384c fix(crypto): SHA-256 hash ENCRYPTION_KEY for AES-256-GCM
ENCRYPTION_KEY was 64 hex chars = 64 bytes. AES-256 needs exactly
32 bytes. Now hashing with SHA-256 to derive proper 32-byte key
regardless of input length. Fixed in auth.ts backfill encrypt
and wallet.ts encrypt/decrypt.
2026-04-21 14:53:55 -04:00
hobokenchicken 338e2a1fc1 feat(auth): backfill 30 days watch history on signup
New users automatically get credited for their last 30 days of
Plex watch history via Tautulli. Creates wallet if needed,
fetches history, calculates credits with same rules as live
webhooks, mints tokens, and creates watchEvent + transaction
records. Only runs on first-time signup.
2026-04-21 14:40:36 -04:00
hobokenchicken 2215eb900b fix(backend): session dedupe + mint authority JSON array parsing
1. Auth callback now deletes old sessions before creating new one,
   and adds Date.now() nonce to JWT to prevent unique constraint
   violations on duplicate login attempts.

2. Solana mint authority now accepts both JSON array and base58
   formats for SOLANA_MINT_AUTHORITY_KEYPAIR env var.
2026-04-21 14:26:21 -04:00
hobokenchicken 5db61212dc feat(theme): barnyard redesign with rustic crypto aesthetic
- New color palette: barn red primary, cream backgrounds, hay gold
- Added Abril Fatface display font for headlines
- Wood grain texture backgrounds via CSS gradients
- Barnyard personality in copy: 'Join the Flock', 'Enter the Coop'
- Replaced hardcoded slate colors with theme variables
- Updated landing, login, dashboard, onboarding, leaderboard
2026-04-21 14:14:48 -04:00
hobokenchicken 185018a42e fix(auth): prevent duplicate plex callback requests
React re-renders caused useEffect to fire twice. First
request succeeded, second consumed already-used PIN → 500.
Added useRef guard to dedupe.
2026-04-21 13:58:11 -04:00
hobokenchicken f191ad4e4c fix(auth): coerce Plex ID to string for Prisma
Plex API returns user.id as integer but Prisma schema expects
String for plexId. Wrapped with String() to fix login 500.
2026-04-21 13:53:32 -04:00
hobokenchicken 175c368cfd fix(docker): align backend port with Caddy reverse proxy
Caddy routes /api/* to port 3002 but docker-compose exposed
backend on 3001. Changed backend port, healthcheck, and
frontend fallback to 3002 for consistency.
2026-04-21 13:30:59 -04:00
hobokenchicken 18e9f58c1a fix(docker): fix standalone output path in frontend Dockerfile
Next.js 16 standalone output preserves monorepo subdirectory
structure, placing server.js at frontend/server.js instead of
server.js. Updated COPY paths and CMD to match.
2026-04-21 11:58:10 -04:00
hobokenchicken 3e531580bd fix(auth): remove unused useSearchParams causing build fail
Next.js 16 prerender error on /auth/callback from
useSearchParams without Suspense. Removed unused import
to fix Docker build.
2026-04-21 11:45:33 -04:00
hobokenchicken 5751e08eb1 fix(auth): use Plex PIN flow instead of OAuth2 code exchange
Plex auth uses PIN-based flow, not standard OAuth2 authorization_code.

- backend/auth: POST /api/v2/pins to create PIN, GET /api/v2/pins/{id} to get authToken
- frontend/login: store pinId in sessionStorage before redirect
- frontend/callback: send pinId to backend instead of query code
- backend/index: fix dotenv path resolution for tsx (__dirname returns '.')
2026-04-21 09:27:00 -04:00
Your Name 7e68f57d69 Fix: support coop FQDN for dashboard access 2026-04-18 02:10:06 +00:00
Your Name 4fba61f83b UI: Re-theme app with coop-inspired colors 2026-04-18 02:07:03 +00:00
Your Name 425fb007f3 Fix: Update CORS and network config for dev IP access 2026-04-18 01:45:27 +00:00
Your Name dabd1d5b18 UI: Update login page branding to CoopCoins 2026-04-18 01:34:11 +00:00
Your Name 4d6e36ec24 Fix: Improve Plex OAuth flow and initialization 2026-04-18 01:32:13 +00:00
Your Name 2c89bf3e18 Feat: Rebrand project to CoopCoins with friendly messaging 2026-04-18 01:20:38 +00:00
Your Name 61bbca2e5d Refactor: Improve error handling in authentication flow 2026-04-17 19:55:35 +00:00
hobokenchicken 7c5da339cb fix: Add root page.tsx to fix 404 on /
- Create app/page.tsx that redirects to /login
- Fixes 404 error when accessing root URL
2026-04-15 14:46:48 -04:00
hobokenchicken 65636f5133 fix: Expose ports on all interfaces for internal network access
- Change port 3000 from 127.0.0.1 to 0.0.0.0 (frontend)
- Change port 3001 from 127.0.0.1 to 0.0.0.0 (backend)
- Allows access from 172.20.1.0/24 network
2026-04-15 14:41:57 -04:00
hobokenchicken 1d05bf9cc8 chore: Remove nginx - use direct Caddy routing
- Remove nginx service from docker-compose
- Services bind to localhost:3000/3001 only
- Add Caddy configuration guide
- Update README with simplified structure
- External reverse proxy handles SSL/routing
2026-04-15 14:27:48 -04:00
hobokenchicken 67701d10ad chore: Remove SSL cert handling - use external reverse proxy
- Nginx now listens on HTTP only (port 80)
- Remove SSL cert volume mounts from docker-compose
- Remove SSL troubleshooting sections
- Update docs to indicate SSL handled by Caddy/reverse proxy
- Simplify nginx.conf to remove HTTPS server block
2026-04-15 14:25:35 -04:00
hobokenchicken 9516f5d570 docs: Update setup and troubleshooting guides
- Add Docker build troubleshooting section
- Update Quick Start with SSL cert and public dir steps
- Add prisma db push instruction for database setup
- Document common build errors and solutions
2026-04-15 14:21:37 -04:00
hobokenchicken 2388873e7a fix: Docker build and runtime fixes
- Fix duplicate 'signature' variable in webhooks.ts
- Add Prisma binary target for Alpine Linux
- Fix tsconfig path alias (@/* -> ./src/*)
- Add missing next-themes dependency
- Add build args for NEXT_PUBLIC_* env vars
- Fix SSR issues with zustand and providers
- Add providers-wrapper with dynamic ssr:false import
- Add SSL certs and public dir for nginx
- Update Dockerfiles for proper Prisma engine handling
2026-04-15 14:16:27 -04:00
hobokenchicken a1572d327f fix: relax tsconfig and add @types/bs58 for build
- Set strict: false and disable strict type checking options
- Add @types/bs58 dev dependency
- Fixes TypeScript compilation errors in Docker build
2026-04-14 15:58:08 -04:00
hobokenchicken 895e74c657 fix: add @unique to Transaction.requestId for one-to-one relation
Prisma requires unique fields on the defining side of one-to-one relations.
Fixes P1012 validation error during prisma generate.
2026-04-14 15:55:04 -04:00
hobokenchicken 84dd370673 fix: add build tools and copy node_modules from builder
- Install python3, make, g++ in builder for native module compilation
- Copy node_modules from builder stage to avoid rebuild in production
- Fixes usb package compilation error in node:20-alpine
2026-04-14 15:52:22 -04:00
hobokenchicken d2e20ad82a fix: docker build - use root context for monorepo workspaces
- Change build context from ./frontend|backend to root (.)
- Update Dockerfiles to copy from correct paths
- Use npm install instead of npm ci (workspaces share root lockfile)
- Remove obsolete version attribute from docker-compose.yml

Fixes npm ci errors when package-lock.json is at workspace root.
2026-04-14 15:45:27 -04:00
hobokenchicken 20d1f216a0 fix: update anchor to 0.30.1 and fix breaking changes
- anchor-lang: 0.29.0 -> 0.30.1
- anchor-spl: 0.29.0 -> 0.30.1
- solana-program: 1.16.20 -> 2.x (inferred from anchor-spl)
- Fix token_prog -> token_program naming
- Fix ctx.bumps access for Anchor 0.30.x API
- Update declare_id! with new vanity address

Build now passes successfully.
2026-04-14 15:29:55 -04:00
hobokenchicken 2e8260bc8c security: upgrade dependencies to fix critical and high vulnerabilities
- next: 14.2.15 → 15.2.5 (fixes critical DoS, SSRF, cache poisoning)
- react/react-dom: 18.2.0 → 19.1.0
- @solana/spl-token: 0.3.9 → 0.4.14 (bigint-buffer overflow fix)
- vitest: 1.1.0 → 3.0.0 (esbuild dev server exposure fix)
- mocha: 9.0.3 → 11.7.5 (serialize-javascript RCE fix)
- @solana/wallet-adapter-*: latest versions
- Add npm overrides for elliptic, lodash, esbuild, nanoid

Vulnerabilities: 44 (1 critical) → 23 (3 high, 20 low)

Refs: npm audit fixes for GHSA-7m27-7ghc-44w9, GHSA-3gc7-fjrx-p6mg
2026-04-14 14:15:48 -04:00
hobokenchicken a0ff5adda8 docs: add troubleshooting guide
Document common issues and solutions including:
- NPM deprecation warnings (safe to ignore)
- Database connection issues
- Webhook configuration
- SSL certificate problems
- Memory and performance tuning
2026-04-14 13:42:35 -04:00
hobokenchicken d602d667ea fix(frontend): update Next.js to 14.2.15
Fix security vulnerability in Next.js 14.0.4.
See: https://nextjs.org/blog/security-update-2025-12-11

Other npm deprecation warnings are from transitive dependencies
(@solana/wallet-adapter packages) and don't affect functionality.
2026-04-14 13:41:57 -04:00
hobokenchicken 2e41156046 chore: add .env.example template files
Add environment variable templates for:
- Root .env.example (all services)
- backend/.env.example (API configuration)
- frontend/.env.local.example (client config)

Copy to .env and fill in your secrets before running.
2026-04-14 11:14:37 -04:00
hobokenchicken e8d9b1fd42 feat: add CoopCredits Solana media rewards ecosystem
Add complete  token system with Plex/Tautulli/Overseer integration:
- Anchor program for SPL token mint/burn/transfer
- Express backend with OAuth, webhooks, Solana integration
- Next.js frontend with dashboard, admin panel, wallet management
- Docker deployment for 172.20.1.0/24 infrastructure
- Production configs with SSL, Nginx, health monitoring

Tautulli webhooks auto-mint  on watch events.
Overseer integration burns  for content requests.
2026-04-14 11:09:50 -04:00
hobokenchicken f106328f6a initial upload 2026-04-13 15:34:36 -04:00