Project Forensa - Forensic-Medicine-Database
Team
- E/22/184, Bhagya Karunanayake
- E/22/151, Imaadh Ifthikar
- E/22/320, Rashad Shamil
- E/22/193, S. Kishonithan
Forensic Medicine Database System (FMDBS)
CO 2050 โ Database System Module Project
Computer Engineering | Faculty of Engineering | University of Peradeniya
Designed and engineered by Tira-miss-u
A comprehensive, scalable, and secure system for managing forensic medicine records, including Clinical Cases, Autopsy Cases, Specimen Logs, and Dispatch Reports. Built to modernize legacy MS Access databases into a normalized, RBAC-protected web application.
๐ Tech Stack
- Frontend: Vanilla JavaScript (ES6+), Vite, TailwindCSS
- Backend: Node.js, Express.js
- Database: PostgreSQL (Dockerized)
- Testing: Jest, Supertest
๐ ๏ธ Features
- Robust Backend Architecture: Express REST API following strict MVC patterns.
- Role-Based Access Control (RBAC): JWT authentication with granular permissions across roles (
super_admin,doctor,clerk,lab_staff,photographer). - Normalized Schema (3NF/BCNF): Architected from complex ER diagrams to ensure data integrity and remove redundancies.
- Adversarial Resiliency:
- Comprehensive protection against SQL Injection via parameterized
pgqueries. - Strict Database constraints (Unique, Foreign Keys, Not Null).
- State machine enforcement preventing invalid backward status transitions on cases.
express-validatorschema validations to gracefully handle malformed data inputs.
- Comprehensive protection against SQL Injection via parameterized
- Audit Logging: Asynchronous tracking of user modifications across core tables.
๐ Project Structure
Forensic-Medicine-Database/
โโโ backend/
โ โโโ src/
โ โ โโโ config/ # DB Pool & Environment configs
โ โ โโโ controllers/ # Core business logic handling
โ โ โโโ db/ # Migrations, Seeds, and Scripts
โ โ โโโ middleware/ # Auth, RBAC, Validation, Error Handling
โ โ โโโ routes/ # Express route definitions
โ โ โโโ utils/ # Error mapping and async wrappers
โ โโโ tests/ # Jest Suites (Integration, Adversarial)
โ โโโ server.js # Entry point
โโโ src/ # Frontend Vite Source code (Vanilla JS)
โโโ index.html # Main UI Template
โโโ package.json
โ๏ธ Installation & Setup
- Clone the repository:
git clone https://github.com/imaadh-ifthi/Forensic-Medicine-Database.git cd Forensic-Medicine-Database - Setup Frontend:
npm install npm run dev - Setup Backend:
cd backend npm install - Environment Variables:
Create a
.envfile in thebackend/directory:NODE_ENV=development PORT=3000 DB_USER=postgres DB_PASSWORD=yourpassword DB_HOST=127.0.0.1 DB_PORT=5433 DB_NAME=fmdbs JWT_SECRET=super_secret_jwt_signature_key_2026 JWT_EXPIRES_IN=24h - Start PostgreSQL Container (if using Docker):
docker-compose up -d - Run Database Migrations & Seeds:
Navigate to
backend/and execute the migration script to build the 3NF schemas and populate realistic test data:node src/db/migrate.js - Run the API:
npm run dev
๐งช Testing
The backend contains a rigorous, adversarial Jest suite covering Auth Bypass attempts, Data Integrity failures, Concurrency/Race condition handling, and complete Integration workflows.
To run the test suite:
cd backend
npm test
๐งโโ๏ธ Dummy Accounts (Seed Data)
After running the seed script, you can log in using the following test accounts:
- Admin:
admin/password123 - Doctor:
dr_ameen/password123 - Clerk:
clerk1/password123