You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Nexora Backend is a high-performance RESTful API server for the Nexora Apartment Management System. Built using Node.js, Express 5, Mongoose ORM, Better Auth, Zod validation, and Stripe payment integration, it follows an enterprise-grade Routes -> Controllers -> Services modular architecture.
β¨ Features
β Layered Modular Architecture (Routes, Controllers, Services)
β Better Auth Integration (better-auth) for session & email/password authentication
β Password Hashing via bcryptjs (salt rounds: 10)
β Strict Request Body Validation using Zod schemas
β Role-Based Authorization (Admin / Member / User)
β Apartments Management with pagination, rent range filtering, and sorting
β Agreements Workflow (Application request, admin accept/reject)
β Coupons System (Create, update, delete, and discount validation)
β Rent Payments integrated with Stripe PaymentIntents
β Automated Monthly Rent Generation via node-cron
β Announcements System for property notices
β Admin Dashboard Statistics with MongoDB aggregation pipelines
# 1. Install dependencies
npm install
# 2. Run in development mode
npm run dev
# 3. Start production server
npm start
Using bun:
# 1. Install dependencies
bun install
# 2. Run in development mode
bun dev
π API Reference
π Authentication (Better Auth)
Method
Endpoint
Description
Auth
ALL
/api/auth/*
Better Auth handlers (Sign In, Sign Up, Sign Out, Session)
Public
POST
/users/login
Email & password login (returns JWT/Session)
Public
π€ Users
Method
Endpoint
Description
Auth
POST
/users
Create or update user account
Public (Zod)
GET
/users/:email/role
Get user role (user, member, admin)
Session
π’ Apartments
Method
Endpoint
Description
Auth
GET
/apartments
Paginated apartments list (page, limit, minRent, maxRent, sortBy, sortOrder)
Public
π Agreements
Method
Endpoint
Description
Auth
POST
/agreements
Apply for an apartment agreement
Session (Zod)
GET
/agreements?status=pending
Get agreements by status
Admin
PATCH
/agreements/:id
Accept or reject agreement request
Admin
GET
/agreements/user/:email
Get user's agreements list
Session
ποΈ Coupons
Method
Endpoint
Description
Auth
GET
/coupons
List all available coupons
Public
POST
/coupons/validate
Validate coupon code and get discount
Member
POST
/coupons
Add a new coupon
Admin (Zod)
PUT
/coupons/:id
Update existing coupon details
Admin (Zod)
DELETE
/coupons/:id
Delete coupon by ID
Admin
π³ Rent Payments & Stripe
Method
Endpoint
Description
Auth
POST
/create-payment-intent
Create Stripe PaymentIntent with optional coupon discount
Member (Zod)
POST
/rent-payments
Record successful rent payment
Session (Zod)
GET
/rent-payments/:email
Get rent payments history for user
Session
PATCH
/rent-payments/:id
Update rent payment status
Session
π’ Announcements
Method
Endpoint
Description
Auth
GET
/announcements
Get list of announcements
Session
POST
/announcements
Create new announcement
Admin (Zod)
PATCH
/announcements/:id
Update announcement by ID
Admin (Zod)
DELETE
/announcements/:id
Delete announcement by ID
Admin
π Admin Dashboard
Method
Endpoint
Description
Auth
GET
/members
Get all members with agreement & apartment info
Admin
PATCH
/members/:email/remove
Downgrade member role & release apartment
Admin
GET
/members/:email/due-months
Get unpaid rent months for a member
Admin
GET
/admin/stats
Aggregate stats (Total rooms, availability %, total users, members)
Admin
β° Cron Jobs
Schedule
Description
0 1 1 * *
Runs on the 1st of every month at 01:00 AM to automatically generate unpaid rent records for active members and advance their nextRentDate.
π License
This project is licensed under the MIT License.
Built with β€οΈ by Taj Uddin
π§ Contact: tajuddin.cse.dev@gmail.com
About
NEXORA-Server is the secure and scalable backend API powering the Nexora web application. Built with Node.js, Express, and MongoDB, it handles authentication, user roles, data management, and seamless communication between the client and database. Designed for performance, security, and flexibility in a modern full-stack environment.