No description
- JavaScript 65.3%
- CSS 17.3%
- HTML 16.9%
- Dockerfile 0.5%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| node_modules | ||
| public | ||
| .dockerignore | ||
| .gitignore | ||
| AGENTS.md | ||
| database.sqlite | ||
| db.js | ||
| DBREADME.md | ||
| docker-compose.yml | ||
| Dockerfile | ||
| find_duplicates.js | ||
| importer.js | ||
| mailer.js | ||
| package-lock.json | ||
| package.json | ||
| README.md | ||
| server.js | ||
| test_import.js | ||
AuditGate
Access Control User Audit Tool - Import, browse, and audit security log credentials from physical access keypads.
Features
- HTML Report Import - Automatically parse and import access control logs from HTML files
- Dashboard - Overview of all imported records with statistics
- Browse & Search - Navigate by floor/zone, filter by file, search by name or ID
- Export - Download data as CSV or Excel (XLSX) files
- Deduplication - Find and remove duplicate entries by ID number or user name
- Admin Controls - Edit and delete individual records (admin only)
- OAuth Authentication - Configurable OAuth2 SSO with role-based access (admin/user)
- Database Backup/Restore - Download backups and restore from previous snapshots
- Dark/Light Theme - Toggle between themes with system preference detection
Tech Stack
- Backend: Node.js 20, Express 5.2.1, SQLite3 6.0.1
- Frontend: Vanilla JavaScript, HTML5, CSS3
- HTML Parsing: Cheerio 1.2.0
- Export: SheetJS (XLSX via CDN)
- Deployment: Docker multi-stage build
Quick Start
Local Development
# Install dependencies
npm install
# Start the server
node server.js
# Open in browser
http://localhost:3000
Docker
# Build and run with docker-compose
docker-compose up --build
# Or build manually
docker build -t auditgate .
docker run -p 3000:3000 auditgate
Environment Variables
| Variable | Default | Description |
|---|---|---|
PORT |
3000 |
Server port |
DB_PATH |
./database.sqlite |
SQLite database path |
IMPORT_DIR |
./Import |
HTML files import directory |
COOKIE_SECRET |
random | Session cookie signing key |
BYPASS_AUTH |
false |
Set to true to skip OAuth |
Project Structure
auditgate/
├── server.js # Express server, auth, API routes
├── db.js # SQLite setup with promisified helpers
├── importer.js # HTML parsing and import logic
├── public/ # Frontend files
│ ├── index.html # SPA main page
│ ├── app.js # Frontend JavaScript
│ └── style.css # Styles with dark/light themes
├── Import/ # HTML report files
│ └── {floor}/
│ └── {zone}/
│ └── *.html
├── Dockerfile # Multi-stage Docker build
├── docker-compose.yml # Docker Compose config
└── package.json # Node.js dependencies
Import Directory Structure
HTML files should be organized in a folder hierarchy:
Import/
├── Penthouse/
│ ├── North/
│ │ ├── report1.html
│ │ └── report2.html
│ └── South/
│ └── report3.html
└── GroundFloor/
└── Zone1/
└── report4.html
- Top-level folder = Floor (e.g., "Penthouse", "GroundFloor")
- Sub-folder = Zone (e.g., "North", "South", "Zone1")
- HTML files = Access control reports to parse
API Endpoints
Authentication
GET /api/me- Get current session infoGET /login- Redirect to OAuth flowGET /login/callback- OAuth callback handlerGET /logout- Clear session
Settings (Admin)
GET /api/settings- Get OAuth configurationPOST /api/settings- Update settingsGET /api/user-roles- List user role mappingsPOST /api/user-roles- Add/update user roleDELETE /api/user-roles- Remove user role
Data
GET /api/navigation- Get floor/zone treeGET /api/stats- Get dashboard statisticsGET /api/files- List files in a zoneGET /api/records- Get records with pagination/searchGET /api/imported-files- List all imported files
Admin Operations
PUT /api/records/:id- Update a recordDELETE /api/records/:id- Delete a recordPOST /api/import- Trigger import scan
Deduplication
GET /api/duplicates- Find duplicate groupsPOST /api/deduplicate- Delete selected duplicates
Backup/Restore
GET /api/backup- Download database backupPOST /api/restore- Restore from backup
Authentication
First-Time Setup
- When OAuth is disabled (default), you're automatically logged in as admin
- To enable OAuth:
- Go to Settings > OAuth Configuration
- Enter your OAuth provider credentials
- Enable OAuth and save
Role-Based Access
- Admin - Full access: edit/delete records, manage users, run imports, backup/restore
- User - Read-only: browse data, export, search
The first user to log in via OAuth automatically becomes an admin.
Deduplication
The deduplication wizard helps remove duplicate entries:
- Select a floor/zone
- Click "Deduplicate"
- Choose criteria: ID Number or User Name
- Review each duplicate group
- Select which records to keep
- Click "Apply & Close" to delete unwanted duplicates
Backup & Restore
Creating a Backup
- Go to Settings > Database Backup
- Click "Download Backup"
- Save the
.sqlitefile
Restoring from Backup
- Go to Settings > Database Restore
- Click "Select Backup File"
- Choose your
.sqlitebackup file - Click "Restore Database"
- Confirm the action (current database is auto-backed up)
Development
Running Tests
# Test import functionality
node test_import.js
# Find duplicates in database
node find_duplicates.js
Code Style
- CommonJS modules (not ES modules)
- Async/await with promisified SQLite helpers
- No TypeScript or linting configured
License
ISC