β‘ The Ultimate Full-Stack Ecosystem for Trackers & Otakus β‘
Note
ARCHITECTURAL MISSION Modern media tracking platforms frequently suffer from discovery fatigue and sluggish data synchronization. Users are often forced to wade through generic, unpersonalized homepages, while tracking modifications (like moving an entry from a watch list to a completed archive) are bottlenecked by sequential database round-trips that introduce noticeable user-interface latency.
ANIDost solves these architectural flaws by introducing a high-performance, asynchronous anime tracking and discovery ecosystem. The core philosophy of the platform centers around providing an immediate, highly personalized user experience from the very first interaction. By decoupling the presentation layer from heavy cloud database transactions, ANIDost balances real-time performance with deep user personalization.
The client application features a responsive, dark glassmorphic interface built to optimize screen real estate. It features global analytics trackers, interactive sliders, custom carousels, and independent state-driven dashboards tailored to both anonymous visitors and authenticated power-users.
To support thousands of simultaneous actions without degrading platform speed, ANIDost implements a Dual-Layer Caching Topology paired with a scalable data persistence layer:
To eradicate redundant network overhead and eliminate jarring loading spinners, the frontend utilizes TanStack Query (React Query) as its asynchronous state-management engine.
- Stale-While-Revalidate (SWR): TanStack Query intelligently caches API responses (such as the watchlist or recommendation arrays) locally. When a user navigates between views, cached data is rendered instantly, while a background fetch ensures the UI silently updates if server data has changed.
- Optimistic UI Mutation Machine: When a user clicks Mark as Completed, TanStack Query immediately updates the client cache directly, instantly incrementing the Completed dashboard card counter and updating the tracking button state (
O(1)perceived latency).
Important
TRANSACTIONAL FAULT ROLLBACKS
If the underlying Axios HTTP request to the FastAPI server fails, TanStack Query catches the exception, fires a targeted visual toast notification (Network error. Reverted changes.), and automatically rolls the client cache back to its exact previous source-of-truth state.
Traditional database text queries rely on heavy relational operations like SQL LIKE statements, which force a sequential table scan across thousands of database rows, leading to severe latency bottlenecks. To resolve this, ANIDost implements a proprietary, high-speed custom search engine paired with Redis-backed caching.
- In-Memory Prefix Search Indexing: On application startup, the FastAPI backend processes raw catalog data, mapping 15,850+ unique anime titles into 54,953 high-speed string search prefixes for instant autocomplete resolution.
-
Custom Multi-Tier Search Engine:
-
Exact Matching: Highest weight assigned to absolute title matches (
match_score = 1000). -
Prefix Matches: Matches strings starting with the query using the precomputed prefix index (
match_score = 800). -
Substring Contains: Matches titles that contain the query anywhere within the string (
match_score = 500). -
Fuzzy Fallback Search: When standard lookups yield fewer than 30 matches, the system triggers a fuzzy fallback using the
rapidfuzzlibrary's Levenshtein-basedpartial_ratioalgorithm (thresholding at$\ge 75%$ similarity). This catches typos, phonetic spellings, and minor omissions, mapping the similarity percentage directly to the match score. -
Ranking Strategy: Results are dynamically sorted by their
match_scoredescending, then by global popularity (members) descending, and finally by numerical reviewscoredescending, presenting the most relevant and high-quality results first.
-
Exact Matching: Highest weight assigned to absolute title matches (
- Serverless Redis: All cached search data and autocomplete arrays are stored in a managed Upstash Serverless Redis instance, providing sub-millisecond read/write performance.
- Optimized Caching Pipelines: Repeated search terms and autocomplete queries are served directly from Redis, shifting lookup latencies from database-bound operations to single-digit milliseconds.
- Global Feed Caching: Heavy aggregations, such as the Trending Now dashboard slider, are processed intermittently and cached in Redis, preventing repetitive calculation loops on every single user request.
While TanStack Query and Redis govern transient speed, Supabase serves as the immutable relational foundation of the platform.
- Relational Database Integrity: Running a cloud-hosted PostgreSQL instance, Supabase safely stores persistent user schema records, active watchlist tables, multi-dimensional genre preference vectors, and verified history tables.
- Frictionless Social Provisioning: The backend maps native frontend Google OAuth tokens directly into the Supabase security layer, allowing instant user profile creation and session verification without writing custom database bridges.
The Forged for You Engine combines two distinct recommendation strategies (Content-Based and Collaborative Filtering) to produce personalized recommendation arrays, using a fallback topology to handle cold starts or out-of-model items.
- Methodology: Item-to-Item Collaborative Filtering using user rating behaviors to calculate item similarities.
- Matrix Construction: Pivots user ratings into a sparse User-Item matrix, transposing it to calculate pairwise Cosine Similarity among popular titles. This allows the system to identify similar items based on global co-rating behavior (
item_similarity.npy). - Data Source & Preprocessing (
rating.csv):- Invalid Filter: Removes missing/non-rated entries (
rating = -1). - High-Activity Thresholding: Filters out anime with fewer than 12,000 global ratings to handle sparsity and focus computational overhead on statistically significant entries, producing
cleaned_ratings.csv.
- Invalid Filter: Removes missing/non-rated entries (
- Methodology: TF-IDF Semantic Text Mining coupled with Multi-Attribute Cosine Similarity.
-
Feature Vectors: Combines:
-
Genre Vectors: Binary
CountVectorizeron genre attributes. -
Synopsis Vectors:
TfidfVectorizer(with English stop-words,$N$ -grams from 1 to 3, and a 20,000 vocabulary limit) on cleaned plots/synopses.
-
Genre Vectors: Binary
-
Weighted Similarity Fusion: Computes Cosine Similarity matrices for both genre and synopsis features separately. The final recommendation score is compiled as a weighted fusion:
$70%$ Genre Similarity +$30%$ Synopsis Similarity. -
Dynamic Boosting: Applies a
$1.3\times$ boost for action/shounen genres and a$1.5\times$ boost if candidates share$4+$ genre intersections with the query anime. -
Data Source & Preprocessing (
animes.csv):-
Null Imputation: Fills blank genres/synopses; drops entries missing a numerical rating
score. -
Franchise Cleanup: Strips title suffixes (
movie,special,ova,season, etc.) and non-alphanumeric characters to deduplicate franchise derivatives. -
Ad-Filtering: Drops placeholder listings or lines containing generic text ("h for genre", "h for synopsis"), saving the final pipeline input to
cleaned_animes.csv.
-
Null Imputation: Fills blank genres/synopses; drops entries missing a numerical rating
-
Recommendation Blend: Given a target anime
uid, the engine fetches recommendations from both engines. If both are available, a weighted hybrid score is computed: [\text{Final Score} = 0.55 \times \text{Content Score} + 0.45 \times \text{Collaborative Score}] -
Robust Fallback Handling: If the item does not exist in the Collaborative Filtering subset (due to the 12,000 ratings density threshold), the engine smoothly falls back to
$100%$ Content-Based recommendations, ensuring a seamless user experience without query failures. - Onboarding Seed Pipeline: Guest profiles and new users undergo a 3-genre affinity selection to seed immediate recommendations before a rich tracking history is established.
- Short-Lived Access Tokens: Authenticated member session states are isolated using short-lived Access Tokens (30-minute expiration boundaries) to minimize hijack windows.
- Secure Refresh Loops: Long-lived Refresh Tokens are processed securely via backend loops to silently rotate credentials without user disruption.
- SMTP-Driven Register Verification: Traditional registration pathways use an automatic backend SMTP configuration layout to securely deliver random OTP (One-Time Password) confirmation codes via email, validating user accounts instantly.
ML_pro_clean/
βββ .gitignore
βββ README.md
βββ backend
β βββ .dockerignore
β βββ .env
β βββ .env.example
β βββ Dockerfile
β βββ app
β β βββ __init__.py
β β βββ auth
β β β βββ __init__.py
β β β βββ google_oauth.py
β β β βββ jwt_handler.py
β β β βββ password.py
β β βββ config.py
β β βββ core
β β β βββ redis_client.py
β β βββ database
β β β βββ __init__.py
β β β βββ connection.py
β β β βββ models.py
β β βββ dependencies.py
β β βββ limiter.py
β β βββ main.py
β β βββ models
β β β βββ Cleaning.py
β β β βββ processed
β β β β βββ cleaned_animes.csv
β β β β βββ cleaned_ratings.csv
β β β βββ raw
β β β β βββ animes.csv
β β β β βββ rating.csv
β β β βββ recommenders
β β β β βββ collaborative_recommender.py
β β β β βββ content_recommender.py
β β β β βββ hybrid_recommender.py
β β β β βββ shared_data.py
β β β β βββ test_hybrid_run.py
β β β β βββ verify_hybrid.py
β β β βββ saved_models
β β β β βββ anime_data.pkl
β β β β βββ cf_mappings.pkl
β β β β βββ genre_matrix.pkl
β β β β βββ genre_tfidf.pkl
β β β β βββ genre_vectorizer.pkl
β β β β βββ item_similarity.npy
β β β β βββ synopsis_matrix.pkl
β β β β βββ synopsis_tfidf.pkl
β β β βββ training
β β β β βββ CollaborativeFTrain.py
β β β β βββ ContentFTrain.py
β β β βββ watchlist.py
β β βββ routes
β β β βββ __init__.py
β β β βββ anime.py
β β β βββ auth_routes.py
β β β βββ cold_start_routes.py
β β β βββ public_routes.py
β β β βββ recommender_routes.py
β β β βββ search_routes.py
β β β βββ watchlist_routes.py
β β βββ schemas
β β β βββ __init__.py
β β β βββ cold_start_schemas.py
β β β βββ user_schemas.py
β β β βββ watchlist_schema.py
β β βββ services
β β β βββ __init__.py
β β β βββ auth_service.py
β β β βββ cache_service.py
β β β βββ email_service.py
β β β βββ jikan_service.py
β β β βββ recommender_service.py
β β β βββ search_service.py
β β β βββ watchlist_service.py
β β βββ tests
β β β βββ __init__.py
β β β βββ redis_test.py
β β βββ utils
β β βββ __init__.py
β β βββ search_index.py
β β βββ search_utils.py
β βββ requirements.txt
β βββ upgrade.py
βββ docker-compose.yml
βββ frontend
β βββ .dockerignore
β βββ .env
β βββ .env.example
β βββ .env.production
β βββ Dockerfile
β βββ index.html
β βββ nginx.conf
β βββ package-lock.json
β βββ package.json
β βββ postcss.config.js
β βββ public
β β βββ epic-bg.jpg
β β βββ favicon.svg
β βββ src
β β βββ App.jsx
β β βββ assets
β β βββ components
β β β βββ AnimeCard.jsx
β β β βββ AnimeGrid.jsx
β β β βββ AnimeHeader.jsx
β β β βββ AnimeInfo.jsx
β β β βββ AnimePosterCard.jsx
β β β βββ Footer.jsx
β β β βββ GenreBadge.jsx
β β β βββ Navbar.jsx
β β β βββ OnboardingRoute.jsx
β β β βββ PageShell.jsx
β β β βββ ProtectedRoute.jsx
β β β βββ Skeleton.jsx
β β β βββ VideoPlayer.jsx
β β βββ context
β β β βββ AuthContext.jsx
β β βββ hooks
β β β βββ useColdStartMutations.js
β β β βββ useColdStartPreferences.js
β β β βββ useCombinedRecommendations.js
β β β βββ useDebounce.js
β β β βββ useForgedList.js
β β β βββ useRecommendations.js
β β β βββ useTopRated.js
β β β βββ useTrending.js
β β β βββ useWatchlist.js
β β β βββ useWatchlistMutation.js
β β βββ index.css
β β βββ main.jsx
β β βββ pages
β β β βββ AboutUs.jsx
β β β βββ AlchemistPage.jsx
β β β βββ AnimeDetailsPage.jsx
β β β βββ Dashboard.jsx
β β β βββ ForgedPage.jsx
β β β βββ GuestAnimeSelection.jsx
β β β βββ GuestOnboarding.jsx
β β β βββ InteractiveHome.jsx
β β β βββ Login.jsx
β β β βββ RecommendationsPage.jsx
β β β βββ SearchPage.jsx
β β β βββ Signup.jsx
β β β βββ WatchlistPage.jsx
β β βββ services
β β β βββ animeService.js
β β β βββ api.js
β β β βββ auth.js
β β β βββ coldStartService.js
β β β βββ recommendationService.js
β β β βββ searchService.js
β β β βββ watchlistService.js
β β βββ styles
β β βββ theme.css
β βββ tailwind.config.js
β βββ vercel.json
β βββ vite.config.js
βββ render.yaml
π Unified API Routing Interface
π Authentication, Validation, & Guest Control
π’ POST /auth/signup
Description: Provisions profile records and dispatches transaction verification OTP.
Security Context: Public (None).
π’ POST /auth/otp/request
Description: Requests a new verification OTP.
Security Context: Public (None).
π’ POST /auth/otp/verify
Description: Validates target register code token to activate account boundaries.
Security Context: Public (None).
π’ POST /auth/login
Description: Traditional credential handshake; issues standard secure dual-token pairings.
Security Context: Access + Refresh Tokens.
π’ POST /auth/google
Description: Validates incoming Google social authentication payloads and provisions credentials.
Security Context: Access + Refresh Tokens.
π’ POST /auth/refresh
Description: Seamlessly refreshes expired access tokens using valid persistent refresh tokens.
Security Context: Requires Refresh Token.
π’ POST /auth/guest
Description: Issues transient guest session tokens for unauthenticated exploratory users.
Security Context: Public (None).
π΅ GET /auth/me
Description: Hydrates frontend application layouts with verified active profile records.
Security Context: Requires valid Access Token.
π’ POST /auth/logout
Description: Terminates user session and completely invalidates active access/refresh tokens.
Security Context: Requires valid Access Token.
π΅ GET /auth/status
Description: Lightweight check for current authentication state.
Security Context: Requires valid Access Token.
πΏ Discovery, Onboarding, & Engine Channels
π’ POST /api/v1/cold-start/preferences
Description: Maps 3 structural genres to build an initial interaction weights user profile.
Security Context: Guest Context or Access Token.
π΅ GET /api/v1/cold-start/preferences
Description: Retrieves user's existing cold-start genre preference schema.
Security Context: Guest Context or Access Token.
π‘ PUT /api/v1/cold-start/preferences
Description: Modifies and updates the structural onboarding parameters.
Security Context: Guest Context or Access Token.
π΄ DELETE /api/v1/cold-start/preferences
Description: Clears user's active cold-start matrix configuration.
Security Context: Guest Context or Access Token.
π΅ GET /api/v1/public/trending
Description: Pulls global index layouts optimized via general system tracking activity weights.
Security Context: Public / Guest Context.
π΅ GET /api/v1/public/top-rated
Description: Retrieves the highest-rated global anime titles ranked by averaged historical user scores.
Security Context: Public / Guest Context.
π΅ GET /api/v1/public/forged-for-you
Description: Generates personalized content streams matching dynamically assigned algorithmic weights.
Security Context: Requires valid Access Token or Guest Context.
π΅ GET /recommend/
Description: Streams hybrid spotlight content compiled using verified global reviewer metadata.
Security Context: Open / Public.
ποΈ Vault Table Control
π΅ GET /api/watchlist/{user_id}
Description: Gathers the active user dataset matching personal vault tracking profiles.
Security Context: Requires valid Access Token.
π΅ GET /api/watchlist/{user_id}/latest
Description: Retrieves the most recently active modifications in a specific tracking matrix.
Security Context: Requires valid Access Token.
π’ POST /api/watchlist/add
Description: Modifies and toggles active item states between Plan to Watch and Completed schemas.
Security Context: Requires valid Access Token.
π΄ DELETE /api/watchlist/{user_id}/{anime_id}
Description: Discards a target entry completely from the user's relational tracking matrix rows.
Security Context: Requires valid Access Token.
π Search & Metadata Execution
π΅ GET /search/
Description: Fast text-index search against the unified anime catalog structure.
Security Context: Public (None).
π΅ GET /search/autocomplete
Description: Prefix-based high-speed autocomplete resolution for navigation dropdowns.
Security Context: Public (None).
π΅ GET /anime/{mal_id}
Description: Fetches robust multi-node metadata configurations for a specific database ID.
Security Context: Public (None).
π οΈ Infrastructure Overview
[!CAUTION]
PRODUCTION ENGINE MAP
Framework Core: FastAPI (Asynchronous Python ASGI Web Hub)
Compilation Engine: React 18 bundled via ultra-low latency Vite infrastructure
Client-Side Cache Engine: TanStack Query (Query client runtime & mutation cache manager)
Relational Backend Database: Supabase Cloud PostgreSQL Cluster
High-Speed Cache Layer: Upstash Serverless Redis (Prefix index execution framework)
Messaging Node: Automated SMTP Gmail App Integration pipeline (OTP infrastructure)