Steps:
-
Initialize Project
mkdir gbewaa-clms && cd gbewaa-clms npm init -y npm install express sequelize pg pg-hstore jsonwebtoken bcrypt cors dotenv pdfkit
-
Folder Structure
src/ ├── config/ │ └── db.js ├── models/ │ ├── User.js │ ├── LandPlot.js │ └── Transaction.js ├── controllers/ ├── services/ ├── routes/ ├── middlewares/ ├── utils/ └── server.js -
Setup DB connection (
config/db.js). -
Define Models (
User.js,LandPlot.js,Transaction.js). -
Sync DB & Test Connection (
sequelize.sync()).
✅ End of Week 1: You can connect to PostgreSQL and see tables created.
Steps:
-
Auth Service → register/login using
bcryptfor passwords. -
JWT Tokens → issue on login.
-
Middleware (
middlewares/auth.js):- Verify token.
- Check role (ADMIN, STAFF, AUDITOR).
-
Routes (
routes/auth.js):POST /auth/register(admin only).POST /auth/login.
✅ End of Week 2: You can log in, get a token, and protect routes.
Steps:
-
Land Service + Controller (
landService.js,landController.js):POST /lands→ Add land.GET /lands→ List lands.PUT /lands/:id→ Update status.
-
Transaction Service + Controller (
transactionService.js,transactionController.js):POST /transactions→ Record sale → auto-calc commission.GET /transactions→ List sales.
-
Commission Logic → inside service (e.g.
commission = price * 0.1). -
Routes (
routes/lands.js,routes/transactions.js).
✅ End of Week 3: You can create land plots, record sales, and auto-calc commission.
Steps:
-
Reports API (
reportsController.js):-
GET /reports/summary→ returns:- Total lands sold
- Revenue earned
- Total commission
- Disputed plots count
-
-
PDF Receipts (
utils/pdfGenerator.jswithpdfkit):- Auto-generate receipt on
POST /transactions. - Include buyer, seller, plot number, price, commission, date.
- Auto-generate receipt on
-
Testing:
- Run Postman tests for all APIs.
- Add seed data (fake lands + sales).
-
Deploy: Push to GitHub → Deploy on Render/Heroku.
✅ End of Week 4: You have a working backend with secure APIs, reports, and PDF receipts.
-
Fully working CLMS backend with:
- Auth (JWT + roles)
- Land registry
- Sales + commission tracking
- Reports
- PDF receipts
-
Ready for real data entry at Gbewaa Palace 🚀