Skip to content

prisha-sh/Visitor-Management-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

12 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›‘οΈ Visitor Management System

A secure, full-stack visitor tracking solution for modern facilities

Node.js Express.js PostgreSQL Vercel License: MIT

🌐 Live Demo Β· πŸ“‹ API Docs Β· πŸš€ Quick Start


✨ Features

Feature Description
πŸ“‹ Smart Check-In/Out Register new visitors or quick check-in returning ones with auto-detection and visit history
πŸ“Š Live Dashboard Real-time stats β€” active visitors, today's visits, overstays, blacklisted β€” auto-refreshes every 30s
πŸ”’ Role-Based Access 3 roles (Admin, Receptionist, Security) with tailored permissions and page restrictions
🚫 Blacklist System Flag & block visitors with logged audit trails; auto-denied at check-in
πŸ• Overstay Detection Database triggers auto-update status when visitors exceed expected checkout time
πŸ“ Reports & Logs Verification logs, visit sessions with date/status filters, pagination
πŸš— Vehicle Tracking Vehicle number, type, and parking slot registration
πŸ‘₯ User Management Admin panel for creating, editing, and managing system users
⚑ Serverless Deploy Deployed on Vercel with Neon PostgreSQL β€” zero-config scaling

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    FRONTEND                         β”‚
β”‚  HTML5 + Vanilla CSS + JavaScript                   β”‚
β”‚  (Landing Β· Login Β· Dashboard Β· Check-In Β· Reports) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β”‚ REST API (JSON)
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  BACKEND (Express.js)                β”‚
β”‚  JWT Auth Β· RBAC Middleware Β· Validation             β”‚
β”‚  Controllers Β· Routes Β· Error Handling               β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β”‚ pg (node-postgres)
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              DATABASE (PostgreSQL / Neon)            β”‚
β”‚  8 Tables Β· 5 Triggers Β· 4 Stored Procedures        β”‚
β”‚  3 Views Β· Indexes Β· Constraints                     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ—„οΈ Database Schema

Tables

Table Purpose
USER_ACCOUNT System users (Admin, Receptionist, Security) with hashed passwords
VISITOR Visitor profiles with ID verification and blacklist status
VISIT_SESSION Check-in/out records, host info, purpose, status tracking
VEHICLE Visitor vehicle details and parking slot assignment
SECURITY_OFFICER Security officers with shift assignments
VERIFICATION_LOG Audit trail for all check-in/out/verification actions
BLACKLIST_LOG History of blacklist add/remove operations
SYSTEM_SETTINGS Configurable facility settings

Triggers & Automation

Trigger Function
trg_log_checkin Auto-logs check-in to VERIFICATION_LOG
trg_log_checkout Auto-logs check-out to VERIFICATION_LOG
trg_check_overstay Auto-updates status to Overstay when past expected time
trg_log_blacklist Auto-logs blacklist add/remove to BLACKLIST_LOG
trg_*_updated_at Auto-updates Updated_At timestamp on row changes

Stored Procedures

  • sp_register_and_checkin() β€” Register new visitor + create session in one transaction
  • sp_checkout_visitor() β€” Check-out with validation
  • sp_get_active_visitors() β€” Active visitors with duration calculation
  • sp_get_visitor_history() β€” Complete visit history for a visitor

πŸ” Role-Based Access Control

Capability Admin Receptionist Security
Dashboard βœ… βœ… βœ…
Check-In Visitors βœ… βœ… ❌
Check-Out Visitors βœ… βœ… ❌
View Visitor List βœ… βœ… βœ…
Edit Visitors βœ… βœ… ❌
Delete Visitors βœ… ❌ ❌
Blacklist Management βœ… ❌ ❌
Reports & Logs βœ… ❌ ❌
User Management βœ… ❌ ❌

πŸ› οΈ Tech Stack

Layer Technology
Frontend HTML5, Vanilla CSS, JavaScript
Backend Node.js, Express.js
Database PostgreSQL (Neon)
Authentication JWT + bcrypt.js
Validation express-validator
Deployment Vercel (Serverless)

πŸš€ Quick Start

Prerequisites

  • Node.js β‰₯ 18
  • PostgreSQL (local) or Neon account

1. Clone the Repository

git clone https://github.com/prisha-sh/Visitor-Management-System.git
cd Visitor-Management-System

2. Install Dependencies

