# seulnan/movie_server architecture

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

- Interactive diagram: https://gitdiagram.com/seulnan/movie_server
- Repository: https://github.com/seulnan/movie_server

## Overview

##### Project type and purpose
- This is a RESTful backend service for a movie page, built in Node.js (plain Express/Nest-style structure) that exposes endpoints for “works” (movies) and handles file uploads to Amazon S3.
- Purpose: Provide mentors and mentees with a live API to fetch, create, update movie data, and upload related assets (e.g., images) instead of static JSON.

##### File structure
- server.js & app.js
- server.js – entry point that starts the HTTP server
- app.js – configures Express, middleware, routes
- config/
- db.js – database connection logic (likely MongoDB or another datastore)
- routes/
- worksRouter.js – routes for CRUD operations on “works”
- upload.js – routes handling file upload requests
- controllers/
- worksController.js – business logic for processing “works” requests
- models/
- work.js – data schema/model definition
- utils/
- test-s3.js – helper for validating S3 connectivity
- upload-data.js – utility to prepare and send files to S3
- package.json & package-lock.json – dependencies (Express, AWS SDK, database ORM)
- .gitignore/.DS_Store – housekeeping

##### README for additional insights
- Although it lists NestJS, the code structure follows Express; in either case the core is a JavaScript-based HTTP API.
- External dependency: Amazon S3 for asset storage.
- No built-in frontend here; expects consumer (React FE) to call these endpoints.

a. Main components
- Client (React FE)
- HTTP API Server (Node.js + Express)
- Database (e.g., MongoDB)
- Amazon S3 bucket
- Utilities/Helpers (S3 uploader and test scripts)
b. Relationships & interactions
1. Client ► HTTP API Server – sends REST requests (GET/POST/PUT/DELETE)
2. Server ► Database – reads/writes work records
3. Server ► Amazon S3 – uploads/retrieves file assets
4. Server uses utils/test-s3 to verify connectivity at startup
5. Controllers orchestrate calls: routes → controllers → models/utils → external services
c. Architectural patterns/principles
- MVC-lite: Routes (Router) → Controllers → Models (schema + DB adapter)
- Single-process, monolithic service
- Separation of concerns: config, routes, controllers, models, utils
- Externalized configuration (config/db.js)
d. Key technologies
- Node.js / Express
- AWS SDK (S3)
- Database driver or ORM (e.g., Mongoose if MongoDB)
- JavaScript modules (ES5/ES6)

##### Detail
- Routes
- Controllers
- Models
- Utils
- External dependency (DB, S3) is represented

## Diagram (Mermaid)

```mermaid
flowchart TB
    Client["React Frontend"]:::client

    subgraph "Express API Server"
        entry["server.js (Entry Point)"]:::server
        app["app.js (Express Config)"]:::server
        dbcfg["config/db.js (DB Config)"]:::config
        subgraph "Routes"
            worksRouter["worksRouter.js (Works Routes)"]:::routes
            uploadRouter["upload.js (Upload Routes)"]:::routes
        end
        subgraph "Controllers"
            worksCtrl["worksController.js (Works Controller)"]:::controller
        end
        subgraph "Models"
            workModel["work.js (Work Model)"]:::model
        end
        subgraph "Utils"
            testS3["test-s3.js (S3 Connectivity Test)"]:::util
            uploadUtil["upload-data.js (S3 Upload Helper)"]:::util
        end
        pkg["package.json (Dependencies)"]:::config
    end

    db["Database (MongoDB)"]:::database
    s3["Amazon S3"]:::storage

    Client -->|"HTTP Requests"| entry
    entry -->|"initialize Express"| app
    app -->|"initialize DB"| dbcfg
    dbcfg -->|"connects to DB"| db
    app -->|"use Works Routes"| worksRouter
    app -->|"use Upload Routes"| uploadRouter
    worksRouter -->|"calls Works Controller"| worksCtrl
    uploadRouter -->|"calls Upload Helper"| uploadUtil
    worksCtrl -->|"CRUD Operations"| workModel
    workModel -->|"DB Driver"| db
    app -->|"run S3 Test on Startup"| testS3
    testS3 -.->|"verifies connectivity"| s3
    uploadUtil -->|"AWS SDK Calls"| s3

    click entry "https://github.com/seulnan/movie_server/blob/main/server.js"
    click app "https://github.com/seulnan/movie_server/blob/main/app.js"
    click dbcfg "https://github.com/seulnan/movie_server/blob/main/config/db.js"
    click worksRouter "https://github.com/seulnan/movie_server/blob/main/routes/worksRouter.js"
    click uploadRouter "https://github.com/seulnan/movie_server/blob/main/routes/upload.js"
    click worksCtrl "https://github.com/seulnan/movie_server/blob/main/controllers/worksController.js"
    click workModel "https://github.com/seulnan/movie_server/blob/main/models/work.js"
    click testS3 "https://github.com/seulnan/movie_server/blob/main/utils/test-s3.js"
    click uploadUtil "https://github.com/seulnan/movie_server/blob/main/utils/upload-data.js"
    click pkg "https://github.com/seulnan/movie_server/blob/main/package.json"

    classDef client fill:#D0E6A5,stroke:#333,stroke-width:1px
    classDef server fill:#86BBD8,stroke:#333,stroke-width:1px
    classDef config fill:#FFD97D,stroke:#333,stroke-width:1px
    classDef routes fill:#C487FC,stroke:#333,stroke-width:1px
    classDef controller fill:#FC6C85,stroke:#333,stroke-width:1px
    classDef model fill:#89DA59,stroke:#333,stroke-width:1px
    classDef util fill:#FDE74C,stroke:#333,stroke-width:1px
    classDef database fill:#90D8D8,stroke:#333,stroke-width:1px
    classDef storage fill:#A0DDE9,stroke:#333,stroke-width:1px
```
