# ygstudio-game/cinesync architecture

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

- Interactive diagram: https://gitdiagram.com/ygstudio-game/cinesync
- Repository: https://github.com/ygstudio-game/cinesync

## Overview

##### Project type and purpose
- CineSync is a full-stack cinema management system. Based on the file tree and README, we see:
- A `client` folder (likely frontend code)
- A `server` folder containing a Node.js/Express REST API
- MongoDB as the primary datastore via Mongoose
The server handles user authentication (JWT), movie listings, watchlists, reviews, etc.

##### File structure
- Top-level:
- `.env`, config files, top-level README
- `TechStorm` (could be a placeholder)
- `client` – your frontend app (see its own README)
- `server` – your backend
- Under `server`:
- `index.js` / `app.js` – Express app setup, middleware registration
- `controllers/` – business logic per resource (auth, movies, watchlist, listing)
- `routes/` – HTTP routes mapped to controllers
- `models/` – Mongoose schema definitions for Users, Movies, Playlists, Reviews, Watchlist
- `db/` – database connection logic
- `middleware/` – JWT auth guard, error handling
- `utils/` – ApiError, ApiResponse, asyncHandler wrappers

##### README for additional insights
- Confirms tech stack: Node.js, Express, MongoDB/Mongoose, REST API, JWT, Dotenv
- Emphasis on backend; the client is separate but integrates via HTTP calls

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    subgraph "Client Layer"
        direction TB
        ClientApp["Client Application"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        direction TB

        %% Configuration
        subgraph "Configuration" 
            direction TB
            Env["Environment Variables (.env)"]:::config
            PKG["Package Manifests"]:::config
        end

        %% API Gateway
        subgraph "API Gateway / Express Entry" 
            direction TB
            Index["index.js"]:::network
            App["app.js"]:::network
        end

        %% Routing Layer
        subgraph "Routing Layer"
            direction TB
            AuthRoutes["Authentication Routes"]:::network
            MoviesRoutes["Movies Routes"]:::network
            WatchlistRoutes["Watchlist Routes"]:::network
        end

        %% Middleware
        subgraph "Middleware"
            direction TB
            AuthMiddleware["Auth Middleware (JWT Guard)"]:::middleware
        end

        %% Controllers
        subgraph "Controllers"
            direction TB
            AuthController["Auth Controller"]:::logic
            MoviesController["Movies Controller"]:::logic
            ListingController["Listing Controller"]:::logic
            WatchlistController["Watchlist Controller"]:::logic
        end

        %% Models
        subgraph "Models"
            direction TB
            UserModel["User Model"]:::data
            MovieModel["Movie Model"]:::data
            PlaylistModel["Playlist Model"]:::data
            ReviewModel["Review Model"]:::data
            WatchlistModel["Watchlist Model"]:::data
        end

        %% Database Connection and DB
        subgraph "Database"
            direction TB
            DBConn["DB Connection Module"]:::network
            MongoDB["MongoDB"]:::db
        end

        %% Utilities
        subgraph "Utilities"
            direction TB
            ApiError["ApiError Class"]:::util
            ApiResponse["ApiResponse Formatter"]:::util
            AsyncHandler["Async Handler"]:::util
        end
    end

    %% Relationships
    ClientApp -->|"HTTPS Requests"| Index
    Index --> App
    App --> AuthRoutes
    App --> MoviesRoutes
    App --> WatchlistRoutes

    AuthRoutes --> AuthMiddleware
    MoviesRoutes --> AuthMiddleware
    WatchlistRoutes --> AuthMiddleware

    AuthMiddleware --> AuthController
    AuthMiddleware --> MoviesController
    AuthMiddleware --> ListingController
    AuthMiddleware --> WatchlistController

    AuthController --> UserModel
    MoviesController --> MovieModel
    ListingController --> PlaylistModel
    WatchlistController --> WatchlistModel
    ListingController --> ReviewModel

    UserModel --> DBConn
    MovieModel --> DBConn
    PlaylistModel --> DBConn
    ReviewModel --> DBConn
    WatchlistModel --> DBConn

    DBConn --> MongoDB

    AuthController --> AsyncHandler
    MoviesController --> AsyncHandler
    ListingController --> AsyncHandler
    WatchlistController --> AsyncHandler

    AuthController --> ApiResponse
    MoviesController --> ApiResponse
    ListingController --> ApiResponse
    WatchlistController --> ApiResponse

    %% Configuration usage
    Index --> Env
    App --> Env
    Index --> PKG

    %% Click Events
    click ClientApp "https://github.com/ygstudio-game/cinesync/tree/main/client/"
    click Index "https://github.com/ygstudio-game/cinesync/blob/main/server/index.js"
    click App "https://github.com/ygstudio-game/cinesync/blob/main/server/app.js"
    click AuthRoutes "https://github.com/ygstudio-game/cinesync/blob/main/server/routes/auth.Routes.js"
    click MoviesRoutes "https://github.com/ygstudio-game/cinesync/blob/main/server/routes/movies.routes.js"
    click WatchlistRoutes "https://github.com/ygstudio-game/cinesync/blob/main/server/routes/watchlist.routes.js"
    click AuthMiddleware "https://github.com/ygstudio-game/cinesync/blob/main/server/middleware/auth.middleware.js"
    click AuthController "https://github.com/ygstudio-game/cinesync/blob/main/server/controllers/auth.Controller.js"
    click MoviesController "https://github.com/ygstudio-game/cinesync/blob/main/server/controllers/movies.controller.js"
    click ListingController "https://github.com/ygstudio-game/cinesync/blob/main/server/controllers/listing.controller.js"
    click WatchlistController "https://github.com/ygstudio-game/cinesync/blob/main/server/controllers/watchlist.controller.js"
    click UserModel "https://github.com/ygstudio-game/cinesync/blob/main/server/models/User.model.js"
    click MovieModel "https://github.com/ygstudio-game/cinesync/blob/main/server/models/Movie.model.js"
    click PlaylistModel "https://github.com/ygstudio-game/cinesync/blob/main/server/models/Playlist.model.js"
    click ReviewModel "https://github.com/ygstudio-game/cinesync/blob/main/server/models/Review.model.js"
    click WatchlistModel "https://github.com/ygstudio-game/cinesync/blob/main/server/models/watchlist.model.js"
    click DBConn "https://github.com/ygstudio-game/cinesync/blob/main/server/db/index.js"
    click ApiError "https://github.com/ygstudio-game/cinesync/blob/main/server/utils/ApiError.js"
    click ApiResponse "https://github.com/ygstudio-game/cinesync/blob/main/server/utils/ApiResponse.js"
    click AsyncHandler "https://github.com/ygstudio-game/cinesync/blob/main/server/utils/asyncHandler.js"
    click Env "https://github.com/ygstudio-game/cinesync/blob/main/.env"
    click PKG "https://github.com/ygstudio-game/cinesync/blob/main/server/package.json"

    %% Styles
    classDef frontend fill:#B3CDE3,stroke:#034F84,color:#000
    classDef network fill:#C7E9B4,stroke:#2E8B57,color:#000
    classDef middleware fill:#FDE0DD,stroke:#FC4E2A,color:#000
    classDef logic fill:#FDD0A2,stroke:#E6550D,color:#000
    classDef data fill:#E2E2E2,stroke:#636363,color:#000
    classDef db fill:#FFF2AE,stroke:#BD9B60,color:#000
    classDef util fill:#D3D3D3,stroke:#696969,color:#000
    classDef config fill:#E0BBE4,stroke:#6A0DAD,color:#000
```
