https://github.com/7ossam7atem1/deyarak
Your Dream Home Awaits!
https://github.com/7ossam7atem1/deyarak
auth authentication cloudinary-api deeplinking javascript mongodb-atlas nodejs restful-api sendgrid stripe
Last synced: 3 months ago
JSON representation
Your Dream Home Awaits!
- Host: GitHub
- URL: https://github.com/7ossam7atem1/deyarak
- Owner: 7ossam7atem1
- Created: 2024-03-17T03:00:34.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-26T22:41:50.000Z (over 1 year ago)
- Last Synced: 2025-01-27T22:55:25.725Z (over 1 year ago)
- Topics: auth, authentication, cloudinary-api, deeplinking, javascript, mongodb-atlas, nodejs, restful-api, sendgrid, stripe
- Language: JavaScript
- Homepage:
- Size: 17.1 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ๐ Deyarak




**A modern real estate rental platform connecting property owners with renters**
[Features](#-features) โข [Tech Stack](#-tech-stack) โข [Installation](#-installation) โข [API Documentation](#-api-documentation) โข [Deployment](#-deployment)
---
## ๐ Table of Contents
- [About](#-about)
- [Features](#-features)
- [Tech Stack](#-tech-stack)
- [Architecture](#-architecture)
- [Prerequisites](#-prerequisites)
- [Installation](#-installation)
- [Environment Variables](#-environment-variables)
- [API Documentation](#-api-documentation)
- [Testing](#-testing)
- [Deployment](#-deployment)
- [Project Structure](#-project-structure)
- [Contributing](#-contributing)
- [License](#-license)
- [Acknowledgments](#-acknowledgments)
---
## ๐ฏ About
**Deyarak** is a comprehensive Node.js web server designed for the real estate industry. It facilitates direct property rental transactions between property owners and renters, eliminating intermediaries and streamlining the rental process.
This project was developed as a graduation project, implementing modern web development practices and industry-standard security measures.
---
## โจ Features
- ๐ **Secure Authentication** - JWT-based authentication with password hashing
- ๐๏ธ **Property Management** - Complete CRUD operations for property listings
- ๐ณ **Payment Integration** - Stripe integration for secure payment processing
- ๐ง **Email Notifications** - Automated email notifications via SendGrid
- ๐ธ **Image Upload** - Cloudinary integration for property image storage
- โญ **Review System** - User reviews and ratings for properties
- ๐ **Contact Management** - Contact form and inquiry system
- ๐ **API Documentation** - Swagger/OpenAPI documentation
- ๐งช **Testing** - Comprehensive test suite with Jasmine
- ๐ก๏ธ **Security** - Rate limiting, data sanitization, and security headers
---
## ๐ ๏ธ Tech Stack
### Backend
- **Runtime**: Node.js
- **Framework**: Express.js
- **Language**: JavaScript
- **Architecture**: MVC (Model-View-Controller)
### Database
- **Database**: MongoDB
- **ODM**: Mongoose
### Authentication & Security
- **Authentication**: JSON Web Tokens (JWT)
- **Password Hashing**: bcryptjs
- **Security Middleware**: Helmet, express-rate-limit, express-mongo-sanitize, HPP
### Services & Integrations
- **Image Storage**: Cloudinary
- **Email Service**: SendGrid (Production), Mailtrap (Development)
- **Payment Processing**: Stripe
- **API Documentation**: Swagger (swagger-jsdoc, swagger-ui-express)
### Testing
- **Testing Framework**: Jasmine
- **HTTP Testing**: Supertest
### Additional Tools
- **Image Processing**: Sharp
- **File Upload**: Multer
- **Email Templates**: Pug
- **Logging**: Morgan
- **Validation**: Validator
---
## ๐๏ธ Architecture
The application follows the **MVC (Model-View-Controller)** architectural pattern:
- **Models**: Data schemas and business logic (MongoDB/Mongoose)
- **Views**: Email templates (Pug templates)
- **Controllers**: Request handling and business logic
- **Routes**: API endpoint definitions
- **Middleware**: Authentication, error handling, security
---
## ๐ฆ Prerequisites
Before you begin, ensure you have the following installed:
- **Node.js** (v18 or higher)
- **npm** (v9 or higher) or **yarn**
- **MongoDB** (local installation or MongoDB Atlas account)
- **Git**
---
## ๐ Installation
### 1. Clone the Repository
```bash
git clone https://github.com/7ossam7atem1/Deyarak.git
cd Deyarak
```
### 2. Install Dependencies
```bash
npm install
```
### 3. Environment Configuration
Create a `.env` file in the root directory (or copy from `.env.example` if available) and configure the environment variables (see [Environment Variables](#-environment-variables) section below).
### 4. Start the Development Server
```bash
npm start
```
The server will start on the port specified in your `.env` file (default: 2000).
### 5. Access the Application
- **API Base URL**: `http://localhost:2000/api/v1`
- **API Documentation**: `http://localhost:2000/api-docs`
---
## ๐ Environment Variables
Create a `.env` file in the root directory with the following variables:
### Application Configuration
```env
NODE_ENV=development
PORT=2000
```
### Database Configuration
```env
DATABASE=mongodb+srv://:@cluster.mongodb.net/database-name
DATABASE_PASSWORD=your-database-password
```
### JWT Configuration
```env
JWT_SECRET=your-super-secret-jwt-key
JWT_EXPIRES_IN=90d
JWT_COOKIE_EXPIRES_IN=90
```
### Email Configuration (Development - Mailtrap)
```env
EMAIL_USERNAME=your-mailtrap-username
EMAIL_PASSWORD=your-mailtrap-password
EMAIL_HOST=smtp.mailtrap.io
EMAIL_PORT=2525
EMAIL_FROM=noreply@deyarak.com
```
### Email Configuration (Production - SendGrid)
```env
SENDGRID_USERNAME=your-sendgrid-username
SENDGRID_PASSWORD=your-sendgrid-api-key
```
### Payment Configuration (Stripe)
```env
STRIPE_SECRET_KEY=your-stripe-secret-key
```
### Cloudinary Configuration
```env
CLOUD_NAME=your-cloudinary-cloud-name
CLOUD_API_KEY=your-cloudinary-api-key
CLOUD_API_SECRET=your-cloudinary-api-secret
```
> โ ๏ธ **Important**: Never commit your `.env` file to version control. Add it to your `.gitignore` file.
---
## ๐ API Documentation
Interactive API documentation is available via Swagger UI:
**Live Documentation**: [https://deyarak-app.onrender.com/api-docs/](https://deyarak-app.onrender.com/api-docs/)
### API Endpoints
The API is organized into the following main routes:
- **Properties**: `/api/v1/properties` - Property management endpoints
- **Users**: `/api/v1/users` - User authentication and management
- **Reviews**: `/api/v1/reviews` - Property reviews and ratings
- **Rentings**: `/api/v1/rentings` - Rental transactions and payments
- **Contacts**: `/api/v1/contacts` - Contact form submissions
For detailed endpoint documentation, visit the Swagger UI interface.
---
## ๐งช Testing
Run the test suite using Jasmine:
```bash
npm test
```
Or directly with:
```bash
npx jasmine
```
The test suite includes:
- Unit tests for controllers
- Integration tests for API endpoints
- Authentication and authorization tests
---
## ๐ข Deployment
### Production Build
To run the application in production mode:
```bash
npm run start:prod
```
### Deployment Platform
This application is deployed on **Render**:
### Deployment Checklist
- [ ] Set all required environment variables in your hosting platform
- [ ] Ensure MongoDB connection string is configured
- [ ] Configure production email service (SendGrid)
- [ ] Set up Stripe production keys
- [ ] Configure Cloudinary production settings
- [ ] Enable HTTPS/SSL
- [ ] Set up monitoring and logging
- [ ] Configure CORS for production domain
---
## ๐ Project Structure
```
Deyarak/
โโโ controllers/ # Request handlers and business logic
โ โโโ authController.js
โ โโโ contactController.js
โ โโโ errorController.js
โ โโโ factoryHandler.js
โ โโโ propertyController.js
โ โโโ rentingController.js
โ โโโ reviewController.js
โ โโโ userController.js
โโโ models/ # MongoDB schemas and models
โ โโโ contactModel.js
โ โโโ propertyModel.js
โ โโโ rentingModel.js
โ โโโ reviewModel.js
โ โโโ userModel.js
โโโ routes/ # API route definitions
โ โโโ contactRoutes.js
โ โโโ paymentRoutes.js
โ โโโ propertyRoutes.js
โ โโโ reviewRoutes.js
โ โโโ userRoutes.js
โโโ utils/ # Utility functions and helpers
โ โโโ apiMaestro.js
โ โโโ appError.js
โ โโโ catchAsyncronization.js
โ โโโ cloudinary.js
โ โโโ email.js
โ โโโ swagger.js
โ โโโ swagger.json
โโโ views/ # Email templates (Pug)
โ โโโ email/
โ โโโ _style.pug
โ โโโ baseEmail.pug
โ โโโ passwordReset.pug
โ โโโ welcome.pug
โโโ public/ # Static files
โ โโโ img/
โ โโโ success.css
โ โโโ success.html
โโโ spec/ # Test specifications
โ โโโ apiSpec.js
โ โโโ support/
โ โโโ jasmine.json
โโโ dev-data/ # Development data and scripts
โ โโโ customScript.js
โ โโโ property.json
โโโ app.js # Express application setup
โโโ server.js # Server entry point
โโโ package.json # Project dependencies
```
---
## ๐ค Contributing
Contributions are welcome! If you'd like to contribute to this project:
1. Fork the repository
2. Create a feature branch (`git checkout -b feature/AmazingFeature`)
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request
Please ensure your code follows the existing style and includes appropriate tests.
---
## ๐ License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
[](https://choosealicense.com/licenses/mit/)
---
## ๐ค Author
**Hossam Hatem**
- GitHub: [@7ossam7atem1](https://github.com/7ossam7atem1)
- Project Link: [https://github.com/7ossam7atem1/Deyarak](https://github.com/7ossam7atem1/Deyarak)
---
## ๐ Acknowledgments
- **Supervisor**: Prof. Dr. Mahmoud Hussien
- **Institution**: Faculty of computers and information
---