# jkarelins/real-estate-site architecture

> Architecture diagram of the GitHub repository jkarelins/real-estate-site, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jkarelins/real-estate-site
- Repository: https://github.com/jkarelins/real-estate-site

## Overview

##### Project type and purpose
- This is a React-Redux single-page application (SPA) that serves as the client for a full-stack real-estate platform.
- Its purpose is to let different user roles (guests, private users, agents, managers) browse, search, post, and manage property adverts; schedule appointments; upload images; and make payments (Stripe) via an external API server.

##### File structure
- src/
- components/ – all UI pieces organized by feature (AddNewAdvert, AdvertCard, Header, Map, Payment, etc.)
- actions/ – Redux action creators (advert, appointment, user, payment, images, seo, etc.)
- reducers/ – Redux reducers matching those domains
- store.js – configures Redux store with Redux-Thunk middleware
- sitemap/ – server-side sitemap generator for SEO
- App.jsx, index.js – entry points
- serviceWorker.js, setupTests.js – PWA and testing support
- public/ – static host files (index.html, manifest.json, robots.txt, sitemap.xml)
- configuration at root (.babelrc, package.json, Docker, CI templates)

##### README for additional insights
- The client calls a separate Express-based API Server (runs on port 4000 by default) that persists to PostgreSQL (via Docker)
- External services: Cloudinary for image storage, Stripe for payments, Leaflet for maps.
- Deployed on Heroku as a static build and communicates with the API URL.

a. Main components
- Client-side SPA (React + Redux):
- UI Components
- Redux Store (Actions → Reducers → State)
- Thunks for async API calls
- API Server (Express + Node)
- Database (PostgreSQL)
- External services: Cloudinary, Stripe, Map Tile Server (for Leaflet)
- Deployment/Hosting: Heroku (Client & Server), Docker for local dev
b. Relationships and interactions
- User → Browser → SPA → dispatches Redux Action → Redux-Thunk → HTTP request to API Server
- API Server → reads/writes PostgreSQL → returns JSON
- Image uploads: Client → Cloudinary React widget → Cloudinary CDN
- Payments: Client → Stripe Checkout/API → Stripe backend
- Rendering: Client → Leaflet fetching tiles from Map provider
- SEO: sitemap generator runs on the server (or at build time) → publishes sitemap.xml to public/
c. Architectural patterns and design principles
- Flux pattern: unidirectional data flow (Components → Actions → Reducers → Store → Components)
- Separation of concerns: UI layer vs. state management vs. network layer
- Feature-based organization of components and Redux modules
- PWA/support for offline via service worker
d. Key technologies
- React, Redux, Redux-Thunk, React-Router (implied), Babel, Parcel/Webpack
- Express, PostgreSQL, Docker
- Cloudinary, Stripe, Leaflet

