A modern office rental application backend built to streamline workspace management and booking
- About
- Features
- Technology Stack
- Getting Started
- Usage
- API Documentation
- Project Structure
- Development
- Testing
- Deployment
- Contributing
- License
- Contact
OfficeZone is a comprehensive backend solution for office rental and workspace management. It provides a robust API for managing office spaces, bookings, user authentication, and payment processing. Whether you're managing coworking spaces, private offices, or meeting rooms, OfficeZone simplifies the entire rental process.
-
User Management
- User registration and authentication
- Role-based access control (Admin, Owner, Tenant)
- Profile management
-
Office Space Management
- Create and manage office listings
- Office availability tracking
- Photo uploads and management
- Location-based search
-
Booking System
- Real-time availability checking
- Flexible booking periods (hourly, daily, monthly)
- Booking confirmation and notifications
- Booking history and management
-
Payment Integration
- Secure payment processing
- Multiple payment methods
- Payment history and invoicing
- Refund management
-
Search & Filter
- Advanced search functionality
- Filter by location, price, amenities
- Sorting options
-
Reviews & Ratings
- User reviews and ratings
- Review moderation
- Average rating calculation
- Runtime Environment: Node.js
- Framework: Express.js
- Database: MongoDB with Mongoose ODM
- Authentication: JWT (JSON Web Tokens)
- File Storage: AWS S3 / Local Storage
- Payment Processing: Stripe API
- Email Service: SendGrid / Nodemailer
- API Documentation: Swagger/OpenAPI
- Testing: Jest / Mocha & Chai
- Code Quality: ESLint, Prettier
Before you begin, ensure you have the following installed:
- Node.js (v14.x or higher)
- npm or yarn package manager
- MongoDB (v4.x or higher)
- Git
- Clone the repository
git clone https://github.com/Digitalturkk/OfficeZone.git
cd OfficeZone- Install dependencies
npm install
# or
yarn install- Set up environment variables
Create a .env file in the root directory:
# Server Configuration
PORT=5000
NODE_ENV=development
# Database
MONGODB_URI=mongodb://localhost:27017/officezone
MONGODB_TEST_URI=mongodb://localhost:27017/officezone-test
# JWT Secret
JWT_SECRET=your_jwt_secret_key_here
JWT_EXPIRE=7d
# Email Configuration
EMAIL_SERVICE=sendgrid
EMAIL_API_KEY=your_email_api_key
EMAIL_FROM=noreply@officezone.com
# File Upload
MAX_FILE_SIZE=5242880
FILE_UPLOAD_PATH=./public/uploads
# AWS S3 (if using cloud storage)
AWS_ACCESS_KEY_ID=your_aws_access_key
AWS_SECRET_ACCESS_KEY=your_aws_secret_key
AWS_BUCKET_NAME=your_bucket_name
AWS_REGION=us-east-1
# Payment Gateway
STRIPE_SECRET_KEY=your_stripe_secret_key
STRIPE_PUBLISHABLE_KEY=your_stripe_publishable_key
# Frontend URL
FRONTEND_URL=http://localhost:3000- Database setup
Make sure MongoDB is running:
# For local MongoDB
mongod
# Or use Docker
docker run -d -p 27017:27017 --name mongodb mongo:latestAdditional configuration options can be found in the config/ directory. Modify these files according to your environment:
config/db.js- Database connection settingsconfig/auth.js- Authentication configurationconfig/upload.js- File upload settings
npm run dev
# or
yarn devThe server will start on http://localhost:5000 (or the PORT specified in your .env file).
npm start
# or
yarn starthttp://localhost:5000/api/v1
Most endpoints require authentication. Include the JWT token in the Authorization header:
Authorization: Bearer <your_token>
POST /api/v1/auth/register- Register a new userPOST /api/v1/auth/login- Login userGET /api/v1/auth/me- Get current userPUT /api/v1/auth/updatedetails- Update user detailsPUT /api/v1/auth/updatepassword- Update passwordPOST /api/v1/auth/forgotpassword- Request password resetPUT /api/v1/auth/resetpassword/:resettoken- Reset password
GET /api/v1/offices- Get all officesGET /api/v1/offices/:id- Get single officePOST /api/v1/offices- Create new office (Auth required)PUT /api/v1/offices/:id- Update office (Auth required)DELETE /api/v1/offices/:id- Delete office (Auth required)GET /api/v1/offices/radius/:zipcode/:distance- Get offices within radius
GET /api/v1/bookings- Get all bookingsGET /api/v1/bookings/:id- Get single bookingPOST /api/v1/offices/:officeId/bookings- Create booking (Auth required)PUT /api/v1/bookings/:id- Update booking (Auth required)DELETE /api/v1/bookings/:id- Cancel booking (Auth required)
GET /api/v1/offices/:officeId/reviews- Get reviews for officePOST /api/v1/offices/:officeId/reviews- Add review (Auth required)PUT /api/v1/reviews/:id- Update review (Auth required)DELETE /api/v1/reviews/:id- Delete review (Auth required)
For detailed API documentation, visit /api-docs when the server is running (Swagger UI).
OfficeZone/
βββ config/ # Configuration files
β βββ db.js # Database configuration
β βββ auth.js # Authentication config
β βββ ...
βββ controllers/ # Route controllers
β βββ auth.js
β βββ offices.js
β βββ bookings.js
β βββ ...
βββ models/ # Database models
β βββ User.js
β βββ Office.js
β βββ Booking.js
β βββ ...
βββ routes/ # API routes
β βββ auth.js
β βββ offices.js
β βββ bookings.js
β βββ ...
βββ middleware/ # Custom middleware
β βββ auth.js
β βββ error.js
β βββ async.js
β βββ ...
βββ utils/ # Utility functions
β βββ errorResponse.js
β βββ sendEmail.js
β βββ ...
βββ public/ # Static files
β βββ uploads/ # Uploaded files
βββ tests/ # Test files
β βββ unit/
β βββ integration/
βββ .env.example # Environment variables example
βββ .gitignore
βββ package.json
βββ server.js # Entry point
βββ README.md
This project uses ESLint and Prettier for code formatting. Run the following commands:
# Lint code
npm run lint
# Fix linting issues
npm run lint:fix
# Format code
npm run formatWe use Husky for Git hooks to ensure code quality:
npm run preparenpm test# Unit tests
npm run test:unit
# Integration tests
npm run test:integration
# Test coverage
npm run test:coverage- Unit tests: Test individual functions and modules
- Integration tests: Test API endpoints and database interactions
- E2E tests: Test complete user workflows
- Create a Heroku app:
heroku create your-app-name- Add MongoDB addon:
heroku addons:create mongolab:sandbox- Set environment variables:
heroku config:set NODE_ENV=production
heroku config:set JWT_SECRET=your_secret
# Set other environment variables- Deploy:
git push heroku mainRefer to the detailed deployment guide in the docs/deployment.md file.
# Build image
docker build -t officezone-backend .
# Run container
docker run -p 5000:5000 --env-file .env officezone-backendWe welcome contributions! Please follow these steps:
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Please make sure to:
- Follow the existing code style
- Write/update tests for your changes
- Update documentation as needed
- Follow the Code of Conduct
For more details, see CONTRIBUTING.md
This project is licensed under the MIT License - see the LICENSE file for details.
Project Maintainer: Digitalturkk
- GitHub: @Digitalturkk
- Project Link: https://github.com/Digitalturkk/OfficeZone
- Thanks to all contributors who have helped shape this project
- Inspired by the need for better workspace management solutions
- Built with love for the coworking community
β If you find this project helpful, please consider giving it a star on GitHub!