Skip to content

About

🍳 The Viral Full-Stack MyAnimeList AI Roaster & Diagnostics Engine β€” Next.js 15, OAuth 2.0 PKCE, LLM Personas & Dynamic Share Cards.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

🍳 MANWARE COOKED

The Viral Anime Taste Diagnostics & AI Profile Roasting Engine

Full-Stack Next.js 15 β€’ MyAnimeList OAuth 2.0 PKCE β€’ Google Gemini LLM β€’ 100% Type-Safe

Next.js 15 TypeScript MyAnimeList API Google Gemini Tests Passing Pedagogy

Ever wondered what your anime watch list says about your psychological state?
Manware Cooked connects securely to your MyAnimeList profile via OAuth 2.0 PKCE, ingests your lifetime viewing history, computes algorithmic taste metrics (score variance, drop rates, guilty pleasures), and unleashes an LLM-powered personalized roast paired with an exportable social brag card.


⚑ Quick Start β€’ πŸ—ΊοΈ System Architecture β€’ πŸ›‘οΈ Security & PKCE Engine β€’ πŸ“Š System Metrics β€’ πŸ§ͺ Test Suite


πŸ“Š At a Glance (System & Architecture Metrics)

Dimension Architectural Specification
⚑ Core Framework Next.js 15+ (App Router, Server Components, Route Handlers, Edge-ready)
πŸ›‘οΈ Authentication Protocol OAuth 2.0 Authorization Code Grant + PKCE (RFC 7636 compliant)
πŸ€– AI Roast Engine Google Gemini LLM with calibrated persona prompts & structured JSON output
πŸ”’ State & Session Security Dual HTTP-only ephemeral cookies (SameSite=Lax, 10m TTL) + encrypted session tokens
πŸ“ˆ Data Ingestion Engine Paginated rate-limited scraper (limit=100, auto-offset) against MyAnimeList API v2
πŸ§ͺ Test Suite & Verification Native Node.js Test Runner (tsx --test) with 100% strict assertions & mock harnesses
🎨 Design & Aesthetics Cyberpunk Terminal HUD, animated roast reveals, and dynamic SVG/Canvas share cards
πŸŽ“ Development Philosophy Built under the Alvar Method (Probe β†’ Plan β†’ Teach β†’ Lock-in) pairing protocol

πŸ—ΊοΈ Visual Architecture Highlights

1. High-Level Ingestion & Roasting Pipeline

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        1. Client Authorization                         β”‚
β”‚       Browser Request ──▢ PKCE Codes (Verifier + Plain Challenge)      β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                       2. MyAnimeList Authentication                    β”‚
β”‚   Redirect to MAL ──▢ User Consents ──▢ Callback with Single-Use Code   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚     3a. Token Exchange            β”‚     3b. Ingestion Engine           β”‚
β”‚  POST /v1/oauth2/token (x-www)    β”‚  Paginated Anime List Aggregator   β”‚
β”‚  Returns: Access & Refresh Tokens β”‚  Calculates Variance, Drops, Mean  β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                    4. Algorithmic Taste Classifier                     β”‚
β”‚    Archetype Matching: Shonen Junkie, Elitist Weeb, Seasonal Hopper    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                        5. LLM Roasting & Delivery                      β”‚
β”‚     Calibrated Persona ──▢ Structured Roast JSON ──▢ Cyberpunk HUD     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

2. OAuth 2.0 PKCE Handshake Sequence

sequenceDiagram
    autonumber
    actor User as User Browser
    participant Login as GET /api/auth/mal/login
    participant MAL as MyAnimeList OAuth API
    participant Callback as GET /api/auth/callback
    participant LLM as Gemini Roast Engine

    User->>Login: Clicks "Login with MyAnimeList"
    Login->>Login: Generate PKCE (verifier, challenge, state)
    Login-->>User: 307 Redirect to MAL + Set HTTP-only Cookies
    User->>MAL: Authorizes Application
    MAL-->>Callback: Redirects with ?code=...&state=...
    Callback->>Callback: 1. Validate State (CSRF Check)<br/>2. Retrieve code_verifier cookie
    Callback->>MAL: POST /v1/oauth2/token (exchange code + verifier)
    MAL-->>Callback: 200 OK: { access_token, refresh_token }
    Callback-->>User: Set mal_session Cookie & Redirect to Dashboard
    User->>LLM: Ingest Library & Request Roast
    LLM-->>User: Deliver Devastating Roast & Share Card
Loading

🧩 Core Engine Modules & Implementation Matrix

1. πŸ›‘οΈ OAuth 2.0 PKCE Security Vault

