# lucascccccccccc/torrentmoviesdwnld architecture

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

- Interactive diagram: https://gitdiagram.com/lucascccccccccc/torrentmoviesdwnld
- Repository: https://github.com/lucascccccccccc/torrentmoviesdwnld

## Overview

##### Project type and purpose
- This is a full-stack web application called “TorrentMoviesDwnld” that lets users search TMDb for movies, view details, download links, leave comments with ratings, and manage user accounts.
- The backend exposes a REST API (with Swagger docs) built on Bun+Elysia and Prisma, while the frontend is a Next.js+Tailwind+Shadcn client.

##### File structure
- Top-level:
- backend/ – server code, Prisma schema & migrations, Elysia routes
- frontend/ – Next.js pages, Shadcn UI components, Tailwind styles
- README.md – overall description.
- backend/src/modules – MVC-style folders for movie, review, user (controller, service, repository, schema, route).
- backend/src/middleware/auth.middleware.ts – JWT auth interceptor.
- backend/src/database/db.ts – Prisma client instantiation.
- frontend/pages – Next.js pages for index, login, register, dashboard and dynamic movie routes.
- frontend/components/ui – reusable UI primitives from Shadcn.
- external config: .env, next.config.ts, bun.lock, package.json.

##### README for additional insights
- Technology stack: Bun, Elysia, Prisma, JWT, Next.js, Tailwind, Shadcn.
- Features: search TMDb API, comments & ratings, user auth, dashboard.
- Swagger available at /swagger.
- Database: PostgreSQL.

