This is the final project guide for installation, setup, roles, AI features, and running the system.
This project is a full-stack financial management system for Ngenda Primary School built with:
Frontend: HTML, Bootstrap 5, Vanilla JavaScriptBackend: Node.js, ExpressDatabase: MongoDB with MongooseAuthentication: JWTPDF Export: PuppeteerAI: local rule-based, explainable financial intelligence
The frontend is served directly by the backend, so one application command runs the whole system.
Install these before running the project:
Node.jsnpmMongoDB- a browser like
Google Chrome,Microsoft Edge, orFirefox
Recommended:
VS CodeMongoDB Compass
Ai financial/
├── backend/
│ ├── controllers/
│ ├── middleware/
│ ├── models/
│ ├── routes/
│ ├── services/
│ ├── templates/
│ ├── utils/
│ └── server.js
├── frontend/
│ ├── css/
│ ├── js/
│ ├── audit-logs.html
│ ├── dashboard.html
│ ├── expense.html
│ ├── income.html
│ ├── login.html
│ ├── receipts.html
│ ├── reports.html
│ ├── settings.html
│ ├── transactions.html
│ └── users.html
├── .env
├── .env.example
├── package.json
└── README.md
- JWT authentication
- role-based access control
- dashboard with summary cards and Chart.js
- income recording
- expense management
- transactions page with filters
- receipts page with reopen and print
- financial report generation
- real PDF export using Puppeteer
- audit logging
- school settings
- AI-based categorization
- anomaly detection
- AI report narratives
- budget deviation AI
- recurring transaction detection
- data quality score
- self-service password change
- admin password reset
Responsibilities:
- manage users
- assign roles
- activate or deactivate users
- reset passwords for users
- view all financial data
- view reports
- view anomaly alerts
- view audit logs
- configure school settings
Restrictions:
- cannot create income
- cannot create expense
- cannot edit financial transactions
- cannot delete financial transactions
Responsibilities:
- review and correct existing income records
- create, edit, and manage expenses
- review anomaly flags
- generate reports
- export PDF reports
- change own password
Restrictions:
- cannot create new cashier-style income entries
- cannot manage users
- cannot reset other users’ passwords
- cannot change school settings
Responsibilities:
- record incoming payments
- receive AI category suggestions
- generate receipts
- print receipts
- view own payment history
- view own receipts
- change own password
Restrictions:
- cannot manage expenses
- cannot edit old income records
- cannot delete old income records
- cannot manage users
- cannot access audit logs
- cannot access reports
- cannot change school settings
This system uses only local, rule-based AI logic. No external AI APIs are used.
- suggests a category from description keywords
- shows confidence level
- examples:
school fees payment->Feeselectricity bill->Utilities
- duplicate transaction detection
- zero or negative amount detection
- missing required fields detection
- category mismatch detection
- unusual expense detection using historical category averages
- generates summary text from:
- income
- expenses
- balance
- previous period comparison
- anomaly count
- compares expense totals against predefined thresholds
- highlights categories that are over or under expected budget
- detects repeated transactions with similar name, category, and amount
- gives a score out of
100 - score is based on:
- anomaly count
- high severity issues
- duplicates
- missing fields
The project uses .env.
Current configuration:
PORT=5000
MONGO_URI=mongodb://127.0.0.1:27017/ngenda-financial-reporting
JWT_SECRET=supersecretjwtkey
JWT_EXPIRES_IN=1dOpen terminal in:
c:\Users\TEMP.KAMANZI11\Desktop\Ai financial
Install dependencies:
npm installRun:
npm run seedThis creates:
- demo users
- initial settings
- sample income
- sample expense
- sample receipt
admin@ngenda.com / password123accountant@ngenda.com / Password123@cashier@ngenda.com / password123
Run:
npm run appThis will:
- start the backend
- serve the frontend
- open the browser automatically to the login page
Run:
npm run devThen open:
http://localhost:5000/login.html
LoginDashboardIncomeExpensesTransactionsReceiptsReportsUsersAudit LogsSettings
When a cashier records a payment:
- AI suggests category
- AI checks duplicates and suspicious fields
- receipt number is generated
- receipt opens automatically
- receipt can be printed immediately
Receipts can later be reopened and printed from:
IncomepageReceiptspage
When an accountant or admin generates a report:
- report period is selected
- totals are calculated from MongoDB data
- anomalies are counted
- AI summary is generated
- data quality score is generated
- budget deviation and recurring pattern insights are shown
- PDF can be downloaded through Puppeteer
All logged-in users can change their own password from:
Settingspage
Requirements:
- current password
- new password
- password confirmation
Admin can reset any user password from:
Userspage
This is useful for:
- forgotten password
- account recovery
- temporary password assignment
PDF generation is real server-side PDF generation using Puppeteer.
Main route:
GET /api/reports/:id/pdf
PDF includes:
- school header
- logo if available
- report title
- selected date range
- total income
- total expenses
- net balance
- category breakdown
- flagged anomalies
- AI summary
- generation date
- generating user
Install:
npm installSeed:
npm run seedRun and open browser automatically:
npm run appRun backend manually:
npm run dev- MongoDB must be running before seeding or starting the app
- the frontend is served by the backend
- no separate frontend server is required
npm run appis the easiest command for demos and presentation