AgileX A.G.I.L.E. Portal

Setup Guide & Architecture Explainer — Cloudflare Workers + Edge AI + D1 + Huly ATS + Microsoft 365

Cloudflare Workers Workers AI D1 Database KV Store Huly ATS Microsoft Graph 1,525 lines of code

1 What This Is

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:

2 Architecture

CF Cloudflare Edge — Security, CDN, Intelligence
WorkersAgent runtime
API + portal UI
Workers AILlama 3.1 8B
BGE embeddings
D1Candidates, vacancies
Agent state, logs
KVSessions, cache
Rate limits
DNS + CDNSSL/TLS, WAF
DDoS protection
AG A.G.I.L.E. Agent Workers
AcquireCV parsing
Profile creation
GaugeScoring
Auto-advance
IntegrateScheduling
Calendar sync
LeverageAnalytics
Reports
EngageNotifications
Nurture
Cloudflare Tunnel — outbound only
HZ Huly ATS — Minimal Metadata (Hetzner VPS or local SA server)
Huly Servicesfront, account
transactor, workspace
CockroachDBPipeline metadata
OneDrive URLs
ElasticsearchFull-text search
ResendSMTP email bridge
Microsoft Graph API — OAuth 2.0
MS Microsoft 365 — Golden Source of Records
OneDriveCVs, offers, refs
contracts, IDs
SharePointDocument libraries
Metadata columns
TeamsClient channels
Agent activity
Entra IDSSO / OAuth
User directory
OutlookCalendar
Email sync

Data Ownership Principle

ATS = Lightweight Metadata

Huly stores names, stages, skills tags, and OneDrive/SharePoint URLs. No binary documents. MinIO is used only for avatars and thumbnails.

M365 = Source of Truth

Every CV, offer letter, reference, scorecard, and contract is stored in OneDrive/SharePoint. Version history, compliance, and access control are managed by Microsoft.

3 A.G.I.L.E. Agents

Five autonomous agents handle the recruitment lifecycle. Each runs as a function inside the Cloudflare Worker with access to D1, KV, and Workers AI.

A

Acquire

CV parsing, sourcing, profile creation, deduplication

G

Gauge

Scoring, skills match, salary check, auto-advance

I

Integrate

Interview scheduling, calendar sync, Teams meetings

L

Leverage

Pipeline reports, dashboards, analytics, forecasts

E

Engage

Email notifications, rejection letters, Teams posts

How Agents Use Edge AI

1
Request arrives

CV text, candidate ID, or command

2
Workers AI

Llama 3.1 8B processes at the edge — zero cold start

3
D1 Updated

Candidate created or updated in database

4
M365 Sync

Document uploaded to OneDrive, link stored in ATS

5
Notification

Teams post + email sent via Resend

4 Technology Stack

LayerTechnologyPurposeTier
RuntimeCloudflare WorkersAgent logic, API, portal hostingFree 100K/day
AIWorkers AI (Llama 3.1 8B)CV parsing, scoring, drafting at edge~$5–20/mo
EmbeddingsWorkers AI (BGE Base)Candidate semantic searchIncluded
DatabaseCloudflare D1 (SQLite)Candidates, vacancies, clients, activityFree 5M reads/day
CacheCloudflare KVSessions, rate limits, response cacheFree 100K reads/day
ATSHuly (Docker)Recruitment pipeline, candidate trackingOpen source
DocumentsMicrosoft 365CVs, offers, contracts (golden source)~R110/user
EmailResendTransactional email (candidate comms)Free 100/day
Hosting (ATS)Hetzner CPX31Docker host for Huly stack~R280/mo
LanguageTypeScriptAll worker code

5 Project Structure

agilex-portal/ ├── wrangler.toml — Worker config: AI, D1, KV bindings ├── package.json — Dependencies: wrangler, workers-types, typescript ├── tsconfig.json — TypeScript config (ES2022, bundler) ├── schema.sql — D1 database schema (6 tables) ├── public/ │ ├── index.html — Interactive portal UI (430 lines) │ └── setup.html — This document └── src/ ├── index.ts — Worker entry: router, CORS, types (97 lines) ├── agents/ │ └── router.ts — A.G.I.L.E. agent logic: A,G,I,L,E (378 lines) ├── api/ │ ├── candidates.ts — CRUD for candidates (52 lines) │ ├── ai.ts — Edge AI inference + embeddings (88 lines) │ ├── activity.ts — Agent activity feed (14 lines) │ ├── huly.ts — Huly ATS bridge + integration map (74 lines) │ └── seed.ts — Demo data seeder (94 lines) └── sim/ └── m365.ts — Simulated Microsoft Graph API (212 lines)

Total: 1,525 lines of TypeScript + HTML across 11 files.

D1 Database Schema (6 tables)

TablePurposeKey Columns
candidatesCandidate profiles + pipeline stagename, email, skills, stage, score, vacancy_id, onedrive_cv_url
vacanciesOpen positionstitle, client, salary, skills, consultant
clientsEnterprise client orgsname, industry, city
agent_activityAgent action logagent, action, details, model_used, tokens
documentsOneDrive/SharePoint linksentity_id, doc_type, onedrive_url, sharepoint_url
ai_usageAI inference trackingmodel, requests, tokens, cost_usd, cache_hits

