# mahbubk/photo-gallery architecture

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

- Interactive diagram: https://gitdiagram.com/mahbubk/photo-gallery
- Repository: https://github.com/mahbubk/photo-gallery

## Overview

##### Project Type and Purpose
- This is a single-page React application bootstrapped with Create React App.
- It uses Redux for client-side state management and a simple JSON Server (in the `SERVER` folder) as a mock backend.

##### File Structure
- Top-level:
- `public/` – static assets and HTML template for the React app.
- `src/` – React source code, CSS, Redux logic, tests, and entry point (`index.js`).
- `SERVER/` – holds `db.json` (the mock “database”) and a small `public/images` directory for static images served by the JSON server.
- Inside `src/`:
- `Components/` – subdivided into `Auth`, `Header`, `Body`, `Footer`.
- `redux/` – action types, action creators (including auth), store configuration, base URL constants, and reducer(s).
- Configuration and scripts in `package.json` coordinate running both the React dev server and JSON server.

##### Key Insights from the README
- Standard Create React App commands (`npm start`, `npm run build`, etc.)

a. Client Side (React/Redux)
- Browser / React Dev Server (port 3000)
- React Application:
- UI Components (Header, Body, Footer, Auth)
- Redux Store & Middleware
- Action Creators & Reducers
- Static assets served from `public/` (index.html, manifest, CSS)
b. Server Side (Mock JSON Server)
- JSON Server (port 3001 or similar)
- `db.json` file as the data store
- Static images under `SERVER/public/images`
c. External (if any in real deployment)
- Replace JSON Server with a real REST API / Database

##### Relationships and Interactions
- User interacts with the React UI → dispatches Redux actions.
- Redux middleware triggers HTTP calls to the JSON Server.
- JSON Server reads/writes to `db.json` and serves image assets.
- Responses are fed back into Redux reducers → React re-renders.

##### Architectural Patterns and Design Principles
- Component-based UI (React).
- Unidirectional data flow (Redux).
- Separation of concerns:
- Presentation (Components)
- State management (Redux store, action creators, types)
- Data persistence (JSON Server).

##### Relevant Technologies & Frameworks
- React, ReactDOM
- Redux (store, reducers, actions)
- Create React App toolchain (Webpack, Babel)
- JSON Server for mock REST API
- Fetch or axios (in actionCreators) for HTTP requests

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Browser"]:::runtime
    B["React Dev Server (port 3000)"]:::runtime
    A --> B

    subgraph "React Application"
      direction TB
      IDX["src/index.js"]:::entry
      APP["src/App.js"]:::component
      IDX --> APP

      subgraph "UI Components"
        direction TB

        subgraph "Auth"
          direction TB
          Login["Login Component"]:::ui
          Logout["Logout Component"]:::ui
        end

        subgraph "Header"
          direction TB
          HeaderComp["Header Layout"]:::ui
          HeaderCSS["Header Styles"]:::ui
          Dropdown["Header Dropdown Menu"]:::ui
        end

        subgraph "Body"
          direction TB
          Animal["Animal View"]:::ui
          Nature["Nature View"]:::ui
          Tech["Tech View"]:::ui
          Photo["Photo Listing"]:::ui
          PhotoItem["Photo Item"]:::ui
          PhotoDetail["Photo Detail"]:::ui
          LoadComments["Comment Loader"]:::ui
          CommentForm["Comment Form"]:::ui
          Loading["Loading Indicator"]:::ui
        end

        FooterComp["Footer Layout"]:::ui
        MainWrapper["Main Layout Wrapper"]:::component
      end

      APP --> Login
      APP --> Logout
      APP --> HeaderComp
      APP --> HeaderCSS
      APP --> Dropdown
      APP --> Animal
      APP --> Nature
      APP --> Tech
      APP --> Photo
      APP --> PhotoItem
      APP --> PhotoDetail
      APP --> LoadComments
      APP --> CommentForm
      APP --> Loading
      APP --> FooterComp
      APP --> MainWrapper

      subgraph "Redux State Management"
        direction TB
        STORE["Store Configuration"]:::redux
        REDUCER["Root Reducer"]:::redux
        ACTIONT["Action Types"]:::redux
        AC["General Action Creators"]:::redux
        AUTHAC["Auth Action Creators"]:::redux
        BASE["API Base URLs"]:::redux

        STORE --> REDUCER
        STORE --> ACTIONT
        STORE --> AC
        STORE --> AUTHAC
        AC --> BASE
      end

      Login --> STORE
      Logout --> STORE
      HeaderComp --> STORE
      MainWrapper --> STORE
    end

    subgraph "Mock Backend (JSON Server @3001)"
      direction TB
      API["JSON Server"]:::api
      DB["Mock Database (db.json)"]:::db
      IMG["Server Static Images"]:::db
      API --> DB
      API --> IMG
    end

    STORE -->|"HTTP Requests"| API
    API -->|"HTTP Responses"| STORE
    STORE --> APP

    classDef ui fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef redux fill:#FFE4B5,stroke:#000,stroke-width:1px
    classDef api fill:#FFA500,stroke:#000,stroke-width:1px
    classDef db fill:#98FB98,stroke:#000,stroke-width:1px
    classDef runtime fill:#D3D3D3,stroke:#000,stroke-width:1px
    classDef entry fill:#E6E6FA,stroke:#000,stroke-width:1px
    classDef component fill:#AFEEEE,stroke:#000,stroke-width:1px

    click IDX "https://github.com/mahbubk/photo-gallery/blob/main/src/index.js"
    click APP "https://github.com/mahbubk/photo-gallery/blob/main/src/App.js"
    click Login "https://github.com/mahbubk/photo-gallery/blob/main/src/Components/Auth/Auth.js"
    click Logout "https://github.com/mahbubk/photo-gallery/blob/main/src/Components/Auth/Logout.js"
    click HeaderComp "https://github.com/mahbubk/photo-gallery/blob/main/src/Components/Header/Header.js"
    click HeaderCSS "https://github.com/mahbubk/photo-gallery/blob/main/src/Components/Header/Header.css"
    click Dropdown "https://github.com/mahbubk/photo-gallery/blob/main/src/Components/Header/Dropdown.js"
    click Animal "https://github.com/mahbubk/photo-gallery/blob/main/src/Components/Body/Animal.js"
    click Nature "https://github.com/mahbubk/photo-gallery/blob/main/src/Components/Body/Nature.js"
    click Tech "https://github.com/mahbubk/photo-gallery/blob/main/src/Components/Body/Tech.js"
    click Photo "https://github.com/mahbubk/photo-gallery/blob/main/src/Components/Body/Photo.js"
    click PhotoItem "https://github.com/mahbubk/photo-gallery/blob/main/src/Components/Body/PhotoItem.js"
    click PhotoDetail "https://github.com/mahbubk/photo-gallery/blob/main/src/Components/Body/PhotoDetail.js"
    click LoadComments "https://github.com/mahbubk/photo-gallery/blob/main/src/Components/Body/LoadComments.js"
    click CommentForm "https://github.com/mahbubk/photo-gallery/blob/main/src/Components/Body/CommentForm.js"
    click Loading "https://github.com/mahbubk/photo-gallery/blob/main/src/Components/Body/Loading.js"
    click FooterComp "https://github.com/mahbubk/photo-gallery/blob/main/src/Components/Footer/footer.js"
    click MainWrapper "https://github.com/mahbubk/photo-gallery/blob/main/src/Components/Main.js"
    click STORE "https://github.com/mahbubk/photo-gallery/blob/main/src/redux/store.js"
    click REDUCER "https://github.com/mahbubk/photo-gallery/blob/main/src/redux/reducer.js"
    click ACTIONT "https://github.com/mahbubk/photo-gallery/blob/main/src/redux/actionTypes.js"
    click AC "https://github.com/mahbubk/photo-gallery/blob/main/src/redux/actionCreators.js"
    click AUTHAC "https://github.com/mahbubk/photo-gallery/blob/main/src/redux/authActionCreators.js"
    click BASE "https://github.com/mahbubk/photo-gallery/blob/main/src/redux/baseUrls.js"
    click DB "https://github.com/mahbubk/photo-gallery/blob/main/SERVER/db.json"
    click IMG "https://github.com/mahbubk/photo-gallery/tree/main/SERVER/public/images"
    click IDX "https://github.com/mahbubk/photo-gallery/blob/main/public/index.html"
    click IDX "https://github.com/mahbubk/photo-gallery/blob/main/public/manifest.json"
    click IDX "https://github.com/mahbubk/photo-gallery/blob/main/public/robots.txt"
    click IDX "https://github.com/mahbubk/photo-gallery/blob/main/package.json"
    click IDX "https://github.com/mahbubk/photo-gallery/blob/main/README.md"
```