Core Files: src/lib/mal/pkce.ts β€’ src/app/api/auth/mal/login/route.ts
Test Suites: src/lib/mal/pkce.test.ts β€’ src/app/api/auth/mal/login/route.test.ts

  • Cryptographic Code Verifier: Generates 128-character cryptographically random strings using Node.js crypto.randomBytes(), mapped strictly to RFC 7636 unreserved characters [A-Za-z0-9-._~].
  • Plain Challenge Method: Implements MyAnimeList's native "plain" code challenge transformation (challenge === verifier).
  • CSRF State Guard: Generates high-entropy random state strings stored in short-lived HTTP-only cookies (600s TTL) to prevent cross-site request forgery attacks.
  • Defensive Route Handlers: Verifies environment configurations (MAL_CLIENT_ID) before dispatching redirects to prevent broken external auth flows.

2. ⚑ Token Exchange & Session Manager

Core Files: src/lib/mal/client.ts β€’ src/lib/mal/session.ts
Test Suite: src/lib/mal/client.test.ts

  • Strict Form Encoding: Packages token requests via new URLSearchParams() to conform to MAL's strict application/x-www-form-urlencoded POST format.
  • Token Rotation & Refresh: Built-in support for transparently refreshing expired access tokens using the long-lived refresh_token.
  • Secure Cookie Jar: Implements strict httpOnly, sameSite: "lax", and path-isolated cookies for active user sessions.

3. πŸ“₯ High-Throughput Watch History Ingestion

Core File: src/lib/mal/client.ts (fetchUserAnimePage)

  • Paginated Fetching: Auto-paginating client fetching up to 100 entries per page, retrieving status, scores, genres, and episode counts.
  • Rate-Limit Resilience: Gracefully navigates MAL's rate limits with exponential backoff and request spacing.
  • Profile Aggregation: Fetches lifetime statistics (mean score, days watched, completed vs dropped count).

4. 🎯 Taste Diagnostics & Archetype Classifier

Core Types: src/types/metrics.ts β€’ src/types/roast.ts

  • Statistical Metrics Engine:
    • Score Standard Deviation: Identifies if the user is a "Generous 10/10 Giver" or a "Pretentious 4/10 Critic".
    • Drop Ratio Index: Flags users who abandon 40%+ of series before episode 3.
    • Guilty Pleasure Quotient: Cross-references user scores against the global MAL community mean to find wildly overrated personal favorites.
  • Archetype Assignment: Categorizes profiles into archetypes:
    • πŸ—‘οΈ The Shonen Meathead (90% battle shonen, zero variety)
    • 🧐 The MAL Forum Elitist (Only rates obscure 90s OVAs above 7)
    • 🌸 The Slice-of-Life Escapist (Watches cute girls drinking tea to avoid reality)
    • πŸ“‰ The Serial Dropper (Started 400 anime, finished 12)

5. 🌢️ AI Roasting Engine & Prompt Studio

Core Engine: Gemini 1.5 Pro / Flash with calibrated system instructions.

  • Structured JSON Schema: Enforces rigid schema validation for consistent UI rendering:
    interface RoastResponse {
      archetype: string;
      summaryBurn: string;
      metricsBreakdown: {
        scoreInflationLevel: "Mild" | "Severe" | "Delusional";
        dropRateSeverity: string;
      };
      spicyBurns: string[];
      guiltyPleasureCallout: string;
      verdict: string;
    }
  • Dynamic Persona Calibration: Tailors roast intensity from Mild Teasing to Nuclear Scorched Earth.

πŸ“ Repository Directory Blueprint

