π€ AI Interview Preparation Coach
An AI-powered interview preparation coach built using the Groq API, designed to help job seekers practice interviews, get real-time responses, and improve their confidence before facing real interviews.
π Features
β
AI-Powered Questions β Get intelligent and tailored interview questions based on your role & experience.
β
Answer Coaching β Practice and receive feedback like a real interviewer.
β
Session Management β Create, manage, and revisit your mock interview sessions.
β
Pin Important Questions β Highlight questions you want to revisit later.
β
Secure Auth β User authentication with JWT and cookie-based sessions.
β
Export Functionality β Download your questions & answers in PDF, CSV, or DOCX.
β
Rate Limiting β Redis-based protection against abuse.
β
Caching β 30β40 % API-cost reduction through intelligent Redis caching.
β
Async Processing β Bull Queue for background AI generation & exports.
β
Docker Ready β One-command spin-up with docker-compose.
π οΈ Tech Stack
Backend: Express.js π + MongoDB π
AI Integration: Google Gemini API β Groq API (faster, cheaper, production-grade)
Auth & Security: JWT π + bcryptjs π
Cache & Queue: Redis + Bull
Export Engine: Puppeteer (PDF), csv-writer, docx-templates
Container: Node 20-alpine, MongoDB 7, Redis 7
- JWT auth with bcrypt password hashing & cookie sessions
- Create, update, delete, list interview prep sessions
- Groq-powered question generation with 24 h Redis cache
- Pin/unpin questions, full-text search, per-session stats
- Async export jobs (PDF, CSV, DOCX) with download links
- Distributed rate-limiting (auth, generation, export)
- Health, metrics, graceful shutdown, Docker & Compose
- Helmet, CORS, input validation, XSS & NoSQL-injection protection
- Node.js 18 +
- MongoDB 5 + (or Docker)
- Redis 6 + (or Docker)
- Groq API key (free tier works)
-
Clone & enter
git clone
cd intervai-backend -
Install
npm install -
Configure
cp .env.example .env -
Run
npm run dev
npm run worker:dev
- cp .env.example .env # fill production values
- docker-compose up --build -d
- docker-compose logs -f # watch
- docker-compose down -v # full cleanup
intervai-backend/
βββ config/ # db, redis, queue config
βββ controllers/ # route handlers
βββ middlewares/ # auth, rate-limit, validation
βββ models/ # Mongoose schemas
βββ routes/ # REST v1 endpoints
βββ services/ # cache, export, groq wrappers
βββ exports/ # generated files (git-ignored)
βββ index.js # API entry
βββ worker.js # Bull worker entry
βββ docker-compose.yml
POST /api/v1/user/register
POST /api/v1/user/login
POST /api/v1/user/logout
GET /api/v1/user/profile
PUT /api/v1/user/profile
POST /api/v1/session/create
GET /api/v1/session
GET /api/v1/session/:id
PUT /api/v1/session/:id
DELETE /api/v1/session/:id
POST /api/v1/question/generate
POST /api/v1/question/:id/regenerate
GET /api/v1/question/session/:sessionId
GET /api/v1/question/session/:sessionId/pinned
GET /api/v1/question/session/:sessionId/stats
GET /api/v1/question/search?q=term
GET /api/v1/question/:id
POST /api/v1/question/custom
PUT /api/v1/question/:id
PATCH /api/v1/question/:id/toggle-pin
DELETE /api/v1/question/:id
GET /api/v1/export/session/:sessionId?format=pdf|csv|docx
GET /api/v1/export/status/:jobId
GET /api/v1/export/download/:filename
GET /api/v1/queue/job/:jobId
GET /health
| Variable | Description | Example |
|---|---|---|
| PORT | Server port | 5000 |
| NODE_ENV | Environment | production |
| MONGO_URI | MongoDB connection | mongodb://admin:password@mongodb:27017/intervai?authSource=admin |
| JWT_SECRET | 32+ random chars | 9f8a3b2c... |
| GROQ_API_KEY | Groq console | gsk_... |
| REDIS_HOST | redis (service name) | redis |
| REDIS_PORT | 6379 | 6379 |
| CLIENT_URL | your frontend | https://app.intervai.com |
- mongodb β official 7.0 image, persistent volume
- redis β official 7-alpine, persistent volume
- api β Node app, port 5000, restart unless-stopped
- worker β same image, runs worker.js, restart unless-stopped
curl https://api.intervai.com/health # returns {βstatusβ:βokβ,βtsβ:...}
docker-compose logs -f api
docker-compose logs -f worker
docker exec -it intervai-redis redis-cli
PING
KEYS questions:*
docker exec -it intervai-mongodb mongosh -u admin -p adminpassword
use intervai_db
db.users.countDocuments()
curl -X POST http://localhost:5000/api/v1/user/register -H "Content-Type: application/json" -d '{"fullname":"Jane Doe","email":"jane@example.com","password":"pass1234"}'
curl -X POST http://localhost:5000/api/v1/user/login -H "Content-Type: application/json" -d '{"email":"jane@example.com","password":"pass1234"}' -c cookies.txt
curl -X POST http://localhost:5000/api/v1/session/create -H "Content-Type: application/json" -b cookies.txt -d '{"role":"Full-Stack Developer","experience":"senior","topicsToFocus":["System Design","Node.js","PostgreSQL"]}'
curl -X POST http://localhost:5000/api/v1/question/generate -H "Content-Type: application/json" -b cookies.txt -d '{"sessionId":"SESSION_ID_HERE"}'
curl -X GET "http://localhost:5000/api/v1/export/session/SESSION_ID?format=pdf" -b cookies.txt -o interview.pdf
- .env filled with production secrets
- NODE_ENV=production
- JWT_SECRET 32+ random chars
- MongoDB users & roles hardened
- Redis protected with requirepass
- API behind HTTPS (Letβs Encrypt / CDN)
- Firewall: 443, 80 open; 27017, 6379 closed externally
- Log aggregation (Loki, CloudWatch, etc.)
- Daily MongoDB + Redis snapshots
- Enable Docker restart policies & auto-updates
- Redis cache TTL = 24 h for identical question prompts
- Bull default concurrency = 5 (tunable via WORKER_CONCURRENCY)
- Mongo indexed on userId, sessionId, isPinned, createdAt
- Connection pooling: max 10 (configurable)
- Helmet sets HSTS, X-Frame-Options, X-XSS-Protection
- CORS whitelist to CLIENT_URL only
- Rate-limit: auth 5/min, generation 10/min, export 5/min per IP
- Joi validation + mongo-sanitize against NoSQL injection
- bcrypt 12 rounds
- JWT http-only, secure, same-site strict cookies
MIT β feel free to fork.
Issues & PRs welcome; please open against main branch.
I'll see you in the next one! π