# ankit-mishra0/senpai-central architecture

> Architecture diagram of the GitHub repository ankit-mishra0/senpai-central, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ankit-mishra0/senpai-central
- Repository: https://github.com/ankit-mishra0/senpai-central

## Overview

##### Project type and purpose
- Senpai Central is a full-stack web application aimed at anime/manga fans.
- It provides trending anime news, top rankings, latest trailers, full articles, and a contact form.
- The frontend is a Next.js app (in `app/`), deployed on Vercel.
- The backend consists of Python scraper scripts and a YouTube-trailer fetcher, deployed on Render as microservices.
- PostgreSQL (Neon) serves as the central data store.

##### File structure
- `app/` – Next.js frontend, including React components under `components/`, page routes under directories (`news/`, `trailers/`, `contact-us/`, `article/`, etc.), Lottie animations, CSS, global layout.
- `app/api/` – Next.js API routes (`all-anime-news`, `anime-rank`, `YT-Trailers`, `full-article`, etc.). These routes fetch data from the backend services or directly from the database.
- `app/scrapper/` – Python scrapers, each in its own subfolder (`all_anime_news`, `trending_news`, `anime_list`, `full-article`); each has a scraper and a DB interface module.
- `app/YT_API/` – Python scripts for fetching YouTube trailers and writing to the database.
- Root scripts: `run_scraper.sh`, `fetch_trailers.sh` schedule or orchestrate scrapers and trailer fetchers.
- `logs/` – Output logs from scraper runs.
- `requirements.txt` – Python dependencies.
- `package.json` + `next.config.mjs` – Frontend dependencies and build config.

##### Key README insights
- Frontend deployed to Vercel.
- Backend (scraper API) deployed to Render.com.
- Database: PostgreSQL on Neon.
- Emphasis on modern UI and integrated scraping via Python.

##### Main components & interactions (to represent
A. Frontend (Next.js on Vercel)
- Pages & components render UI.
- Calls internal API routes under `app/api/` via HTTP.
B. Next.js API Layer
- Endpoints (e.g., `/api/all-anime-news`, `/api/anime-rank`, `/api/YT-Trailers`, `/api/full-article`)
- Either proxy requests to backend microservices or query the database directly.
C. Backend Microservices (Python on Render)
- Scraper Service: scheduled scrape jobs populate the DB.
- YouTube API Service: scheduled fetch of latest trailers into the DB.
- Full-article scraping endpoint returns article content on demand.
D. Database (Neon PostgreSQL)
- Tables for anime list, trending news, full articles, trailer metadata, rankings.
E. External Services
- YouTube Data API (for trailers).
- Vercel (hosting frontend).
- Render.com (hosting Python microservices).

##### Architectural patterns & design principles
- Separation of concerns: frontend/UI vs. API vs. data ingestion.
- Microservices for scrapers & API logic, scheduled independently.
- Serverless / cloud functions (Next.js API routes) as the API façade.
- Event-driven or cron-based data ingestion pipelines.
- Centralized relational store for consistency.