##### Detailed capture of essential elements
- Frontend: Next.js pages, static/public asset serving, API client module.
- Backend:
- Entry point (server.ts)
- Route definitions (movie.route.ts, review.route.ts, user.route.ts)
- Middleware (auth.middleware.ts)
- Controllers → Services → Repositories
- Prisma schema and migrations
- External TMDb API integration
- Swagger documentation endpoint

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend (Blue)" 
        direction TB
        NextClient["Next.js Client"]:::frontend
        Pages["Pages (CSR/SSR Routes)"]:::frontend
        UIComponents["UI Components (Shadcn)"]:::frontend
        Styles["Tailwind & Styles"]:::frontend
        Utils["Utility Functions"]:::frontend
        Public["Static Assets / Public"]:::frontend

        NextClient --> Pages
        NextClient --> UIComponents
        NextClient --> Styles
        NextClient --> Utils
        NextClient --> Public
    end

    %% Backend Layer
    subgraph "Backend API (Green)" 
        direction TB
        API["Elysia API Server"]:::backend
        AuthMW["JWT Auth Middleware"]:::backend
        Swagger["Swagger UI (/swagger)"]:::backend

        API --> AuthMW
        API --> Swagger

        subgraph "Modules (Domain Controllers → Services → Repositories)"
            direction TB
            MovieModule["Movie Module"]:::backend
            ReviewModule["Review Module"]:::backend
            UserModule["User Module"]:::backend
        end

        API --> MovieModule
        API --> ReviewModule
        API --> UserModule
    end

    %% Data Access Layer
    subgraph "Data Access (Yellow)"
        direction TB
        PrismaClient["Prisma Client"]:::data
        PrismaSchema["Prisma Schema & Migrations"]:::data
    end

    %% Databases & External
    subgraph "Databases & External (Orange)"
        direction TB
        Postgres[(PostgreSQL)]:::data
        TMDb["TMDb External API"]:::external
    end

    %% Flows
    NextClient -->|"REST calls (JWT)"| API
    API -->|"CRUD via Prisma"| PrismaClient
    PrismaClient -->|"SQL Queries"| Postgres
    API -->|"Search Metadata"| TMDb
    NextClient -->|"View Docs"| Swagger

    %% Click Events Frontend
    click NextClient "https://github.com/lucascccccccccc/torrentmoviesdwnld/tree/main/frontend/"
    click Pages "https://github.com/lucascccccccccc/torrentmoviesdwnld/blob/main/frontend/pages/index.tsx"
    click Pages "https://github.com/lucascccccccccc/torrentmoviesdwnld/blob/main/frontend/pages/login/index.tsx"
    click Pages "https://github.com/lucascccccccccc/torrentmoviesdwnld/blob/main/frontend/pages/register/index.tsx"
    click Pages "https://github.com/lucascccccccccc/torrentmoviesdwnld/blob/main/frontend/pages/dashboard/index.tsx"
    click Pages "https://github.com/lucascccccccccc/torrentmoviesdwnld/blob/main/frontend/pages/movies/[movieId]/index.tsx"
    click UIComponents "https://github.com/lucascccccccccc/torrentmoviesdwnld/tree/main/frontend/components/ui/"
    click Styles "https://github.com/lucascccccccccc/torrentmoviesdwnld/blob/main/frontend/tailwind.config.js"
    click Styles "https://github.com/lucascccccccccc/torrentmoviesdwnld/blob/main/frontend/postcss.config.mjs"
    click Styles "https://github.com/lucascccccccccc/torrentmoviesdwnld/blob/main/frontend/styles/globals.css"
    click Utils "https://github.com/lucascccccccccc/torrentmoviesdwnld/blob/main/frontend/lib/utils.ts"
    click Public "https://github.com/lucascccccccccc/torrentmoviesdwnld/tree/main/frontend/public/"

    %% Click Events Backend
    click API "https://github.com/lucascccccccccc/torrentmoviesdwnld/blob/main/backend/src/server.ts"
    click AuthMW "https://github.com/lucascccccccccc/torrentmoviesdwnld/blob/main/backend/src/middleware/auth.middleware.ts"
    click PrismaClient "https://github.com/lucascccccccccc/torrentmoviesdwnld/blob/main/backend/src/database/db.ts"
    click PrismaSchema "https://github.com/lucascccccccccc/torrentmoviesdwnld/blob/main/backend/prisma/schema.prisma"
    click PrismaSchema "https://github.com/lucascccccccccc/torrentmoviesdwnld/tree/main/backend/prisma/migrations/20250406234826_init/"
    click PrismaSchema "https://github.com/lucascccccccccc/torrentmoviesdwnld/tree/main/backend/prisma/migrations/20250415223359_add_role/"
    click PrismaSchema "https://github.com/lucascccccccccc/torrentmoviesdwnld/tree/main/backend/prisma/migrations/20250424000927_add_reviews/"
    click MovieModule "https://github.com/lucascccccccccc/torrentmoviesdwnld/blob/main/backend/src/modules/movie/movie.controller.ts"
    click MovieModule "https://github.com/lucascccccccccc/torrentmoviesdwnld/blob/main/backend/src/modules/movie/movie.service.ts"
    click MovieModule "https://github.com/lucascccccccccc/torrentmoviesdwnld/blob/main/backend/src/modules/movie/movie.repository.ts"
    click MovieModule "https://github.com/lucascccccccccc/torrentmoviesdwnld/blob/main/backend/src/modules/movie/movie.schema.ts"
    click MovieModule "https://github.com/lucascccccccccc/torrentmoviesdwnld/blob/main/backend/src/modules/movie/movie.types.ts"
    click MovieModule "https://github.com/lucascccccccccc/torrentmoviesdwnld/blob/main/backend/src/modules/movie/movie.route.ts"
    click ReviewModule "https://github.com/lucascccccccccc/torrentmoviesdwnld/blob/main/backend/src/modules/review/review.controller.ts"
    click ReviewModule "https://github.com/lucascccccccccc/torrentmoviesdwnld/blob/main/backend/src/modules/review/review.service.ts"
    click ReviewModule "https://github.com/lucascccccccccc/torrentmoviesdwnld/blob/main/backend/src/modules/review/review.repository.ts"
    click ReviewModule "https://github.com/lucascccccccccc/torrentmoviesdwnld/blob/main/backend/src/modules/review/review.schema.ts"
    click ReviewModule "https://github.com/lucascccccccccc/torrentmoviesdwnld/blob/main/backend/src/modules/review/review.route.ts"
    click UserModule "https://github.com/lucascccccccccc/torrentmoviesdwnld/blob/main/backend/src/modules/user/user.controller.ts"
    click UserModule "https://github.com/lucascccccccccc/torrentmoviesdwnld/blob/main/backend/src/modules/user/user.service.ts"
    click UserModule "https://github.com/lucascccccccccc/torrentmoviesdwnld/blob/main/backend/src/modules/user/user.repository.ts"
    click UserModule "https://github.com/lucascccccccccc/torrentmoviesdwnld/blob/main/backend/src/modules/user/user.schema.ts"
    click UserModule "https://github.com/lucascccccccccc/torrentmoviesdwnld/blob/main/backend/src/modules/user/user.types.ts"
    click UserModule "https://github.com/lucascccccccccc/torrentmoviesdwnld/blob/main/backend/src/modules/user/user.route.ts"

    %% Styles
    classDef frontend fill:#D0E6FF,stroke:#0366d6,color:#0366d6;
    classDef backend fill:#D0FFD0,stroke:#228B22,color:#228B22;
    classDef data fill:#FFF4A3,stroke:#DAA520,color:#DAA520;
    classDef external fill:#FFD8A8,stroke:#FF8C00,color:#FF8C00;
```