##### Essential details to capture
- How file structure maps to logical modules (e.g., src/actions ↔ API calls; src/reducers ↔ state slices; src/components ↔ UI screens).
- Clearly label user roles and which parts of the UI they interact with (e.g., Manager page vs. Agent vs. Public Search).
- External API URL configuration point in the client (highlight environment variable).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User and Browser
    User[/"User"/]:::external -->|uses| Browser[/"Browser"/]:::frontend

    %% Frontend SPA
    subgraph "Client SPA (React-Redux)" 
        direction TB
        EntryIndex["index.js"]:::frontend
        EntryApp["App.jsx"]:::frontend
        ServiceWorker["serviceWorker.js"]:::frontend
        subgraph "UI Components" 
            direction TB
            Header["Header & Navigation"]:::frontend
            MapView["ViewMap.jsx"]:::frontend
            AddAdvert["AddNewAdvert.jsx"]:::frontend
            AdvertCard["AdvertCard.jsx"]:::frontend
            PaymentFlow["Payment Components"]:::frontend
            ImageGallery["Image Upload/Gallery"]:::frontend
            Appointments["Appointment Screens"]:::frontend
            RolePages["Role-specific Pages"]:::frontend
        end
        subgraph "Redux State Management"
            direction TB
            Actions["src/actions"]:::state
            Reducers["src/reducers"]:::state
            Store["store.js"]:::state
        end
    end

    %% Backend
    API["API Server (Express)"]:::backend
    SitemapGen["Sitemap Generator"]:::backend

    %% Data Layer
    Database[(PostgreSQL)]:::data

    %% External Services
    Cloudinary["Cloudinary CDN"]:::external
    Stripe["Stripe API"]:::external
    MapTiles["Map Tile Server"]:::external

    %% Data flows
    Browser -->|renders| EntryIndex
    EntryIndex -->|loads| EntryApp
    EntryApp -->|registers| ServiceWorker

    EntryApp -->|renders UI| Header
    EntryApp -->|renders UI| MapView
    EntryApp -->|renders UI| AddAdvert
    EntryApp -->|renders UI| AdvertCard
    EntryApp -->|renders UI| PaymentFlow
    EntryApp -->|renders UI| ImageGallery
    EntryApp -->|renders UI| Appointments
    EntryApp -->|renders UI| RolePages

    Header -->|dispatch| Actions
    MapView -->|dispatch| Actions
    AddAdvert -->|dispatch| Actions
    AdvertCard -->|dispatch| Actions
    PaymentFlow -->|dispatch| Actions
    ImageGallery -->|dispatch| Actions
    Appointments -->|dispatch| Actions
    RolePages -->|dispatch| Actions

    Actions -->|thunk HTTP/REST| API
    API -->|cron/build| SitemapGen
    API -->|SQL queries| Database
    API -->|uploads| Cloudinary
    API -->|webhooks| Stripe

    PaymentFlow -->|direct HTTPS| Stripe
    ImageGallery -->|direct HTTPS| Cloudinary
    MapView -->|tile requests| MapTiles

    %% Click Events
    click EntryIndex "https://github.com/jkarelins/real-estate-site/blob/master/src/index.js"
    click EntryApp "https://github.com/jkarelins/real-estate-site/blob/master/src/App.jsx"
    click Header "https://github.com/jkarelins/real-estate-site/blob/master/src/components/header/Header.jsx"
    click MapView "https://github.com/jkarelins/real-estate-site/blob/master/src/components/map/ViewMap.jsx"
    click AddAdvert "https://github.com/jkarelins/real-estate-site/blob/master/src/components/addnewadvert/AddNewAdvert.jsx"
    click AdvertCard "https://github.com/jkarelins/real-estate-site/blob/master/src/components/advertcard/AdvertCard.jsx"
    click PaymentFlow "https://github.com/jkarelins/real-estate-site/blob/master/src/components/pay/CheckoutForm.jsx"
    click ImageGallery "https://github.com/jkarelins/real-estate-site/blob/master/src/components/image/ImagesUpload.jsx"
    click Appointments "https://github.com/jkarelins/real-estate-site/blob/master/src/components/appointment/MyAppointments.jsx"
    click RolePages "https://github.com/jkarelins/real-estate-site/blob/master/src/components/agentpage/AgentPage.jsx"
    click Actions "https://github.com/jkarelins/real-estate-site/blob/master/src/actions/advert.js"
    click Reducers "https://github.com/jkarelins/real-estate-site/blob/master/src/reducers/advert.js"
    click Store "https://github.com/jkarelins/real-estate-site/blob/master/src/store.js"
    click ServiceWorker "https://github.com/jkarelins/real-estate-site/blob/master/src/serviceWorker.js"
    click SitemapGen "https://github.com/jkarelins/real-estate-site/blob/master/src/sitemap/generator.js"
    click Database "https://github.com/jkarelins/real-estate-site/tree/master/postgresql"
    
    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#055a8c,color:#01344d
    classDef backend fill:#DFF2D8,stroke:#4F8A10,color:#274E13
    classDef data fill:#FFE4B3,stroke:#D78B00,color:#703800
    classDef external fill:#E6D0FF,stroke:#6A0DAD,color:#3E0056
    classDef state fill:#F0F0F0,stroke:#333,color:#000
```
