# suzeai/be_fe_ltw architecture

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

- Interactive diagram: https://gitdiagram.com/suzeai/be_fe_ltw
- Repository: https://github.com/suzeai/be_fe_ltw

## Overview

##### Project type and purpose
- This is a full-stack web application:
- Frontend (“fe” folder) built with React (create-react-app)
- Backend (“be” folder) built with Node.js/Express
- Persistence via a database (likely MongoDB given the “photoModel.js” and schema files)
- External service integration with Cloudinary for image storage
- JWT-based authentication

##### File structure
- Top-level separation: “be” (backend) and “fe” (frontend)
- Backend (“be”):
- config/ – middleware and third-party configs (auth, Cloudinary, error handling)
- controller/ – request handlers for photos and users
- db/ – connection, data loading script, models, and local “images” folder for seeding
- model/ – API response wrapper
- routes/ – Express routers for Admin, Photo, User
- index.js – Express app setup and server start
- Frontend (“fe”):
- public/ – host page and manifest
- src/ – React components, global CSS, custom Axios instance for API calls
- components/ – feature folders (Home, LoginRegister, PhotoDetail, TopBar, UploadPhoto, UserComments, UserDetail, UserList, UserPhotos)
- Deployment/config files: .env in both layers, package.json, and gitignored files

##### Extract additional insights from README
- Instructions to install and run backend and frontend
- Screenshots for key views: home, profile, comments

##### Detail
– Capture all controllers and routers as separate nodes
– Show middleware (JWT auth, error handling) as filters on the API layer
– Include the custom axiosCustom instance in the Frontend zone
– Highlight environment variables (.env) feeding into both Frontend and Backend

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend"
        ReactFrontend["React Frontend (SPA)"]:::ui
        Axios["Axios Custom Client"]:::ui
        subgraph "UI Components"
            Home["Home Component"]:::ui
            Login["Login/Register Component"]:::ui
            PhotoDetail["PhotoDetail Component"]:::ui
            TopBar["TopBar Component"]:::ui
            Upload["UploadPhoto Component"]:::ui
            Comments["UserComments Component"]:::ui
            UserDetail["UserDetail Component"]:::ui
            UserList["UserList Component"]:::ui
            UserPhotos["UserPhotos Component"]:::ui
        end
        EnvFE[".env"]:::external
    end

    subgraph "Backend"
        Index["Express App (index.js)"]:::api
        subgraph "Middleware"
            Auth["JWT Auth Middleware"]:::api
            Error["Error Handling Middleware"]:::api
        end
        subgraph "Config"
            JWTcfg["JWT Config"]:::api
            CloudCfg["Cloudinary Config"]:::api
        end
        subgraph "API Layer"
            AdminR["Admin Router"]:::api
            PhotoR["Photo Router"]:::api
            UserR["User Router"]:::api
        end
        subgraph "Controllers"
            PhotoC["Photo Controller"]:::api
            UserC["User Controller"]:::api
        end
        subgraph "Services/Models"
            APIRes["APIResponse Utility"]:::api
        end
        subgraph "Database Layer"
            DBConn["DB Connection (dbConnect)"]:::persistence
            DBLoad["DB Load Script"]:::persistence
            PhotoM["Photo Model"]:::persistence
            UserM["User Model"]:::persistence
        end
        EnvBE[".env"]:::external
    end

    Mongo["MongoDB"]:::external
    Cloud["Cloudinary"]:::external

    ReactFrontend --> Axios
    Axios -->|"REST API calls"| Index
    EnvFE --> ReactFrontend

    Index --> Auth
    Index --> Error
    EnvBE --> Index
    EnvBE --> Auth
    EnvBE --> JWTcfg
    EnvBE --> CloudCfg

    Index --> AdminR
    Index --> PhotoR
    Index --> UserR

    Auth --> JWTcfg

    AdminR --> PhotoC
    AdminR --> UserC
    PhotoR --> PhotoC
    UserR --> UserC

    PhotoC --> APIRes
    UserC --> APIRes

    PhotoC --> PhotoM
    UserC --> UserM
    PhotoM --> DBConn
    UserM --> DBConn
    DBLoad --> DBConn
    DBConn --> Mongo

    PhotoC --> CloudCfg
    CloudCfg --> Cloud

    classDef ui fill:#ADD8E6,stroke:#000
    classDef api fill:#90EE90,stroke:#000
    classDef persistence fill:#FFA500,stroke:#000
    classDef external fill:#D8BFD8,stroke:#000

    click ReactFrontend "https://github.com/suzeai/be_fe_ltw/tree/master/fe/src"
    click Axios "https://github.com/suzeai/be_fe_ltw/blob/master/fe/src/axiosCustom.js"
    click Home "https://github.com/suzeai/be_fe_ltw/blob/master/fe/src/components/Home/index.jsx"
    click Login "https://github.com/suzeai/be_fe_ltw/blob/master/fe/src/components/LoginRegister/index.jsx"
    click PhotoDetail "https://github.com/suzeai/be_fe_ltw/blob/master/fe/src/components/PhotoDetail/index.jsx"
    click TopBar "https://github.com/suzeai/be_fe_ltw/blob/master/fe/src/components/TopBar/index.jsx"
    click Upload "https://github.com/suzeai/be_fe_ltw/blob/master/fe/src/components/UploadPhoto/index.jsx"
    click Comments "https://github.com/suzeai/be_fe_ltw/blob/master/fe/src/components/UserComments/index.jsx"
    click UserDetail "https://github.com/suzeai/be_fe_ltw/blob/master/fe/src/components/UserDetail/index.jsx"
    click UserList "https://github.com/suzeai/be_fe_ltw/blob/master/fe/src/components/UserList/index.jsx"
    click UserPhotos "https://github.com/suzeai/be_fe_ltw/blob/master/fe/src/components/UserPhotos/index.jsx"
    click Index "https://github.com/suzeai/be_fe_ltw/blob/master/be/index.js"
    click Auth "https://github.com/suzeai/be_fe_ltw/blob/master/be/config/auth.middleware.js"
    click JWTcfg "https://github.com/suzeai/be_fe_ltw/blob/master/be/config/jwt.config.js"
    click CloudCfg "https://github.com/suzeai/be_fe_ltw/blob/master/be/config/cloudinary.config.js"
    click Error "https://github.com/suzeai/be_fe_ltw/blob/master/be/config/errorMiddleware.js"
    click PhotoC "https://github.com/suzeai/be_fe_ltw/blob/master/be/controller/photo.controller.js"
    click UserC "https://github.com/suzeai/be_fe_ltw/blob/master/be/controller/user.controller.js"
    click AdminR "https://github.com/suzeai/be_fe_ltw/blob/master/be/routes/AdminRouter.js"
    click PhotoR "https://github.com/suzeai/be_fe_ltw/blob/master/be/routes/PhotoRouter.js"
    click UserR "https://github.com/suzeai/be_fe_ltw/blob/master/be/routes/UserRouter.js"
    click DBConn "https://github.com/suzeai/be_fe_ltw/blob/master/be/db/dbConnect.js"
    click DBLoad "https://github.com/suzeai/be_fe_ltw/blob/master/be/db/dbLoad.js"
    click PhotoM "https://github.com/suzeai/be_fe_ltw/blob/master/be/db/photoModel.js"
    click UserM "https://github.com/suzeai/be_fe_ltw/blob/master/be/db/userModel.js"
    click APIRes "https://github.com/suzeai/be_fe_ltw/blob/master/be/model/apiresponse.js"
```
