Go backend · MongoDB · Vanilla JS — Social networking and professional recruitment platform with real-time chat, feed, and events.
Prerequisites: Go 1.25+, MongoDB 6.0+, Docker (optional)
# Clone
git clone https://github.com/alextitosdev/hirekey.git
cd hirekey
# Option A: Run with Docker Compose (recommended)
# Note: Config is baked into src/env.go. Edit before build.
docker compose up -d
# Option B: Run natively
make runExpected output:
HireKey starting...
Server starting on :8080
Access: http://localhost:8080
Stop containers: docker compose down
| Layer | Technology |
|---|---|
| Language | Go 1.25 |
| Database | MongoDB 7.0 |
| Frontend | Vanilla JavaScript (ES modules) |
| Templates | Go html/template |
| Auth | Cookie-based sessions + 2FA |
| Map Rendering | Leaflet.js |
| Container | Docker / docker-compose |
| Reverse Proxy | Nginx (TLS, static serving, proxy) |
| OS Service | systemd |
flowchart TD
subgraph Client["Browser (PWA)"]
UI[Vanilla JS]
SW[Service Worker]
end
subgraph Infra["Infrastructure"]
NGINX[Nginx Reverse Proxy\nTLS termination]
APP[HireKey Go Server\nport 8080]
end
subgraph Storage["Data Layer"]
MONGO[(MongoDB 7.0\nprofiles, posts,\nmessages, events)]
VOL[Mongo Volume\npersistent data]
end
UI -->|HTTP /api/*| NGINX
NGINX -->|proxy_pass| APP
UI -->|/static/*| NGINX
SW -->|cache-first| UI
APP -->|MongoDB| MONGO
MONGO --> VOL
style Client fill:#f0f0f0,stroke:#333
style Infra fill:#e1f5fe,stroke:#0277bd
style Storage fill:#e8f5e9,stroke:#2e7d32
All runtime config lives in src/env.go as Go variables — no .env parsing, you must edit the file directly:
var MongoDBURL string = "mongodb://localhost:27017"
var DBName string = "hirekey"
var Port string = "8080"
var EnableLogin bool = true
// ... mock togglesNo schema migration required. Collections are created on first insert. For a clean state:
# Drop database (development)
mongosh --eval "db.getSiblingDB('hirekey').dropDatabase()"
# Or in docker-compose:
docker compose down -v && docker compose up -d# Native build (static binary, no CGO)
make build
ls -lh build/hirekey
# Docker build (multi-stage, ~65MB final image)
docker compose build --no-cacheExpected build output:
==> Building hirekey...
==> Build complete: build/hirekey
Static binary verification:
ldd build/hirekey
# not a dynamic executable# docker-compose.yml included in repository
# Services: hirekey-app, hirekey-mongo
# Volume: mongo-data (persistent)
# Health check: mongosh ping every 10s
# Logging: json-file driver, 10MB max, 3 files retained# Deploy binary
sudo cp build/hirekey /opt/hirekey/
sudo chown hirekey:hirekey /opt/hirekey/hirekey
# Configure environment
sudo cp deploy/env.example /etc/hirekey/env
sudo nano /etc/hirekey/env # Edit MongoDB URI, etc.
# Enable service
sudo cp deploy/hirekey.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now hirekey
sudo systemctl status hirekeyHardening features in the systemd unit:
NoNewPrivileges=true— cannot escalateProtectSystem=strict— read-only filesystem (except/opt/hirekey)PrivateTmp=true— isolated temp directoryReadWritePaths=/opt/hirekey— only app dir is writable
- Stateless app layer — multiple
hirekey-appinstances behind a load balancer work identically. Session state lives in MongoDB, not memory. - MongoDB — use a replica set for production. The app uses a single connection URI that supports failover.
- Connection pooling — the mongo-driver handles pooling internally. Tune via
MONGO_URIparameters (maxPoolSize,minPoolSize) if needed. - Story garbage collection — runs every 5 minutes in a goroutine. For high-traffic, consider moving to a dedicated worker process or MongoDB TTL index.
- Application logs — written to
stderr, collected by systemd journal or Docker logging driver. - Structured log entries via
log.Printfwith severity context (errors include the error object). - MongoDB slow queries — monitor with
db.collection.find(...).explain("executionStats"). - Process metrics — add a
/metricsendpoint by wiring inprometheus/client_golangfor Go runtime stats (goroutines, heap, etc.).
hirekey/
├── cmd/server/main.go # Entry point
├── src/
│ ├── api.go # API handlers
│ ├── chat.go # Chat message endpoints
│ ├── login.go # Auth middleware, session mgmt
│ ├── web.go # HTTP routing, template serving
│ ├── env.go # Runtime configuration
│ ├── utils.go # Input sanitization
│ ├── utils_api.go # Profile resolution, JSON helpers
│ ├── types_*.go # Type definitions (22 files)
│ ├── mock_*.go # Mock data seeding
│ ├── templates/ # HTML templates
│ └── static/ # CSS, JS, images, fonts, PWA
├── deploy/
│ ├── hirekey.service # Systemd unit
│ └── hirekey-nginx.conf # Reverse proxy config
├── docker-compose.yml # Multi-service deployment
├── Dockerfile # Multi-stage build
├── Makefile # Build/run/deploy commands
├── .gitignore
├── go.mod
├── go.sum
└── README.md
CC BY-NC 4.0 — free for personal and educational use. Commercial licensing available on request.