##### Final checklist
- Components: Frontend, API façade, Scraper Service, YT API Service, Database, External APIs.
- Labels: exact names (e.g., `/api/anime-rank`, `all_anime_news_scrapper.py`).
- Hosting: denote Vercel vs. Render vs. Neon.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend (Vercel)" 
        direction TB
        NextApp["Next.js App"]:::frontend
        Components["React UI Components"]:::frontend
        AuthPages["Authentication Pages"]:::frontend
        NewsPage["News Page"]:::frontend
        ArticlePage["Article Page"]:::frontend
        TrailersPage["Trailers Page"]:::frontend
        ContactPage["Contact Us Page"]:::frontend
        GlobalStyles["Global Styles & Layout"]:::frontend
        Animations["Animations (Lottie)"]:::frontend
    end

    %% API Facade Layer
    subgraph "API Façade (Next.js Serverless)" 
        direction TB
        API_AllNews["/api/all-anime-news"]:::api
        API_Rank["/api/anime-rank"]:::api
        API_TNews["/api/anime-t-news"]:::api
        API_YT["/api/YT-Trailers"]:::api
        API_FullArticle["/api/full-article"]:::api
        API_Send["/api/send"]:::api
    end

    %% Backend Microservices
    subgraph "Backend Microservices (Render)" 
        direction TB
        Scrape_AllAnime["All Anime News Scraper"]:::backend
        Scrape_Trending["Trending News Scraper"]:::backend
        Scrape_List["Anime List Scraper"]:::backend
        Scrape_Article["Full Article Scraper"]:::backend
        YT_Service["YouTube Trailer Fetcher"]:::backend
        Orchestration["Cron / CI Orchestration"]:::external
    end

    %% Database
    subgraph "Database (Neon PostgreSQL)"
        direction TB
        Database["PostgreSQL"]:::db
    end

    %% External Services
    subgraph "External Services"
        direction TB
        YouTubeAPI["YouTube Data API"]:::external
    end

    %% Connections
    Orchestration -->|"run_scraper.sh / fetch_trailers.sh"| Scrape_AllAnime
    Orchestration --> Scrape_Trending
    Orchestration --> Scrape_List
    Orchestration --> Scrape_Article
    Orchestration --> YT_Service

    Scrape_AllAnime -->|"write"| Database
    Scrape_Trending -->|"write"| Database
    Scrape_List -->|"write"| Database
    Scrape_Article -->|"write"| Database
    YT_Service -->|"write"| Database
    YT_Service -->|"fetch"| YouTubeAPI

    NextApp -->|"renders UI"| Components
    NextApp --> AuthPages
    NextApp --> NewsPage
    NextApp --> ArticlePage
    NextApp --> TrailersPage
    NextApp --> ContactPage
    NextApp --> GlobalStyles
    NextApp --> Animations

    NextApp -->|"HTTP fetch"| API_AllNews
    NextApp --> API_Rank
    NextApp --> API_TNews
    NextApp --> API_YT
    NextApp --> API_FullArticle
    NextApp --> API_Send

    API_AllNews -->|"query/write"| Database
    API_Rank --> Database
    API_TNews --> Database
    API_YT --> YT_Service
    API_FullArticle --> Scrape_Article
    API_Send --> Database

    %% Click Events - Frontend
    click NextApp "https://github.com/ankit-mishra0/senpai-central/tree/main/app/"
    click Components "https://github.com/ankit-mishra0/senpai-central/tree/main/app/components/"
    click AuthPages "https://github.com/ankit-mishra0/senpai-central/tree/main/app/_auth/"
    click NewsPage "https://github.com/ankit-mishra0/senpai-central/blob/main/app/news/page.js"
    click Components "https://github.com/ankit-mishra0/senpai-central/blob/main/app/news/components/AllNews.jsx"
    click ArticlePage "https://github.com/ankit-mishra0/senpai-central/blob/main/app/article/page.js"
    click ArticlePage "https://github.com/ankit-mishra0/senpai-central/blob/main/app/article/components/FullNews.jsx"
    click ArticlePage "https://github.com/ankit-mishra0/senpai-central/blob/main/app/article/components/FullNews.css"
    click TrailersPage "https://github.com/ankit-mishra0/senpai-central/blob/main/app/trailers/page.js"
    click TrailersPage "https://github.com/ankit-mishra0/senpai-central/blob/main/app/trailers/component/AllTrailers.jsx"
    click ContactPage "https://github.com/ankit-mishra0/senpai-central/blob/main/app/contact-us/page.js"
    click ContactPage "https://github.com/ankit-mishra0/senpai-central/blob/main/app/contact-us/components/ContactUs.jsx"
    click ContactPage "https://github.com/ankit-mishra0/senpai-central/blob/main/app/contact-us/components/ContactUs.css"
    click GlobalStyles "https://github.com/ankit-mishra0/senpai-central/blob/main/app/globals.css"
    click GlobalStyles "https://github.com/ankit-mishra0/senpai-central/blob/main/app/layout.js"
    click Animations "https://github.com/ankit-mishra0/senpai-central/tree/main/app/animations/"

    %% Click Events - API Façade
    click API_AllNews "https://github.com/ankit-mishra0/senpai-central/blob/main/app/api/all-anime-news/route.js"
    click API_Rank "https://github.com/ankit-mishra0/senpai-central/blob/main/app/api/anime-rank/route.js"
    click API_TNews "https://github.com/ankit-mishra0/senpai-central/blob/main/app/api/anime-t-news/route.js"
    click API_YT "https://github.com/ankit-mishra0/senpai-central/blob/main/app/api/YT-Trailers/route.js"
    click API_FullArticle "https://github.com/ankit-mishra0/senpai-central/blob/main/app/api/full-article/route.js"
    click API_Send "https://github.com/ankit-mishra0/senpai-central/blob/main/app/api/send/route.js"

    %% Click Events - Scraper Services
    click Scrape_AllAnime "https://github.com/ankit-mishra0/senpai-central/blob/main/app/scrapper/all_anime_news/all_anime_news_scrapper.py"
    click Scrape_AllAnime "https://github.com/ankit-mishra0/senpai-central/blob/main/app/scrapper/all_anime_news/all_anime_news_db.py"
    click Scrape_Trending "https://github.com/ankit-mishra0/senpai-central/blob/main/app/scrapper/trending_news/trendingnews-scrap.py"
    click Scrape_Trending "https://github.com/ankit-mishra0/senpai-central/blob/main/app/scrapper/trending_news/db.py"
    click Scrape_List "https://github.com/ankit-mishra0/senpai-central/blob/main/app/scrapper/anime_list/anime_list_scrapper.py"
    click Scrape_List "https://github.com/ankit-mishra0/senpai-central/blob/main/app/scrapper/anime_list/db_anime_list.py"
    click Scrape_Article "https://github.com/ankit-mishra0/senpai-central/blob/main/app/scrapper/full-article/full_article_scrap.py"
    click Scrape_Article "https://github.com/ankit-mishra0/senpai-central/blob/main/app/scrapper/full-article/full_article_db.py"
    click YT_Service "https://github.com/ankit-mishra0/senpai-central/blob/main/app/YT_API/anime_trailers.py"
    click YT_Service "https://github.com/ankit-mishra0/senpai-central/blob/main/app/YT_API/anime_trailersDB.py"
    click Orchestration "https://github.com/ankit-mishra0/senpai-central/blob/main/run_scraper.sh"
    click Orchestration "https://github.com/ankit-mishra0/senpai-central/blob/main/fetch_trailers.sh"
    click Database "https://github.com/ankit-mishra0/senpai-central/blob/main/requirements.txt"

    %% Configuration Files
    click NextApp "https://github.com/ankit-mishra0/senpai-central/blob/main/package.json"
    click NextApp "https://github.com/ankit-mishra0/senpai-central/blob/main/next.config.mjs"
    click NextApp "https://github.com/ankit-mishra0/senpai-central/blob/main/jsconfig.json"

    %% Styles
    classDef frontend fill:#D0E6FF,stroke:#007ACC,stroke-width:1px;
    classDef api fill:#FFE5CC,stroke:#FF9900,stroke-width:1px;
    classDef backend fill:#E2F0D9,stroke:#33A02C,stroke-width:1px;
    classDef db fill:#E6E0F8,stroke:#7B1FA2,stroke-width:1px;
    classDef external fill:#F5F5F5,stroke:#666666,stroke-width:1px;
```
