WebNest
Team/MD SAYED SHEIKH/ArcLane-server

Repository

ArcLane-server

View on GitHub ↗
JavaScript★ 0 stars⑂ 0 forks

README

🏢 Arclane Backend Server

This is the backend server for Arclane, a full-stack apartment management web application. It handles authentication, payment, role-based access control, apartment and user management, announcements, coupon verification, and more using Node.js, Express, Firebase Admin SDK, MongoDB, and Stripe.

🌐 Live API URL

https://arc-lane-server.vercel.app


📁 Project Structure


.
├── server.js # Main entry file
├── .env # Environment variables
├── package.json # Project dependencies
└── README.md # This file


🚀 Features

✅ Firebase Admin SDK for secure JWT authentication ✅ Stripe integration for secure rent payments ✅ Role-based access control (Admin, Member, User) ✅ RESTful API for apartments, agreements, coupons, users, payments, and announcements ✅ Admin can:

  • Accept or reject agreement requests
  • Remove members
  • Change coupon statuses ✅ Members can:
  • View their assigned apartment
  • Pay monthly rent and view history ✅ Secure endpoints with verifyToken, verifyEmail, verifyAdmin, and verifyMember middlewares ✅ Axios interceptor friendly ✅ All private API routes are JWT-protected ✅ Coupon system with status (active/expired) control ✅ MongoDB for data storage

📦 Dependencies

  • express
  • cors
  • dotenv
  • mongodb
  • firebase-admin
  • stripe

🔐 Environment Variables (.env)

Make sure to create a .env file in the root directory with the following variables:


PORT=3000
MONGO_URI=your_mongodb_connection_uri
STRIPE_SECRET_KEY=your_stripe_secret_key
FB_SERVICE_KEY=base64_encoded_firebase_admin_sdk_json

🔐 The FB_SERVICE_KEY is the base64 encoded version of your Firebase service account JSON file.

To encode it:

base64 firebase-adminsdk.json

🧪 How to Run Locally

  1. Clone the repository
git clone https://github.com/SayedSheikh/arclane-server.git
cd arclane-server
  1. Install dependencies
npm install
  1. Create .env file
# .env file
PORT=3000
MONGO_URI=your_mongodb_uri
STRIPE_SECRET_KEY=your_stripe_secret_key
FB_SERVICE_KEY=your_base64_encoded_firebase_admin_json
  1. Run the server
node server.js

🔐 API Security Middleware

MiddlewareDescription
verifyTokenValidates JWT token via Firebase Admin
verifyEmailCompares param email with token email
verifyAdminRestricts access to admin only routes
verifyMemberRestricts access to member only routes

📚 Major API Endpoints

👥 Authentication & Users

MethodEndpointDescription
POST/usersCreate or update user info
GET/users/role/:emailGet user role (user, admin, etc.)
GET/users/:emailGet all users (admin only)
GET/countUsersGet user count

🏘 Apartments & Agreements

MethodEndpointDescription
GET/apartments/:page/:size?search=min&max=...Filtered apartments list
GET/countApartmentsGet total apartment count
POST/agreement/:emailCreate new agreement
PATCH/updateAgStatus/:email/:agId?actionType=...Accept/reject agreement
GET/agreements/:emailGet all agreement requests

💳 Payments

MethodEndpointDescription
POST/create-payment-intentStripe payment intent
POST/paymentInfo/:emailSave payment info
GET/paymentHistory/:emailView payment history (member only)
PATCH/pendingPayments/:email/:agIdGet unpaid months for agreement

📢 Announcements

MethodEndpointDescription
GET/countAnnouncementsTotal number of posts
GET/announcements/:emailPaginated list (auth)
POST/announcements/:emailCreate announcement (admin)

🧾 Coupons

MethodEndpointDescription
GET/couponsGet all coupons
POST/coupon/:emailCreate new coupon (admin only)
PATCH/coupon/status/:email/:idUpdate status of a coupon (admin)
GET/couponVerify/:couponCodeVerify coupon and get discount

🧼 Member Management

MethodEndpointDescription
PATCH/remove/:email/:memIdAdmin removes a member
GET/memberApartment/:emailMember’s assigned unit

📊 Admin Dashboard Stats

MethodEndpointDescription
GET/dashboardStats/:emailAll statistics for admin

🧠 Additional Notes

  • You must pass a JWT token in Authorization: Bearer <token> header for all protected routes.
  • Only Flowbite is used for the frontend.
  • Built with scalability, modularity, and security in mind.
  • All errors are handled with appropriate HTTP status codes and messages.

Let me know if you want the same structure as a downloadable .md file or want to add Postman docs too.

← Back to profile