# san-kalp/moview-recommendation-system-using-mern architecture

> Architecture diagram of the GitHub repository san-kalp/moview-recommendation-system-using-mern, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/san-kalp/moview-recommendation-system-using-mern
- Repository: https://github.com/san-kalp/moview-recommendation-system-using-mern

## Overview

##### Project type and purpose
- This is a backend RESTful API for a “Movie Review Application” (like IMDB).
- Built with Node.js and Express, following an MVC-style pattern:
- Models handle data persistence
- Controllers process requests and orchestrate business logic
- Routes map HTTP endpoints to controllers
- It supports user authentication, movie CRUD, reviews, ratings, and comments.

##### File structure
- Top-level files
- server.js – bootstraps the Express app, loads middleware and routes
- package.json / package-lock.json – dependencies and scripts
- Directories
- routes/ – Express route definitions (movieRoutes, reviewRoutes, userRoutes)
- controller/ – controllers for movies, reviews, users
- models/ – ORM or database models + database connection (database.js)
- middlewares/ – middleware (e.g., auth.js for authentication)
- tmp/ – temporary files (not directly part of core architecture)
- No frontend folder; this is a pure backend service.

##### Key insights from README
- The app’s focus: users can sign up, log in, post reviews/ratings/comments on movies.
- Team project with typical REST API features (authentication, CRUD operations).

## Diagram (Mermaid)

```mermaid
graph TD
    Client["Client (Web/Mobile)"]:::client
    Client -->|"HTTP Request"| Server

    subgraph "API Gateway / Express Server"
        Server["Express Server"]:::gateway
    end

    Server -->|"load & execute"| GlobalMiddleware["Global Middleware (body parser, logging)"]:::middleware

    subgraph "Middleware Layer"
        Auth["Auth Middleware"]:::middleware
    end

    GlobalMiddleware --> Auth
    Auth -->|"auth check"| RoutingLayer

    subgraph "Routing Layer"
        direction TB
        MovieRoutes["Movie Routes"]:::routing
        ReviewRoutes["Review Routes"]:::routing
        UserRoutes["User Routes"]:::routing
    end

    RoutingLayer --> MovieRoutes
    RoutingLayer --> ReviewRoutes
    RoutingLayer --> UserRoutes

    subgraph "Controller Layer"
        direction TB
        MovieController["Movie Controller"]:::controller
        ReviewController["Review Controller"]:::controller
        UserController["User Controller"]:::controller
    end

    MovieRoutes -->|"POST/GET /movies"| MovieController
    ReviewRoutes -->|"POST/GET /reviews"| ReviewController
    UserRoutes -->|"POST/GET /users"| UserController

    subgraph "Model / Data Access Layer"
        direction TB
        DatabaseConnection["Database Connection"]:::model
        MovieModel["Movie Model"]:::model
        UserModel["User Model"]:::model
        ReviewModel["Review Model"]:::model
        RatingModel["Rating Model"]:::model
        CommentsModel["Comments Model"]:::model
    end

    MovieController -->|"invoke CRUD"| MovieModel
    ReviewController -->|"invoke CRUD"| ReviewModel
    UserController -->|"invoke CRUD"| UserModel

    MovieModel --> DatabaseConnection
    ReviewModel --> DatabaseConnection
    UserModel --> DatabaseConnection
    RatingModel --> DatabaseConnection
    CommentsModel --> DatabaseConnection

    DatabaseConnection -->|"SQL/NoSQL Queries"| Database["Database"]:::db

    subgraph "External Services"
        EmailService["Email Service"]:::external
    end

    UserController -->|"send verification"| EmailService

    %% Click Events
    click Server "https://github.com/san-kalp/moview-recommendation-system-using-mern/blob/main/server.js"
    click Auth "https://github.com/san-kalp/moview-recommendation-system-using-mern/blob/main/middlewares/auth.js"
    click MovieRoutes "https://github.com/san-kalp/moview-recommendation-system-using-mern/blob/main/routes/movieRoutes.js"
    click ReviewRoutes "https://github.com/san-kalp/moview-recommendation-system-using-mern/blob/main/routes/reviewRoutes.js"
    click UserRoutes "https://github.com/san-kalp/moview-recommendation-system-using-mern/blob/main/routes/userRoutes.js"
    click MovieController "https://github.com/san-kalp/moview-recommendation-system-using-mern/blob/main/controller/movieController.js"
    click ReviewController "https://github.com/san-kalp/moview-recommendation-system-using-mern/blob/main/controller/reviewController.js"
    click UserController "https://github.com/san-kalp/moview-recommendation-system-using-mern/blob/main/controller/userController.js"
    click DatabaseConnection "https://github.com/san-kalp/moview-recommendation-system-using-mern/blob/main/models/database.js"
    click MovieModel "https://github.com/san-kalp/moview-recommendation-system-using-mern/blob/main/models/movieModel.js"
    click UserModel "https://github.com/san-kalp/moview-recommendation-system-using-mern/blob/main/models/userModel.js"
    click ReviewModel "https://github.com/san-kalp/moview-recommendation-system-using-mern/blob/main/models/reviewModel.js"
    click RatingModel "https://github.com/san-kalp/moview-recommendation-system-using-mern/blob/main/models/ratingModel.js"
    click CommentsModel "https://github.com/san-kalp/moview-recommendation-system-using-mern/blob/main/models/commentsModel.js"

    %% Styles
    classDef client fill:#f9f,stroke:#333,stroke-width:1px;
    classDef gateway fill:#bbf,stroke:#333,stroke-width:1px;
    classDef middleware fill:#f96,stroke:#333,stroke-width:1px;
    classDef routing fill:#9cf,stroke:#333,stroke-width:1px;
    classDef controller fill:#8cf,stroke:#333,stroke-width:1px;
    classDef model fill:#6c6,stroke:#333,stroke-width:1px;
    classDef db fill:#ccc,stroke:#333,stroke-width:1px;
    classDef external fill:#eee,stroke:#333,stroke-width:1px;
```