cd backend
npm install

3. Configure Environment

Create backend/.env:

PORT=8000
NODE_ENV=development

# Database (Local PostgreSQL)
DATABASE_URL=postgresql://user:password@localhost:5432/visitor_management_system

# JWT
JWT_SECRET=your_super_secret_key_here
JWT_EXPIRE=7d

# Bcrypt
BCRYPT_ROUNDS=10

4. Set Up Database

# Create database and run schema
psql -U postgres -f database/schema_pg.sql

# Seed sample data
psql -U postgres -d visitor_management_system -f database/seed_pg.sql

5. Start the Server

npm run dev
# Server starts at http://localhost:8000

6. Open the App

Visit http://localhost:8000 β€” you'll see the landing page, then navigate to Login.


πŸ”‘ Demo Credentials

Role Username Password
πŸ”΄ Admin admin admin123
🟒 Security security1 admin123
🟑 Receptionist reception1 admin123

πŸ“‘ API Endpoints

Authentication

Method Endpoint Description
POST /api/auth/login User login β†’ returns JWT
GET /api/auth/verify Verify token validity

Visitors

Method Endpoint Description
GET /api/visitors List all visitors (paginated, filterable)
GET /api/visitors/:id Get visitor details
GET /api/visitors/search?query= Search by name/contact/ID
GET /api/visitors/:id/history Get visit history
POST /api/visitors Create visitor
PUT /api/visitors/:id Update visitor
DELETE /api/visitors/:id Delete visitor (Admin)
POST /api/visitors/:id/blacklist Blacklist visitor
DELETE /api/visitors/:id/blacklist Remove from blacklist

Visit Sessions

Method Endpoint Description
GET /api/sessions/active Get currently checked-in visitors
POST /api/sessions/checkin New visitor check-in
POST /api/sessions/quick-checkin Returning visitor check-in
PUT /api/sessions/:id/checkout Check-out visitor

Reports (Admin)

Method Endpoint Description
GET /api/reports/dashboard Dashboard statistics
GET /api/reports/verification-logs Verification log report
GET /api/reports/visit-sessions Visit session report

Users (Admin)

Method Endpoint Description
GET /api/users List all users
POST /api/users Create user
PUT /api/users/:id Update user
PUT /api/users/:id/toggle-active Activate/deactivate user

πŸ“ Project Structure

Visitor-Management-System/
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ index.html          # Landing page (project showcase)
β”‚   β”œβ”€β”€ login.html          # Authentication page
β”‚   β”œβ”€β”€ dashboard.html      # Main dashboard with stats
β”‚   β”œβ”€β”€ checkin.html        # Visitor check-in form
β”‚   β”œβ”€β”€ checkout.html       # Visitor check-out
β”‚   β”œβ”€β”€ visitors.html       # Visitor management table
β”‚   β”œβ”€β”€ reports.html        # Reports & verification logs
β”‚   β”œβ”€β”€ users.html          # User management (Admin)
β”‚   └── assets/images/      # Preview images
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ server.js           # Express app entry point
β”‚   β”œβ”€β”€ config/db.js        # PostgreSQL connection pool
β”‚   β”œβ”€β”€ middleware/
β”‚   β”‚   β”œβ”€β”€ auth.js         # JWT authentication
β”‚   β”‚   └── errorHandler.js # Global error handler
β”‚   β”œβ”€β”€ controllers/        # Business logic
β”‚   β”œβ”€β”€ routes/             # API route definitions
β”‚   └── utils/              # Validation & helpers
β”œβ”€β”€ database/
β”‚   β”œβ”€β”€ schema_pg.sql       # PostgreSQL schema + triggers
β”‚   └── seed_pg.sql         # Sample data
β”œβ”€β”€ api/index.js            # Vercel serverless entry
β”œβ”€β”€ vercel.json             # Vercel deployment config
└── package.json

🌐 Deployment (Vercel)

The project is configured for Vercel serverless deployment:

  1. Push to GitHub
  2. Import in Vercel β†’ Link your repository
  3. Add Environment Variables in Vercel dashboard:
    • DATABASE_URL β€” Neon PostgreSQL connection string
    • JWT_SECRET β€” Your JWT signing secret
  4. Deploy β€” Vercel auto-detects vercel.json config

πŸ“„ License

This project is open source and available under the MIT License.


Built with ❀️ by Prisha Sharma

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors