# tushitgrg/sushinime architecture

> Architecture diagram of the GitHub repository tushitgrg/sushinime, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tushitgrg/sushinime
- Repository: https://github.com/tushitgrg/sushinime

## Overview

##### Project Type & Purpose
- Sushinime is a full-stack web application focused on offering an ad-free anime streaming experience with features such as user authentication, custom watch history, personalized anime lists, and a responsive and fast UI.
- The tech stack comprises Next.js (for both the client and server via its app directory and API routes), Postgres (managed with Prisma), and Redis for caching.

##### Analyzing the File Structure
- The top-level directories and files (e.g., app, components, hooks, lib, public) clearly separate the application’s UI (pages, dynamic routes), business logic, API routes, and utility functions.
- The “app” folder shows the dynamic routing design with nested directories for genres, watch, trending, recently-updated, etc. This indicates the use of Next.js’ new routing system (file-based routing).
- The “lib” folder contains modules that interface with external systems, like database (Prisma), Redis caching, and fetching utilities.
- The “components” folder is well-organized into UI components (anime cards, player components, input forms, etc.) and even testing components that may mimic production functionality.

##### Insights from the README
- The README states the platform is “ad free” and is designed to offer a seamless viewing experience.
- It explicitly mentions tech stack components: Next.js for the frontend and server-side logic, Postgres as the primary database (managed with Prisma), and Redis for caching.
- There’s also mention of environment variables (for Redis, Google OAuth through NextAuth, and a consumet API endpoint) which reinforces the backend interactions.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        FE1["Next.js Frontend (Pages & Routes)"]:::frontend
        FE2["Reusable UI Components"]:::frontend
    end

    %% Backend API
    subgraph "Backend API"
        BE1["Auth Service (NextAuth)"]:::backend
        BE2["Comments API"]:::backend
        BE3["History API"]:::backend
        BE4["Media API"]:::backend
        BE5["MyList API"]:::backend
        BE6["Proxy API"]:::backend
    end

    %% Data Stores
    subgraph "Data Stores"
        DB["Postgres Database (via Prisma)"]:::database
        RC["Redis Cache"]:::cache
    end

    %% External Services
    subgraph "External Services"
        EX["External Consumet API"]:::external
    end

    %% User Interactions
    U["User (Viewer)"]:::frontend

    %% Arrows from User to Frontend
    U -->|"interacts"| FE1
    U -->|"interacts"| FE2

    %% Frontend calling Backend API endpoints
    FE1 -->|"calls"| BE1
    FE1 -->|"calls"| BE2
    FE1 -->|"calls"| BE3
    FE1 -->|"calls"| BE4
    FE1 -->|"calls"| BE5
    FE1 -->|"calls"| BE6

    FE2 -->|"calls"| BE1

    %% Backend API interactions with Data Stores and External API
    BE1 -->|"uses"| DB
    BE1 -->|"caches"| RC

    BE2 -->|"reads/writes"| DB

    BE3 -->|"reads/writes"| DB

    BE4 -->|"reads/writes"| DB
    BE4 -->|"caches"| RC
    BE4 -->|"fetches"| EX

    BE5 -->|"reads/writes"| DB
    BE5 -->|"caches"| RC

    BE6 -->|"streams"| EX

    %% Click Events
    click FE1 "https://github.com/tushitgrg/sushinime/tree/main/app/(allroutes)"
    click FE2 "https://github.com/tushitgrg/sushinime/tree/main/components"
    click BE1 "https://github.com/tushitgrg/sushinime/blob/main/app/api/auth/[...nextauth]/route.ts"
    click BE2 "https://github.com/tushitgrg/sushinime/tree/main/app/api"
    click BE3 "https://github.com/tushitgrg/sushinime/tree/main/app/api"
    click BE4 "https://github.com/tushitgrg/sushinime/tree/main/app/api"
    click BE5 "https://github.com/tushitgrg/sushinime/tree/main/app/api"
    click BE6 "https://github.com/tushitgrg/sushinime/tree/main/app/api"
    click DB "https://github.com/tushitgrg/sushinime/blob/main/lib/prisma.ts"
    click RC "https://github.com/tushitgrg/sushinime/blob/main/lib/redis.ts"
    click EX "https://github.com/tushitgrg/sushinime/blob/main/lib/fetchdata.ts"

    %% Styles
    classDef frontend fill:#a6cee3,stroke:#1f78b4,stroke-width:2px;
    classDef backend fill:#b2df8a,stroke:#33a02c,stroke-width:2px;
    classDef database fill:#fdbf6f,stroke:#ff7f00,stroke-width:2px;
    classDef cache fill:#ccebc5,stroke:#006d2c,stroke-width:2px;
    classDef external fill:#fbb4ae,stroke:#e31a1c,stroke-width:2px;
```
