# dipanjanpathak/master_ml-mern-realestate architecture

> Architecture diagram of the GitHub repository dipanjanpathak/master_ml-mern-realestate, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dipanjanpathak/master_ml-mern-realestate
- Repository: https://github.com/dipanjanpathak/master_ml-mern-realestate

## Overview

##### Project Overview and Types
- This project is a full-stack application with a strong focus on machine learning (ML) for real estate price prediction and property recommendations.
- It uses a mix of both the MERN (MongoDB, Express/Node.js, React, Node.js server) and Django stacks for different microservices. The ML workflows and model experiments are developed in Jupyter notebooks (inside ML_Operations) and further integrated into production through Django.
- The system incorporates several distinct layers: data science/ML processing, a backend API layer (with both Node.js and Django components), and a React-based frontend.

##### Main Components of the System
a. ML_Operations:
- Contains multiple Jupyter notebooks (data treatment, EDA, model selection, building, recommendation system) and raw/processed datasets.
- Represents the data science and model development phase where various ML models (XGBoost Regressor) are experimented and validated.
- Includes data artifacts (e.g., .csv, .pkl files) needed for training and prediction.
b. Backend Services:
- Node.js Based API:
- Found in Website/Backend, with controllers handling requests for prediction and recommendation data, routing modules that define endpoints, and server configuration.
- This service likely handles tasks such as processing user input, caching predictions, and communicating with the database (MongoDB).
- Django Based API:
- Within the Website/ml directory, Django manages API endpoints that specifically interact with the ML models (loaded either from pre-trained states or wrapped in Django apps).
- It handles ML-specific tasks such as prediction, recommendation logic, and perhaps data validation.
- Database:
- MongoDB – serving as the primary storage solution for property listings and possibly caching user query results or predictions.
c. Frontend:
- Developed in React (under Website/frontend), including a comprehensive folder structure for components, pages, static assets, and Redux Toolkit (RTK) slices for state management.
- It interacts heavily with both the backend APIs (Django and Node.js) to post user queries, receive predicted prices, and display property details.
d. Integration and Communication Flow:
- In-memory caching in the backend for quick retrieval of previously computed predictions.
- Usage of RESTful APIs for communication between the frontend and the different microservices (Node.js service for recommendations and Django service for ML predictions).
- Data flows end-to-end—from user input at the frontend to model execution in the Django service, then recommendation processing via Node.js, finally delivered from the database.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Nodes
    UQI["User Query Input"]:::external
    FE["React Frontend (Redux)"]:::react
    DAPI["Django ML API"]:::django
    NAPI["Node.js API Service"]:::node
    ML["ML Operations (Notebooks & Data)"]:::ml
    DB["MongoDB Database"]:::db
    CACHE["In-Memory Cache"]:::cache

    %% Flow Connections
    UQI -->|"sends query"| FE
    FE -->|"POST_query(price_prediction)"| DAPI
    FE -->|"POST_query(recommendations)"| NAPI
    DAPI -->|"load&execute_XGBoost"| ML
    ML -->|"trained_model"| DAPI
    DAPI <-.->|"cache_predictions"| CACHE
    NAPI <-.->|"cache_retrieval"| CACHE
    NAPI -->|"fetch_property_data"| DB
    DAPI -->|"send_prediction_result"| FE
    NAPI -->|"send_recommendations"| FE

    %% Click Events
    click FE "https://github.com/dipanjanpathak/master_ml-mern-realestate/tree/master/Website/frontend"
    click DAPI "https://github.com/dipanjanpathak/master_ml-mern-realestate/tree/master/Website/ml"
    click NAPI "https://github.com/dipanjanpathak/master_ml-mern-realestate/tree/master/Website/Backend"
    click ML "https://github.com/dipanjanpathak/master_ml-mern-realestate/tree/master/ML_Operations"
    click DB "https://github.com/dipanjanpathak/master_ml-mern-realestate/tree/master/Website/Backend/db"

    %% Styles
    classDef react fill:#9fdf9f,stroke:#333,stroke-width:2px;
    classDef node fill:#9ecdfb,stroke:#333,stroke-width:2px;
    classDef django fill:#f9d57a,stroke:#333,stroke-width:2px;
    classDef ml fill:#f7a8a8,stroke:#333,stroke-width:2px;
    classDef db fill:#d1a3ff,stroke:#333,stroke-width:2px;
    classDef cache fill:#ffdd75,stroke:#333,stroke-width:2px;
    classDef external fill:#cccccc,stroke:#333,stroke-width:2px;
```
