Audit Engine is a Node.js + Express service that accepts seller onboarding call recordings, runs asynchronous AI analysis, and generates downloadable audit outputs (PDF, report JSON, transcript TXT).
- User portal (
/user): upload call audio and track job progress. - Admin portal (
/admin): monitor all jobs, view job id + status, and download:- generated PDF report,
- extracted JSON report,
- transcript text file.
- Async processing pipeline:
- Upload audio (
POST /jobs). - Job is queued in memory.
- Audio is transcribed using OpenAI.
- Checklist extraction is generated using a strict JSON schema.
- PDF report is produced and saved under
storage/audits. - Uploaded audio is retained for 24 hours (cleanup runs periodically) and then removed.
- Upload audio (
- Node.js (ES modules)
- Express
- Multer (file uploads)
- OpenAI API (transcription + analysis)
- PDFKit
- Static frontend (vanilla HTML/CSS/JS)
npm installcp .env.example .envSet:
OPENAI_API_KEYADMIN_TOKEN(long random string for admin APIs)- optional
PORT
npm run checknpm startEndpoints:
- User page:
http://localhost:3000/user - Admin page:
http://localhost:3000/admin - Health endpoint:
http://localhost:3000/health
POST /jobs(multipart/form-data:audio,sellerId) => queues a job. Supported audio formats:.mp3,.wav,.m4a.GET /jobs/:id=> fetch one job status.GET /sellers/:sellerId/jobs=> fetch jobs for seller.GET /admin/jobs=> admin list all jobs.GET /admin/jobs/:id/report=> admin download extracted report JSON.GET /admin/jobs/:id/transcript=> admin download transcript TXT.
Admin endpoints require:
Authorization: Bearer <ADMIN_TOKEN>If this app is not expected to get much load, keep deployment simple:
- 1 EC2 instance (Ubuntu)
- Node.js app managed by systemd
- Nginx reverse proxy
- HTTPS using Certbot directly on the same EC2
This avoids ALB/ECS complexity and is enough for small-to-moderate traffic.
Create .env on server:
PORT=3000
OPENAI_API_KEY=<your_key>
ADMIN_TOKEN=<very_long_random_secret>
NODE_ENV=production- Use a strong
ADMIN_TOKEN(32+ chars random). - Keep
.envout of git. - Ensure persistent disk space for
storage/audioandstorage/audits(audio retention defaults to 24 hours). - Enable HTTPS.
- Add at least a basic uptime check against
GET /health. - Restrict SSH in security groups.
- AMI: Ubuntu LTS
- Instance type:
t3.smallis enough for low traffic - Storage: start with 20+ GB gp3
- Security Group inbound rules:
22from your IP only80from anywhere (0.0.0.0/0)443from anywhere (0.0.0.0/0)
ssh -i <your-key>.pem ubuntu@<ec2-public-ip>
sudo apt update
sudo apt install -y nginx curl git
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt install -y nodejscd /opt
sudo git clone <your_repo_url> Audit_engine
cd Audit_engine
sudo chown -R ubuntu:ubuntu /opt/Audit_engine
npm ci --omit=dev
cp .env.example .envEdit .env and set:
PORT=3000
OPENAI_API_KEY=<your_key>
ADMIN_TOKEN=<very_long_random_secret>
NODE_ENV=productionSet permissions for runtime folders:
sudo mkdir -p storage/audio storage/audits
sudo chown -R ubuntu:ubuntu storageCreate /etc/systemd/system/audit-engine.service:
[Unit]
Description=Audit Engine
After=network.target
[Service]
Type=simple
WorkingDirectory=/opt/Audit_engine
ExecStart=/usr/bin/node src/server.js
Restart=always
RestartSec=5
Environment=NODE_ENV=production
EnvironmentFile=/opt/Audit_engine/.env
User=ubuntu
Group=ubuntu
[Install]
WantedBy=multi-user.targetEnable and run:
sudo systemctl daemon-reload
sudo systemctl enable audit-engine
sudo systemctl start audit-engine
sudo systemctl status audit-engineCreate /etc/nginx/sites-available/audit-engine:
server {
listen 80;
server_name your-domain.com;
client_max_body_size 50M;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}Enable and reload:
sudo ln -s /etc/nginx/sites-available/audit-engine /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx- In Route53 (or any DNS provider), create an
Arecord:- Name: your domain (for example
audit.yourdomain.com) - Value: your EC2 public IPv4 address
- Name: your domain (for example
- Wait for DNS to propagate.
sudo apt install -y certbot python3-certbot-nginx
sudo certbot --nginx -d your-domain.comCertbot will:
- install TLS certificate,
- update Nginx config,
- reload Nginx automatically.
Verify auto-renewal:
sudo systemctl status certbot.timer- Test app health:
curl http://127.0.0.1:3000/health- Follow logs:
sudo journalctl -u audit-engine -f- Restart app after deployment:
sudo systemctl restart audit-engine- Keep SSH (
22) restricted to your IP. - Take an AMI snapshot after successful setup.
- Move secrets to AWS Systems Manager Parameter Store later if needed.
- Add CloudWatch alarm on simple uptime check if desired.
If you move to ECS/Fargate later:
- build image and deploy as ECS service,
- place ALB in front,
- mount persistent storage (EFS) if you need local audit artifacts preserved,
- inject secrets from Secrets Manager.
Current job state is in-memory (Map) and will reset on restart/redeploy. For durable production usage, move job metadata to a persistent store (Postgres/Redis) and process jobs via a worker queue.