Setup Guide & Architecture Explainer — Cloudflare Workers + Edge AI + D1 + Huly ATS + Microsoft 365
The AgileX A.G.I.L.E. Portal is a working Cloudflare Workers application that demonstrates the full AgileX recruitment intelligence architecture. It is deployed at:
https://agilex-portal.ccodeimbila.workers.dev
Running on Cloudflare's global edge network — 300+ cities worldwide
It proves that:
Huly stores names, stages, skills tags, and OneDrive/SharePoint URLs. No binary documents. MinIO is used only for avatars and thumbnails.
Every CV, offer letter, reference, scorecard, and contract is stored in OneDrive/SharePoint. Version history, compliance, and access control are managed by Microsoft.
Five autonomous agents handle the recruitment lifecycle. Each runs as a function inside the Cloudflare Worker with access to D1, KV, and Workers AI.
CV parsing, sourcing, profile creation, deduplication
Scoring, skills match, salary check, auto-advance
Interview scheduling, calendar sync, Teams meetings
Pipeline reports, dashboards, analytics, forecasts
Email notifications, rejection letters, Teams posts
CV text, candidate ID, or command
Llama 3.1 8B processes at the edge — zero cold start
Candidate created or updated in database
Document uploaded to OneDrive, link stored in ATS
Teams post + email sent via Resend
| Layer | Technology | Purpose | Tier |
|---|---|---|---|
| Runtime | Cloudflare Workers | Agent logic, API, portal hosting | Free 100K/day |
| AI | Workers AI (Llama 3.1 8B) | CV parsing, scoring, drafting at edge | ~$5–20/mo |
| Embeddings | Workers AI (BGE Base) | Candidate semantic search | Included |
| Database | Cloudflare D1 (SQLite) | Candidates, vacancies, clients, activity | Free 5M reads/day |
| Cache | Cloudflare KV | Sessions, rate limits, response cache | Free 100K reads/day |
| ATS | Huly (Docker) | Recruitment pipeline, candidate tracking | Open source |
| Documents | Microsoft 365 | CVs, offers, contracts (golden source) | ~R110/user |
| Resend | Transactional email (candidate comms) | Free 100/day | |
| Hosting (ATS) | Hetzner CPX31 | Docker host for Huly stack | ~R280/mo |
| Language | TypeScript | All worker code | — |
Total: 1,525 lines of TypeScript + HTML across 11 files.
| Table | Purpose | Key Columns |
|---|---|---|
candidates | Candidate profiles + pipeline stage | name, email, skills, stage, score, vacancy_id, onedrive_cv_url |
vacancies | Open positions | title, client, salary, skills, consultant |
clients | Enterprise client orgs | name, industry, city |
agent_activity | Agent action log | agent, action, details, model_used, tokens |
documents | OneDrive/SharePoint links | entity_id, doc_type, onedrive_url, sharepoint_url |
ai_usage | AI inference tracking | model, requests, tokens, cost_usd, cache_hits |
| Method | Endpoint | Agent | Description |
|---|---|---|---|
| POST | /api/agents/acquire/parse-cv | Acquire | Parse CV text with Edge AI → create candidate + OneDrive link |
| POST | /api/agents/acquire/search | Acquire | Search candidates by name, skills, or title |
| POST | /api/agents/gauge/score | Gauge | Score a candidate against their vacancy with AI |
| POST | /api/agents/gauge/bulk-score | Gauge | Score all unscored candidates in batch |
| POST | /api/agents/integrate/schedule | Integrate | Schedule interview → calendar + Teams meeting |
| POST | /api/agents/leverage/report | Leverage | Generate pipeline report → SharePoint upload |
| POST | /api/agents/leverage/dashboard | Leverage | Full analytics dashboard: pipeline, clients, activity, AI usage |
| POST | /api/agents/engage/notify | Engage | Send notification (email / Teams) to candidate or client |
| GET | /api/agents/{name}/activity | Any | Get recent activity for a specific agent |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/candidates | List candidates (filter by ?stage= or ?client=) |
| GET | /api/candidates/:id | Get candidate + linked documents |
| POST | /api/candidates | Create candidate manually |
| GET | /api/activity | Agent activity feed (?agent=&limit=) |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/ai/infer | Raw edge AI inference (Llama 3.1 8B) |
| POST | /api/ai/embed | Generate 768-dim embedding (BGE Base) |
| GET | /api/ai/models | List available edge + gateway models |
| GET | /api/ai/stats | AI usage analytics by model and date |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/m365/onedrive/upload | Simulated file upload → sharing link |
| GET | /api/m365/onedrive/list | List files in OneDrive (from D1 document_links) |
| GET | /api/m365/sharepoint/site | SharePoint site info + document libraries |
| GET | /api/m365/sharepoint/search?q= | Search documents across SharePoint |
| GET | /api/m365/teams/channels | List Teams channels (General, clients, agents) |
| POST | /api/m365/teams/send | Post message to a Teams channel |
| GET | /api/m365/entra/users | Staff directory from Entra ID |
| GET | /api/m365/calendar/events | Upcoming interviews and meetings |
| GET | /api/huly/status | Check Huly ATS connectivity |
| GET | /api/huly/integration | Full integration map: endpoints, data model, deployment |
Every M365 endpoint returns a "simulated": true flag and the exact Microsoft Graph API call it represents. In production, these swap to real Graph API calls with OAuth tokens from Entra ID.
Agent uploads CV to /Candidates/Active/{Name}/ via PUT /me/drive/root:/{path}:/content. Gets back a sharing link stored in the ATS.
Folder structure: Candidates → Active / Placed / Archived. Clients → {Name} → Contracts, Briefs, Reports.
Document libraries with metadata columns (Name, Vacancy, Stage, Client). Microsoft Search indexes all document content. Content types enforce schema consistency.
Per-client channels for placement updates. Agent Activity channel for automated posts. Tabs embed the portal dashboard and pipeline board.
OpenID Connect SSO for user login. Service principal with client credentials for agent-to-Graph API access. Permissions: Files.ReadWrite.All, Sites.ReadWrite.All, ChannelMessage.Send.
The portal demonstrates how AgileX connects to any Huly instance — a local server in a South African office, a Hetzner VPS in Europe, or scaled elastically as needed.
| Service | Protocol | Endpoint | Used For |
|---|---|---|---|
| Account API | JSON-RPC over POST | /_accounts | signUp, login, createWorkspace, invite, join |
| Transactor | WebSocket | ws://_transactor | Create/update candidates, vacancies. All data mutations. |
| Collaborator | WebSocket + OT | ws://_collaborator | Real-time collaborative editing of notes |
A candidate record in Huly contains: name, email, phone, city, skills tags, pipeline stage, vacancy link, and OneDrive URLs to their CV, offer letter, references, and scorecards. The actual files never enter MinIO — they stay in M365 as the golden source.
Cloudflare Workers AI runs inference at the edge — in the data centre nearest to the request. No round-trip to a central API. Zero cold starts.
| Model | Type | Agent Use | Latency |
|---|---|---|---|
@cf/meta/llama-3.1-8b-instruct | LLM (text) | CV parsing, scoring, email drafting | ~5–25 seconds |
@cf/meta/llama-3.3-70b-instruct-fp8-fast | LLM (text, larger) | Complex reasoning, report generation | ~15–45 seconds |
@cf/baai/bge-base-en-v1.5 | Embedding (768-dim) | Semantic search, candidate matching | <100ms |
The Acquire agent was tested with a real CV. The Edge AI (Llama 3.1 8B) extracted:
{
"name": "Dr. Nomsa Khumalo",
"email": "nomsa.khumalo@gmail.com",
"phone": "+27 82 555 1234",
"city": "Johannesburg",
"title": "Senior ML Engineer",
"skills": "Python, TensorFlow, PyTorch, NLP, MLOps, Azure ML",
"experience_years": 8,
"current_company": "Discovery Health",
"salary_expectation": 1300000
}
The agent then stored the candidate in D1, generated a simulated OneDrive link, and logged the activity — all in a single Worker request.
npm install -g wranglerwrangler login# Clone and install
cd /Users/craig/Projects/AgileX/agilex-portal
npm install
# Initialise local D1 database
npm run db:init
# Start dev server (port 8788)
npm run dev
# Seed demo data
curl -X POST http://localhost:8788/api/seed
# Open portal
open http://localhost:8788
Note: Workers AI (edge inference) only works when deployed to Cloudflare. Locally, agents use fallback demo responses.
# Create remote D1 database (one-time)
wrangler d1 create agilex-portal
# Update wrangler.toml with the database_id
# Create KV namespace (one-time, or reuse existing)
wrangler kv namespace create CACHE
# Update wrangler.toml with the KV id
# Initialise remote D1 schema
wrangler d1 execute agilex-portal --remote --file=schema.sql
# Deploy worker + assets
npm run deploy
# Seed remote data
curl -X POST https://agilex-portal.<subdomain>.workers.dev/api/seed
agilex-portal.ccodeimbila.workers.devagilex-portal (e60b6084-b097-4ce9-b07f-2952c319129a) — WEUR regionCACHE (fa3239d69b08493da8e3acce91fca5e9)Shows real-time metrics (candidates, placements, offers, agent actions), the agent activity feed, and pipeline stage counts. Data comes from the D1 database via the Leverage agent's dashboard endpoint.
Click an agent card, then type commands in the chat input:
| Agent | Try This | What Happens |
|---|---|---|
| Acquire | Paste any CV text | Edge AI parses it → candidate created → OneDrive link generated |
| Acquire | Type search Python | Searches D1 for candidates matching "Python" |
| Gauge | Type a candidate name | Edge AI scores them against their vacancy (0–100 with reasoning) |
| Gauge | Type bulk | Scores all unscored candidates in batch |
| Integrate | Type a candidate name | Schedules interview → calendar event + Teams meeting link |
| Leverage | Type report | Generates pipeline report → simulated SharePoint upload |
| Leverage | Type dashboard | Returns full analytics: pipeline, clients, activity, AI usage |
| Engage | Type a candidate name | Sends stage-update notification (email template + Teams post) |
The right panel shows the raw JSON API response for every action — useful for developers integrating with the agents.
Kanban board showing all candidates by stage. Cards show name, title, and AI score (colour-coded: green ≥80, amber ≥60, red <60).
Click any card to see the simulated Microsoft Graph API response. Every response includes the exact Graph API endpoint that would be called in production, plus realistic response shapes.
Tests connectivity to the Huly ATS instance and shows the full integration map — endpoints, data model, and deployment options.
Raw inference playground. Type any prompt and run it against Llama 3.1 8B at the Cloudflare edge. Also test embedding generation (768 dimensions via BGE Base) and view the available model list.
app.agilex.co.za via Cloudflare DNS