# anibal-quiroz-p5/house-of-dev architecture

> Architecture diagram of the GitHub repository anibal-quiroz-p5/house-of-dev, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/anibal-quiroz-p5/house-of-dev
- Repository: https://github.com/anibal-quiroz-p5/house-of-dev

## Overview

##### Project Type and Purpose
- This is a full-stack web application for a real estate service. The application allows users to view available properties, mark favorites, and schedule appointments for property visits.
- The README confirms the use of a Node/Express back end (with Sequelize and PostgreSQL) and a React/Redux front end with Bootstrap and React Router.

##### Main Components
a. Frontend:
- User Interface: The “public” folder holds static assets (like index.html, manifest, and robots.txt).
- React Application: The “src” folder contains components (UI views for Home, Register, Login, Admin panels, Property details, etc.), shared common components (Grid, Property display), styling files (CSS), state management (Redux store and related files), and routing configuration.
- Key Technologies: React, Redux, React-Router-Dom, Bootstrap.

b. Backend (API Server):
- Express Server: The “api/server.js” file serves as the entry point for the back end.
- API Routes: The “api/routes” directory hosts separate route files for core functionalities (admin, appointment, favourites, property, user), exposing RESTful endpoints.
- Middleware: There is a dedicated “api/middleware” directory (e.g., auth.js) that handles authentication/authorization before requests reach the controllers.
- Database Models: The “api/models” folder defines Sequelize models like Appointment, Category, Favourites, Property, and User. These models facilitate ORM operations with a PostgreSQL database.
- Configuration and Utilities: The “api/config” folder contains files for mailer and tokens, supporting features like email notifications and token management.
- Database Initialization and Seeding: The “api/seed.js” file is used to seed or initialize the database, which is important during the initial setup.

c. Data Storage:
- PostgreSQL: Not directly present in the project tree, but referenced via Sequelize in the README. It should be shown as the central database that the back end interacts with.

##### Relationships and Interactions
- The Frontend communicates with the Backend via HTTP requests (e.g., using fetch or axios) to RESTful endpoints provided by the API routes (e.g., /user, /property, /appointment, etc.).
- The Backend processes requests using middleware (auth) before interacting with the database models. The ORM (Sequelize) facilitates the interactions with the PostgreSQL database.
- Configuration elements (mailer and tokens) support features like user authentication and email notifications within the backend.

##### Architectural Patterns and Components
- MVC-like separation on the backend: Models (in “api/models”), Controllers (represented by route handlers in “api/routes”), and Middleware (authentication) outline a clear separation of concerns.
- The Frontend is structured around React components with state management using Redux, ensuring separation between UI logic and state.
- Use of RESTful API design for clearly defined endpoints.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Subgraph
    subgraph "Frontend"
        direction TB
        browser["Browser/Client"]:::frontend
        subgraph "Static Assets"
            direction TB
            indexHTML["index.html"]:::frontend
            manifest["manifest.json"]:::frontend
            robots["robots.txt"]:::frontend
        end
        reactApp["React App"]:::frontend
        routing["Routing (React-Router)"]:::frontend
        gridComp["Grid Component"]:::frontend
        propertyComp["Property Display Component"]:::frontend
        reduxStore["Redux Store"]:::frontend
        userState["User State Management"]:::frontend
    end

    %% Backend Subgraph
    subgraph "Backend"
        direction TB
        expressServer["Express Server"]:::backend
        apiRoutes["API Routes"]:::backend
        authMiddleware["Authentication Middleware"]:::backend
        sequelizeModels["Sequelize Models"]:::backend
        configUtils["Configuration (Mailer & Tokens)"]:::utility
        dbSeed["Database Seeding"]:::backend
        postgresDB["PostgreSQL Database"]:::db
    end

    %% Frontend Flow
    browser -->|"loads"| indexHTML
    browser -->|"loads"| manifest
    browser -->|"loads"| robots
    indexHTML -->|"renders"| reactApp
    reactApp -->|"configures_routing"| routing
    reactApp -->|"uses"| gridComp
    reactApp -->|"uses"| propertyComp
    reactApp -->|"manages_state_with"| reduxStore
    reduxStore -->|"includes"| userState

    %% Communication between Frontend and Backend
    reactApp -->|"REST_API_calls"| expressServer

    %% Backend Flow
    expressServer -->|"routes_to"| apiRoutes
    apiRoutes -->|"passes_through"| authMiddleware
    authMiddleware -->|"queries"| sequelizeModels
    authMiddleware -->|"uses"| configUtils
    sequelizeModels -->|"accesses"| postgresDB
    expressServer -->|"invokes"| dbSeed

    %% Click Events for Frontend Components
    click indexHTML "https://github.com/anibal-quiroz-p5/house-of-dev/blob/develop/public/index.html"
    click manifest "https://github.com/anibal-quiroz-p5/house-of-dev/blob/develop/public/manifest.json"
    click robots "https://github.com/anibal-quiroz-p5/house-of-dev/blob/develop/public/robots.txt"
    click reactApp "https://github.com/anibal-quiroz-p5/house-of-dev/tree/develop/src/"
    click gridComp "https://github.com/anibal-quiroz-p5/house-of-dev/tree/develop/src/commons/Grid"
    click propertyComp "https://github.com/anibal-quiroz-p5/house-of-dev/tree/develop/src/commons/Property"
    click reduxStore "https://github.com/anibal-quiroz-p5/house-of-dev/blob/develop/src/state/store.js"
    click userState "https://github.com/anibal-quiroz-p5/house-of-dev/blob/develop/src/state/user.js"
    click routing "https://github.com/anibal-quiroz-p5/house-of-dev/blob/develop/src/App.js"

    %% Click Events for Backend Components
    click expressServer "https://github.com/anibal-quiroz-p5/house-of-dev/blob/develop/api/server.js"
    click apiRoutes "https://github.com/anibal-quiroz-p5/house-of-dev/tree/develop/api/routes"
    click authMiddleware "https://github.com/anibal-quiroz-p5/house-of-dev/blob/develop/api/middleware/auth.js"
    click sequelizeModels "https://github.com/anibal-quiroz-p5/house-of-dev/tree/develop/api/models"
    click configUtils "https://github.com/anibal-quiroz-p5/house-of-dev/tree/develop/api/config"
    click dbSeed "https://github.com/anibal-quiroz-p5/house-of-dev/blob/develop/api/seed.js"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#0000FF,stroke-width:2px;
    classDef backend fill:#FFA500,stroke:#FF8C00,stroke-width:2px;
    classDef utility fill:#EE82EE,stroke:#DA70D6,stroke-width:2px;
    classDef db fill:#90EE90,stroke:#008000,stroke-width:2px;
```