manware_cooked/
β”œβ”€β”€ πŸ“ docs/                        # Architecture specs, checkpoints & notes
β”‚   β”œβ”€β”€ πŸ“„ 01-architecture.md       # OAuth PKCE & system diagrams
β”‚   β”œβ”€β”€ πŸ“„ SESSION_CHECKPOINT.md    # Active pair-programming handover state
β”‚   └── πŸ“ notes/                   # Obsidian-ready atomic knowledge cards
β”‚       └── πŸ“„ 03-token-exchange.md # Step-by-step token exchange breakdown
β”œβ”€β”€ πŸ“ src/
β”‚   β”œβ”€β”€ πŸ“ app/                     # Next.js 15 App Router
β”‚   β”‚   β”œβ”€β”€ πŸ“ api/
β”‚   β”‚   β”‚   └── πŸ“ auth/
β”‚   β”‚   β”‚       β”œβ”€β”€ πŸ“ mal/login/   # GET /api/auth/mal/login (redirect + cookies)
β”‚   β”‚   β”‚       β”‚   β”œβ”€β”€ πŸ“„ route.ts
β”‚   β”‚   β”‚       β”‚   └── πŸ§ͺ route.test.ts
β”‚   β”‚   β”‚       └── πŸ“ callback/    # GET /api/auth/callback (code exchange)
β”‚   β”‚   β”‚           β”œβ”€β”€ πŸ“„ route.ts
β”‚   β”‚   β”‚           └── πŸ§ͺ route.test.ts
β”‚   β”‚   β”œβ”€β”€ πŸ“„ page.tsx             # Cyberpunk Landing Page & HUD
β”‚   β”‚   └── πŸ“„ layout.tsx           # Global Layout & Fonts
β”‚   β”œβ”€β”€ πŸ“ lib/
β”‚   β”‚   └── πŸ“ mal/
β”‚   β”‚       β”œβ”€β”€ πŸ“„ pkce.ts          # RFC 7636 PKCE generator functions
β”‚   β”‚       β”œβ”€β”€ πŸ§ͺ pkce.test.ts     # 10/10 automated PKCE test suite
β”‚   β”‚       β”œβ”€β”€ πŸ“„ client.ts        # MyAnimeList API v2 Client
β”‚   β”‚       β”œβ”€β”€ πŸ§ͺ client.test.ts   # Token exchange unit test suite
β”‚   β”‚       └── πŸ“„ session.ts       # Secure cookie options & session types
β”‚   └── πŸ“ types/                   # Strict TypeScript definitions
β”‚       β”œβ”€β”€ πŸ“„ mal.ts               # MAL Tokens, User & API interfaces
β”‚       β”œβ”€β”€ πŸ“„ metrics.ts           # Algorithmic taste score metrics
β”‚       └── πŸ“„ roast.ts             # Roast schema & archetype contracts
β”œβ”€β”€ πŸ“„ AGENTS.md                    # Pair-programming rules & end-of-task protocol
β”œβ”€β”€ πŸ“„ STUDY_JOURNAL.md             # Chronological student learning journal
└── πŸ“„ package.json                 # Scripts, dependencies & test runner

πŸ§ͺ Test Suite & Quality Assurance

All core business logic is tested with Node.js Native Test Runner (node:test) and TypeScript execution (tsx):

# Run all unit tests across the entire codebase
npm test

# Run a specific module test suite
npx tsx --test src/lib/mal/pkce.test.ts
npx tsx --test src/lib/mal/client.test.ts
npx tsx --test src/app/api/auth/mal/login/route.test.ts

βœ… Test Coverage Highlights:

  • src/lib/mal/pkce.test.ts: 10 / 10 Passing (Verifier length bounds, unreserved regex, random entropy, plain challenge, state generation, auth URL builder).
  • src/lib/mal/client.test.ts: 2 / 2 Passing (x-www-form-urlencoded POST encoding, status code error throwing, token return parsing).
  • src/app/api/auth/mal/login/route.test.ts: 2 / 2 Passing (Missing client ID 500 guard, 307 temporary redirect, HTTP-only cookie attachment).

πŸš€ Quick Start & Developer Setup

1. Prerequisites

  • Node.js v20.x or higher
  • npm v10.x or higher
  • A MyAnimeList Account & registered developer application at myanimelist.net/apiconfig.

2. Clone & Install

git clone https://github.com/karnVen/manware_cooked.git
cd manware_cooked
npm install

3. Environment Variables

Create .env.local in the project root:

# MyAnimeList Developer API Credentials
MAL_CLIENT_ID=your_mal_client_id_here
MAL_CLIENT_SECRET=your_optional_client_secret

# Application URL
NEXT_PUBLIC_APP_URL=http://localhost:3000

# AI Roasting Engine (Google Gemini)
GEMINI_API_KEY=your_gemini_api_key_here

# Session Secret (Optional: for encrypted cookie sessions)
SESSION_SECRET=super_secure_random_string_here

4. Launch Development Server

npm run dev

Open http://localhost:3000 in your browser.


πŸŽ“ The Alvar Method & AI-bou Framework

This repository is developed following the Alvar Method (Probe β†’ Plan β†’ Teach β†’ Lock-in):

    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚ 1. PROBE  β”‚ ───▢  β”‚ 2. PLAN  β”‚ ───▢  β”‚ 3. TEACH  β”‚ ───▢  β”‚ 4. LOCK-IN  β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
      Diagnose            Architect          Plain-English       Commit, Push
      Prerequisites       Blueprints         Guidance            & Obsidian
  1. Student-Led Coding: Zero spoon-feeding. The AI mentors and provides scaffolding; the human developer designs and writes 100% of the code.
  2. Atomic Obsidian Sync: Every milestone automatically generates an Obsidian-formatted Markdown study note in docs/notes/ for long-term retention.
  3. Continuous Handover Checkpoints: Transparent progress logs maintained in STUDY_JOURNAL.md and docs/SESSION_CHECKPOINT.md.

🍳 Built with ❀️ and spicy burns by @karnVen

Licensed under the MIT License.

About

🍳 The Viral Full-Stack MyAnimeList AI Roaster & Diagnostics Engine β€” Next.js 15, OAuth 2.0 PKCE, LLM Personas & Dynamic Share Cards.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages