Skip to content

BarYosef212/Apartments-AI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

11 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Apartments - Real Estate Search Platform

A full-stack real estate search platform with AI-powered chat interface and semantic search capabilities. Built with React, TypeScript, Node.js, and MongoDB.

πŸš€ Features

For Users

  • AI-Powered Chat Interface: Natural language search for apartments using Hebrew language support
  • Semantic Search: Vector-based search using embeddings for intelligent property matching
  • Advanced Filtering: Filter apartments by city, price range, rooms, size, and more
  • Property Details: Detailed view of each apartment with images and specifications
  • Responsive Design: Modern UI built with Tailwind CSS and Radix UI components

For Administrators

  • Admin Dashboard: Protected route for managing apartments
  • CRUD Operations: Create, read, update, and delete apartment listings
  • Authentication: Secure login system with JWT tokens

πŸ› οΈ Tech Stack

Backend

  • Node.js with Express.js
  • TypeScript for type safety
  • MongoDB with Mongoose ODM
  • JWT for authentication
  • bcryptjs for password hashing
  • @xenova/transformers for embeddings (multilingual-e5-base model)
  • @langchain/ollama for AI chat (gemma2 model)
  • express-session for session management

Frontend

  • React 18 with TypeScript
  • Vite for build tooling
  • React Router for navigation
  • Tailwind CSS for styling
  • Radix UI for accessible components
  • Axios for API calls
  • Embla Carousel for image carousels

πŸ“ Project Structure

apartments/
β”œβ”€β”€ back/                    # Backend application
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ config/         # Configuration constants
β”‚   β”‚   β”œβ”€β”€ controllers/    # Route controllers
β”‚   β”‚   β”‚   β”œβ”€β”€ apartments.controller.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ auth.controller.ts
β”‚   β”‚   β”‚   └── embedding.controller.ts
β”‚   β”‚   β”œβ”€β”€ middleware/     # Authentication middleware
β”‚   β”‚   β”œβ”€β”€ models/         # MongoDB models
β”‚   β”‚   β”œβ”€β”€ routes/         # Express routes
β”‚   β”‚   β”œβ”€β”€ services/       # Business logic
β”‚   β”‚   β”œβ”€β”€ types/          # TypeScript type definitions
β”‚   β”‚   └── server.ts       # Entry point
β”‚   β”œβ”€β”€ package.json
β”‚   └── tsconfig.json
β”‚
└── front/                   # Frontend application
    β”œβ”€β”€ src/
    β”‚   β”œβ”€β”€ api/            # API client configuration
    β”‚   β”œβ”€β”€ components/     # React components
    β”‚   β”‚   β”œβ”€β”€ ui/         # Reusable UI components
    β”‚   β”‚   β”œβ”€β”€ ChatWidget.tsx
    β”‚   β”‚   β”œβ”€β”€ FiltersBar.tsx
    β”‚   β”‚   └── ...
    β”‚   β”œβ”€β”€ contexts/       # React contexts (ChatContext)
    β”‚   β”œβ”€β”€ hooks/          # Custom React hooks
    β”‚   β”œβ”€β”€ pages/          # Page components
    β”‚   β”œβ”€β”€ types/          # TypeScript type definitions
    β”‚   └── main.tsx        # Entry point
    β”œβ”€β”€ package.json
    └── vite.config.ts

πŸ“¦ Installation

Prerequisites

  • Node.js (v18 or higher)
  • MongoDB (local or cloud instance)
  • Ollama (for AI chat functionality - gemma2 model)

Setup Steps

  1. Clone the repository

    git clone https://github.com/BarYosef212/Apartments-AI.git
    cd Apartments-AI
  2. Install backend dependencies

    cd back
    npm install
  3. Install frontend dependencies

    cd ../front
    npm install
  4. Set up environment variables

    Create a .env file in the back/ directory:

    PORT=4000
    MONGO_URI=your_mongodb_connection_string
    SESSION_SECRET=your_session_secret_key
    JWT_SECRET=your_jwt_secret_key
  5. Install and configure Ollama (for AI chat)

    # Install Ollama from https://ollama.ai
    # Then pull the gemma2 model:
    ollama pull gemma2

πŸš€ Running the Project

Development Mode

  1. Start the backend server

    cd back
    npm run dev

    The backend will run on http://localhost:4000

  2. Start the frontend development server

    cd front
    npm run dev

    The frontend will run on http://localhost:5173

Production Build

  1. Build the backend

    cd back
    npm run build
    npm start
  2. Build the frontend

    cd front
    npm run build
    npm run preview

πŸ”Œ API Endpoints

Authentication

  • POST /auth/login - User login
  • POST /auth/register - User registration (if implemented)

Apartments

  • GET /apartments - Get paginated list of apartments with filters
    • Query params: page, city, min_price, max_price, rooms, type, search
  • GET /apartments/:id - Get apartment by ID
  • GET /apartments/cities - Get list of all cities
  • GET /apartments/types - Get list of all property types
  • POST /apartments - Create new apartment (admin only)
  • PUT /apartments/:id - Update apartment (admin only)
  • DELETE /apartments/:id - Delete apartment (admin only)

Chat/Embeddings

  • POST /embedding/extract-filters - Extract search filters from natural language
  • POST /embedding/talk - Chat with AI assistant

🎯 Key Features Explained

AI Chat Interface

The chat widget uses Ollama's gemma2 model to:

  • Understand natural language queries in Hebrew
  • Extract search filters (city, price range) from conversations
  • Provide friendly, conversational responses
  • Switch between search mode and chat mode

Semantic Search

Properties are embedded using the Xenova/multilingual-e5-base model:

  • Each apartment is converted to a searchable text representation
  • User queries are embedded and matched against property embeddings
  • Enables intelligent, context-aware property matching

Admin Dashboard

Protected route (/admin) that requires authentication:

  • View all apartments in a table format
  • Create, edit, and delete apartment listings
  • Manage apartment data with a user-friendly interface

πŸ”’ Authentication

The application uses JWT tokens for authentication:

  • Tokens are stored in HTTP-only cookies or localStorage
  • Protected routes require valid authentication
  • Session management via express-session

🌐 Supported Languages

  • Hebrew (Χ’Χ‘Χ¨Χ™Χͺ): Primary language for UI and AI chat
  • The AI assistant is configured to respond in Hebrew with a friendly, conversational tone

πŸ“ Environment Variables

Backend (.env)

  • PORT - Server port (default: 4000)
  • MONGO_URI - MongoDB connection string
  • SESSION_SECRET - Secret for express-session
  • JWT_SECRET - Secret for JWT token signing

πŸ§ͺ Development Notes

  • The backend uses TypeScript with strict type checking
  • Frontend uses Vite for fast HMR (Hot Module Replacement)
  • Both projects have separate tsconfig.json files
  • UI components are built with Radix UI for accessibility

Note: Make sure Ollama is running and the gemma2 model is available before using the chat functionality. The embedding models will be downloaded automatically on first use.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors