How konstasil/anijun works
Purpose and Runtime
Anijun is a Next.js TypeScript application for an anime catalog and social recommendation experience: browsing anime, rating items, profile/friend interactions, suggestions, and an admin content workflow. It uses the App Router and runs as a server-rendered/client-interactive web application.
Primary entry points:
• Root layout and landing route: src/app/layout.tsx, src/app/page.tsx
• Request/session boundary: middleware.ts
• Supabase access adapters: src/lib/supabase/client.ts, src/lib/supabase/server.ts
Routing and Product Surfaces
Route folders define the application’s primary product areas:
• Catalog and title detail: src/app/catalog/page.tsx, src/app/anime/[slug]/page.tsx
• Discovery/rankings and recommendations: src/app/top/page.tsx, src/app/sova/page.tsx, src/app/suggest/page.tsx
• User and social features: src/app/profile/page.tsx, src/app/friends/page.tsx
• Administrative content management: src/app/admin/page.tsx, src/app/admin/add/page.tsx
The dynamic [slug] route is the canonical detail boundary for an individual anime, supported by the slug database migration.
Authentication and Session Propagation
Authentication UI lives at src/app/login/page.tsx and src/app/signup/page.tsx; the OAuth/auth redirect completion endpoint is src/app/auth/callback/route.ts.
middleware.ts delegates Supabase-aware request handling through src/lib/supabase/middleware.ts, making session refresh and identity availability a cross-cutting request boundary. Server components/routes should use src/lib/supabase/server.ts; browser-interactive components should use src/lib/supabase/client.ts, avoiding direct coupling to a single environment’s auth/storage mechanics.
Data Model and Persistence
Supabase is the material persistence and authentication service. The relational baseline and evolution are represented in:
• sql/schema.sql
• sql/migration_profiles_extended.sql
• sql/migration_recommendations.sql
Migrations indicate core domains: profiles and user IDs, friends, anime slugs, avatar storage URLs, ratings/recommendations, suggestions, seasonal notes, and simulation data. sql/seed.sql supplies initial data. Database schema changes are an explicit deployment concern rather than being generated by the Next.js app.
Recommendation and Simulation Domain
Recommendation logic is centralized in src/lib/recommendations.ts, separating ranking/suggestion rules from page presentation. Recommendation-related persisted state is introduced by sql/migration_recommendations.sql and sql/migration_suggestions.sql.
src/lib/simulation-context.tsx provides client-side shared state for a simulation-oriented experience, consumed by the Sova/discovery surface at src/app/sova/page.tsx. This is a UI-state boundary distinct from durable Supabase records.
Shared UI and Interaction Boundaries
src/components/Header.tsx is the application-wide navigation shell, while src/components/AnimeCard.tsx is the reusable catalog/list presentation unit used across discovery-oriented routes.
Interactive boundaries include:
• Image/avatar upload: src/components/ImageUpload.tsx
• User discovery/social selection: src/components/UserSearch.tsx
• Rating feedback: src/components/RatingToast.tsx
src/components/SafeImage.tsx standardizes image rendering/failure handling, important because anime artwork and user avatars likely originate from stored or external URLs.
Infrastructure and External Integration
The deployment runtime is Next.js, configured by next.config.ts, with global styling in src/app/globals.css. Supabase provides auth, database, and likely object storage for uploaded avatars. Static ownership-verification files in public/google4b778939d11ff2e9.html and public/yandex_1bb5b30642fb8372.html indicate Google and Yandex webmaster/search integrations.
Control flow is generally: request → middleware session handling → App Router page/route → server or browser Supabase adapter → Supabase persistence/auth; UI components render catalog, profile, social, and recommendation results.
Components 19
Next.js Runtime
- Session Middleware · Refreshes sessions and makes identity available per request.
- Supabase Middleware
- App Shell · Global layout and navigation shell.
- Landing Route
Product Surfaces
- Auth UI & Callback · Login, signup, and OAuth completion routes.
- Catalog & Anime Detail · Browse catalog and canonical slug-based title detail.
- Discovery & Suggestions · Rankings, Sova discovery, and recommendation suggestions.
- Profile & Friends · User profile and friend interactions.
- Admin Content Workflow · Administrative content management and creation.
Shared Domain & UI
- Recommendation Rules · Centralized ranking and suggestion logic.
- Simulation State · Shared client-side state for the simulation experience.
- Shared Catalog UI · Global navigation and reusable anime-card presentation.
- Interactive UI · Uploads, user search, rating feedback, and safe image rendering.
Supabase & Schema
- Server Supabase Adapter · Supabase access for server components and route handlers.
- Browser Supabase Adapter · Supabase access for browser-interactive components.
- Supabase · Durable authentication, relational data, and avatar storage.
- Schema Baseline · Relational baseline for application domains.
- Recommendation Migrations · Persists recommendation and suggestion state.
- Initial Seed Data
Connections 18
- Session Middleware → Supabase Middleware: delegates session handling
- Supabase Middleware → Supabase: refreshes auth session
- App Shell → Landing Route: wraps
- App Shell → Shared Catalog UI: uses navigation
- Auth UI & Callback → Server Supabase Adapter: auth flow
- Catalog & Anime Detail → Server Supabase Adapter: loads catalog data
- Discovery & Suggestions → Recommendation Rules: applies ranking rules
- Discovery & Suggestions → Simulation State: uses client state
- Discovery & Suggestions → Shared Catalog UI: renders cards
- Profile & Friends → Server Supabase Adapter: loads social data
- Admin Content Workflow → Server Supabase Adapter: manages content
- Interactive UI → Browser Supabase Adapter: interactive data access
- Server Supabase Adapter → Supabase: server access
- Browser Supabase Adapter → Supabase: browser access
- Recommendation Rules → Supabase: reads persisted signals
- Schema Baseline → Supabase: defines baseline
- Recommendation Migrations → Supabase: evolves recommendation tables
- Initial Seed Data → Supabase: loads initial data