Skip to content

icelal-kskn/Horse_Property_Backend

Repository files navigation

Horse Property Backend

Real Estate Site Backend Developer Documentation This Documentation never open for user

Table of Contents

  1. Getting Started
  2. Database Access
  3. Requirements Documentation
  4. API Documentation

Getting Started

  • Aşağıdaki maddeleri uygularken hata alırsanız lütfen @icelal_kskn'e ulaşın
  1. Değişiklik yapmak isterseniz projeyi forklayarak başlayın
  2. Projeyi klonlayın
git clone https://github.com/icelal-kskn/Horse_Property_Backend.git
  1. Gerekli bağımlılıkları indirin
npm install
  1. Ana dizinde yeni bir env dosyası oluşturun (yeni dosya oluşturup .env yapmanız yeterlidir)
  • Aşağıdaki dosyayı env dosyasına yapıştırın sonrasında çalıştırın
JWT_SECRET= this_must_keep_secret_xd
PORT= 1806
DB_HOST= mongodb+srv://testuser:[email protected]/?retryWrites=true&w=majority&appName=HorseCluster
  1. Projeyi Çalıştırın
  • Nodemon ile çalıştırmak için yukarıdakini kullanın
  • Normal çalıştırmak için aşağıdakini kullanın
npm run server
npm start 

Database Access

MongoDB Database

Requirements Documentation

User Requirements:

Simple and Guiding Interface:

  • A structure that directs the user to categories (for sale, for rent, land, etc.) so that they know what to do at the first login.
  • Search bar and filtering options (price, square meter, location, etc.).

Viewing without Login Requirement:

  • It should be possible to search, list, view price analysis without registration and login.
  • Login requirement to write comments and add to favorites.

Price Per Square Meter Calculation:

  • The “price/m²” for each property should be automatically calculated and displayed to the user.

Suggestions Close to Location:

  • Map-based search or suggestion based on location.

Favorites and Comparison:

  • User can add properties to favorites or compare multiple properties.

Agent Features:

Favorites Count Display:

-The agent can see how many people have favorited the properties they have added.

Ability to Add or Remove Properties:

-Agents can add, edit, remove properties by managing their own portfolio.

Admin Features:

Comment Management:

  • Can edit or delete comments on the platform.

Agent Blocking:

  • Can block agents who violate the rules.

API Documentation

Endpoints

/api

Property Endpoints

Create a New Property

POST /property/
Description: Creates a new property listing.

Request Body:

Field Type Required Description Constraints
title string Yes The title of the property. Min: 5, Max: 100 characters
description string Yes A detailed description of the property. Min: 20, Max: 1000 characters
price number Yes The price of the property. Must be >= 0
type string Yes Type of the property. Must be one of apartment, house, villa, land
status string Yes Sale status of the property. Must be one of for-sale, for-rent
location object Yes Location details of the property. Contains city, district, address, and optional coordinates (lat/lng)
features object No Additional features of the property. Includes rooms, bathrooms, size, floor, heating, age
images array No Array of image URLs. Each must be a valid URI

Response:

  • 201 Created: Property successfully created.
  • 400 Bad Request: Validation error.

Get All Properties

GET /
Description: Fetches all properties with optional filters, sorting, and pagination.
Access: Public.

Query Parameters (Optional):

Parameter Type Description
type string Filter by property type (apartment, house, etc.).
status string Filter by status (for-sale, for-rent).
city string Filter by city name (case insensitive).
district string Filter by district name (case insensitive).
minPrice number Minimum price filter.
maxPrice number Maximum price filter.
minSize number Minimum size filter (e.g., in square meters).
maxSize number Maximum size filter.
rooms number Filter by number of rooms.
page number Pagination: Page number (default: 1).
limit number Pagination: Items per page (default: 10).
sort string Sort by field (e.g., price, createdAt). Prefix - for descending order.

Response:

  • 200 OK: Returns a list of properties and pagination details.
  • 500 Server Error: Error while fetching properties.

Get a Property by ID

GET /:id
Description: Fetches a specific property by its ID.
Access: Public.

Response:

  • 200 OK: Returns the property details, including the owner's information.
  • 404 Not Found: Property not found.
  • 500 Server Error: Error while fetching the property.

Update a Property

PUT /:id
Description: Updates an existing property listing.
Access: Private (requires JWT token in Authorization header).

Request Body: Partial or complete updates are allowed (fields follow the same structure as the Create a Property endpoint).

Response:

  • 200 OK: Returns the updated property object.
  • 401 Unauthorized: User does not own the property.
  • 404 Not Found: Property not found.
  • 500 Server Error: Error while updating the property.

Delete a Property

DELETE /:id
Description: Deletes a specific property by its ID.
Access: Private (requires JWT token in Authorization header).

Response:

  • 200 OK: Confirms property deletion.
  • 401 Unauthorized: User does not own the property.
  • 404 Not Found: Property not found.
  • 500 Server Error: Error while deleting the property.

User Endpoints

Register a User

POST /user/register/
Description: Registers a new user.

Request Body:

Field Type Required Description Constraints
email string Yes User's email address. Must be a valid email
password string Yes User's password. Min: 6, Max: 30 characters
fullName string Yes Full name of the user. Min: 2, Max: 50 characters
phone string No User's phone number. Must match the pattern +123456789
userType string No Type of user (role). One of regular, agent, admin

Response:

  • 201 Created: User successfully registered.
  • 400 Bad Request: Validation error.

Login User

POST /login
Description: Logs in an existing user.

Request Body:

Field Type Required Description Constraints
email string Yes User's email address. Must be a valid email
password string Yes User's password. Must match registered password

Response:

  • 200 OK: JWT token is returned.
  • 400 Bad Request: Invalid credentials.

Get User Profile

GET /profile
Description: Retrieves the logged-in user's profile.
Access: Private (requires JWT token in Authorization header).

Response:

  • 200 OK: Returns user details excluding the password.
  • 500 Server Error: Error while fetching user details.

Update User Profile

PUT /profile
Description: Updates the logged-in user's profile.
Access: Private (requires JWT token in Authorization header).

Request Body:

Field Type Required Description Constraints
fullName string No Updated full name of the user. Min: 2 characters
phone string No Updated phone number. Must match pattern +123456789

Response:

  • 200 OK: Returns updated user details.
  • 500 Server Error: Error while updating user.

Delete User Profile

DELETE /profile
Description: Deletes the logged-in user's profile.
Access: Private (requires JWT token in Authorization header).

Response:

  • 200 OK: Confirms user deletion.
  • 500 Server Error: Error while deleting user.

Notes

  • All endpoints expect request bodies in JSON format.
  • Ensure that required fields are properly provided to avoid validation errors.
  • Optional fields, if present, must meet their respective constraints.

CONTINUE FROM HERE

About

For Swe project real estate site

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published