This is the backend for the Sky Flow, a full-stack building management system, built with Express, MongoDB, and integrated with Stripe for payment processing. The system includes features for user management, apartment bookings, agreements, and role-based access control.
- User authentication using JWT and cookies.
- Role-based access control (admin, member, and user).
- Apartment management system.
- Agreement handling and status updates.
- Payment system integration via Stripe.
- Coupon management and validation.
- Admin functionalities to manage users and agreements.
- Express - Web framework for Node.js.
- MongoDB - NoSQL database for storing user and apartment data.
- JWT - JSON Web Token for user authentication.
- Stripe - Payment gateway for processing payments.
- Nodemailer - For sending emails.
- Cookie-parser - For handling cookies.
- CORS - For cross-origin requests.
- dotenv - For environment variable management.
- Node.js (v16 or higher)
- MongoDB account and database (create a free MongoDB Atlas account if you don’t have one)
- Stripe account for payment integration
-
Clone the repository:
git clone https://github.com/your-username/sabbir-project.git
-
Navigate to the project directory:
cd sabbir-project
-
Install dependencies:
npm install
-
Set up environment variables by creating a
.env
file in the root directory with the following keys:DB_USER=your_mongo_user DB_PASS=your_mongo_password STRIPE_SECRET_KEY=your_stripe_secret_key SECRECT_KEY=your_jwt_secret_key NODE_ENV=development
To run the server locally, use:
npm start
The server will start on port 9000 by default. You can access the API at http://localhost:9000
.
POST /jwt
- Generate a JWT token and set a cookie.POST /logout
- Log out and clear the JWT token cookie.
POST /users/:email
- Create or update a user.GET /users/role/:email
- Get the role of a user.GET /users/profile
- Get the profile of the authenticated user.
GET /apartments
- Get a list of apartments (limit 6).GET /allapartments
- Get all apartments with pagination.GET /apartments/:id
- Get details of a specific apartment.
POST /agreement
- Create a new agreement request.PATCH /agreements/update/:id
- Update agreement status (approve/reject).PATCH /agreements/reject/:id
- Reject an agreement request.
POST /create-payment-intent
- Create a payment intent with Stripe.
GET /coupons
- Get all available coupons.GET /coupons/:code
- Validate a coupon by its code.
This project is licensed under the MIT License - see the LICENSE file for details.
- MongoDB Atlas for database hosting.
- Stripe for payment processing.
- Express for the backend framework.
- JWT for authentication management.