# gautamkr-10/rentify architecture

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

- Interactive diagram: https://gitdiagram.com/gautamkr-10/rentify
- Repository: https://github.com/gautamkr-10/rentify

## Overview

##### Project type and purpose
- This is a full-stack real estate rental application (“Rentify”) that provides both Next.js and Vite-based React frontends, a set of shareable UI components, multiple Express-based API services, and a MongoDB database. Its purpose is to connect property owners and tenants via authentication, property listings, filtering, dashboard management, email notifications, and file uploads.

##### File structure
- Top-level directories:
- app/       → Next.js 13 “app router” frontend
- frontend/ → Vite + React SPA frontend
- backend/  → Express API (auth, properties, users)
- server/   → Secondary Express API (similar structure)
- components/ → Shared UI library (Radix/Tailwind components)
- hooks/      → Custom React hooks (use-mobile, use-toast)
- lib/        → Shared utilities (utils.ts)
- Common patterns:
- Frontends organized by pages, components, context, services
- Backend organized as MVC: routes → controllers → models, plus middleware
- Shared code (components, hooks, lib) used by both frontends
- Config files: pnpm-lock.yaml, tsconfig.json, tailwind.config.*

##### README
- Confirms core features: authentication, property listing & filtering, dashboards, image upload, email notifications
- Tech stack: React, Next.js, Axios, Tailwind; Node.js, Express, MongoDB, JWT, Nodemailer, Multer

a. Main Components
- Next.js “app” frontend
- Vite React “frontend” SPA
- Shared UI Component Library (components/)
- Shared Hooks & Utilities (hooks/, lib/)
- API Services (backend/ and server/)
– Auth Service (login, register, JWT)
– Property Service (CRUD, filtering, image uploads)
– User Service (profile, saved/liked properties)
- MongoDB Database (atlas or self-hosted)
- External Services
– Email Service (Nodemailer SMTP)
– File Storage (local disk or cloud via Multer)

b. Relationships & Interactions
1. Clients (Next.js & Vite SPA) → send HTTP/HTTPS requests (Axios/Fetch) → API Gateway or direct API endpoints
2. AuthContext in clients manages JWT, injects Authorization header
3. API routes → invoke Express middleware (auth.js) → controllers → mongoose models → MongoDB
4. File uploads handled by Multer → stored in disk or cloud bucket → file URLs saved in DB
5. Controllers trigger Nodemailer to send email notifications on interest expressed
6. Both frontends import shared components, hooks, utils via monorepo workspace

c. Architectural Patterns & Principles
- Layered / MVC pattern in backend
- Component-driven UI architecture in frontends
- Monorepo modularization for code sharing (PNPM workspaces)
- Context API for global state (authentication)
- Separation of concerns: UI ↔ services/API ↔ data layer

d. Key Technologies & Frameworks to annotate
- Next.js 13 (app router)
- React + Vite
- Tailwind CSS
- Express.js
- Mongoose / MongoDB
- JSON Web Tokens
- Nodemailer, Multer

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Client Layer"
        direction TB
        NextJS["Next.js Frontend"]:::frontend
        ReactSPA["React SPA Frontend"]:::frontend
    end

    %% Shared Libraries
    subgraph "Shared Libraries"
        direction TB
        UI["Shared UI Components"]:::shared
        Hooks["Shared Hooks"]:::shared
        Utils["Shared Utilities"]:::shared
    end

    %% API Layer
    subgraph "API Layer"
        direction TB
        subgraph "Backend Services (backend/)"
            direction TB
            AuthBE["Auth Service (backend)"]:::backend
            PropBE["Property Service (backend)"]:::backend
            UserBE["User Service (backend)"]:::backend
        end
        subgraph "Secondary Services (server/)"
            direction TB
            AuthSV["Auth Service (server)"]:::backend
            PropSV["Property Service (server)"]:::backend
            UserSV["User Service (server)"]:::backend
        end
    end

    %% Database
    DB["MongoDB Database"]:::database

    %% External
    Email["Email Service (Nodemailer)"]:::external
    Storage["File Storage (Multer)"]:::external

    %% Relationships
    NextJS -->|"uses components, hooks, utils"| UI
    NextJS --> UI
    NextJS --> Hooks
    NextJS --> Utils
    ReactSPA --> UI
    ReactSPA --> Hooks
    ReactSPA --> Utils

    NextJS -->|"HTTP/HTTPS via Axios/Fetch"| AuthBE
    NextJS --> PropBE
    NextJS --> UserBE

    ReactSPA --> AuthBE
    ReactSPA --> PropBE
    ReactSPA --> UserBE

    AuthBE -->|"reads/writes"| DB
    PropBE --> DB
    UserBE --> DB

    AuthSV --> DB
    PropSV --> DB
    UserSV --> DB

    PropBE --> Storage
    PropSV --> Storage

    PropBE -->|"send interest email"| Email
    PropSV --> Email

    %% Click Events
    click NextJS "https://github.com/gautamkr-10/rentify/tree/main/app/"
    click ReactSPA "https://github.com/gautamkr-10/rentify/tree/main/frontend/"
    click UI "https://github.com/gautamkr-10/rentify/tree/main/components/"
    click Hooks "https://github.com/gautamkr-10/rentify/tree/main/hooks/"
    click Utils "https://github.com/gautamkr-10/rentify/blob/main/lib/utils.ts"

    click AuthBE "https://github.com/gautamkr-10/rentify/blob/main/backend/routes/auth.js"
    click PropBE "https://github.com/gautamkr-10/rentify/blob/main/backend/routes/properties.js"
    click UserBE "https://github.com/gautamkr-10/rentify/blob/main/backend/routes/users.js"

    click AuthSV "https://github.com/gautamkr-10/rentify/blob/main/server/routes/auth.js"
    click PropSV "https://github.com/gautamkr-10/rentify/blob/main/server/routes/properties.js"
    click UserSV "https://github.com/gautamkr-10/rentify/blob/main/server/routes/users.js"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#3399ff,color:#000;
    classDef shared fill:#d4edda,stroke:#28a745,color:#000;
    classDef backend fill:#fff3cd,stroke:#ffc107,color:#000;
    classDef database fill:#e2e3e5,stroke:#6c757d,color:#000,stroke-width:2px;
    classDef external fill:#f8d7da,stroke:#dc3545,color:#000;
```