6 API Reference

Agent Endpoints

MethodEndpointAgentDescription
POST/api/agents/acquire/parse-cvAcquireParse CV text with Edge AI → create candidate + OneDrive link
POST/api/agents/acquire/searchAcquireSearch candidates by name, skills, or title
POST/api/agents/gauge/scoreGaugeScore a candidate against their vacancy with AI
POST/api/agents/gauge/bulk-scoreGaugeScore all unscored candidates in batch
POST/api/agents/integrate/scheduleIntegrateSchedule interview → calendar + Teams meeting
POST/api/agents/leverage/reportLeverageGenerate pipeline report → SharePoint upload
POST/api/agents/leverage/dashboardLeverageFull analytics dashboard: pipeline, clients, activity, AI usage
POST/api/agents/engage/notifyEngageSend notification (email / Teams) to candidate or client
GET/api/agents/{name}/activityAnyGet recent activity for a specific agent

Data Endpoints

MethodEndpointDescription
GET/api/candidatesList candidates (filter by ?stage= or ?client=)
GET/api/candidates/:idGet candidate + linked documents
POST/api/candidatesCreate candidate manually
GET/api/activityAgent activity feed (?agent=&limit=)

AI Endpoints

MethodEndpointDescription
POST/api/ai/inferRaw edge AI inference (Llama 3.1 8B)
POST/api/ai/embedGenerate 768-dim embedding (BGE Base)
GET/api/ai/modelsList available edge + gateway models
GET/api/ai/statsAI usage analytics by model and date

M365 Simulation & Huly Bridge

MethodEndpointDescription
POST/api/m365/onedrive/uploadSimulated file upload → sharing link
GET/api/m365/onedrive/listList files in OneDrive (from D1 document_links)
GET/api/m365/sharepoint/siteSharePoint site info + document libraries
GET/api/m365/sharepoint/search?q=Search documents across SharePoint
GET/api/m365/teams/channelsList Teams channels (General, clients, agents)
POST/api/m365/teams/sendPost message to a Teams channel
GET/api/m365/entra/usersStaff directory from Entra ID
GET/api/m365/calendar/eventsUpcoming interviews and meetings
GET/api/huly/statusCheck Huly ATS connectivity
GET/api/huly/integrationFull integration map: endpoints, data model, deployment

7 Microsoft 365 Simulation

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.

OneDrive — Document Storage

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.

SharePoint — Searchable Libraries

Document libraries with metadata columns (Name, Vacancy, Stage, Client). Microsoft Search indexes all document content. Content types enforce schema consistency.

Teams — Agent Communication

Per-client channels for placement updates. Agent Activity channel for automated posts. Tabs embed the portal dashboard and pipeline board.

Entra ID — Authentication

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.

8 Huly ATS Bridge

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.

Integration Points

ServiceProtocolEndpointUsed For
Account APIJSON-RPC over POST/_accountssignUp, login, createWorkspace, invite, join
TransactorWebSocketws://_transactorCreate/update candidates, vacancies. All data mutations.
CollaboratorWebSocket + OTws://_collaboratorReal-time collaborative editing of notes

Huly stores metadata, not documents

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.

9 Edge AI — How It Works

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.

Models Used

ModelTypeAgent UseLatency
@cf/meta/llama-3.1-8b-instructLLM (text)CV parsing, scoring, email drafting~5–25 seconds
@cf/meta/llama-3.3-70b-instruct-fp8-fastLLM (text, larger)Complex reasoning, report generation~15–45 seconds
@cf/baai/bge-base-en-v1.5Embedding (768-dim)Semantic search, candidate matching<100ms

Proven: CV Parsing at Edge

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.

Getting Smarter

10 Setup & Deployment

Prerequisites

Local Development

# 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.

Deploy to Cloudflare

# 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

Current Deployment

11 Using the Demo Portal

Dashboard Tab

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.

A.G.I.L.E. Agents Tab

Click an agent card, then type commands in the chat input:

AgentTry ThisWhat Happens
AcquirePaste any CV textEdge AI parses it → candidate created → OneDrive link generated
AcquireType search PythonSearches D1 for candidates matching "Python"
GaugeType a candidate nameEdge AI scores them against their vacancy (0–100 with reasoning)
GaugeType bulkScores all unscored candidates in batch
IntegrateType a candidate nameSchedules interview → calendar event + Teams meeting link
LeverageType reportGenerates pipeline report → simulated SharePoint upload
LeverageType dashboardReturns full analytics: pipeline, clients, activity, AI usage
EngageType a candidate nameSends 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.

Pipeline Tab

Kanban board showing all candidates by stage. Cards show name, title, and AI score (colour-coded: green ≥80, amber ≥60, red <60).

M365 Layer Tab

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.

Huly Bridge Tab

Tests connectivity to the Huly ATS instance and shows the full integration map — endpoints, data model, and deployment options.

Edge AI Tab

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.

12 What's Next

Production Readiness (Weeks 2–4)

Intelligence Improvements