A full-stack application for generating, verifying, and managing Halal certificates. The backend is a Python-based uAgent with REST endpoints; the frontend is a React + Vite application.
HCO/
├── agents/ # Backend — Python uAgent (port 8096)
├── frontend/ # Frontend — React + Vite + TypeScript (port 5173)
└── README.md
- Python 3.11+
- Node.js 18+ and npm 9+
- PostgreSQL (optional — falls back to local JSON storage)
- WeasyPrint system dependencies (for PDF generation)
- OpenAI API key (required for certificate verification and product matching)
- Microsoft Azure app registration (optional — for Excel/OneDrive integration)
WeasyPrint requires native libraries for PDF rendering:
# macOS
brew install cairo pango gdk-pixbuf libffi
# Ubuntu / Debian
sudo apt-get install -y build-essential libglib2.0-0 libcairo2 \
libpango-1.0-0 libpangocairo-1.0-0 libgdk-pixbuf-2.0-0 shared-mime-infocd agents
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txtcp .env.example .envEdit .env and fill in the required values:
| Variable | Description |
|---|---|
OPENAI_API_KEY |
OpenAI API key (used for verification, product matching, and chat) |
| Variable | Description |
|---|---|
DATABASE_URL |
PostgreSQL connection string, e.g. postgresql://user:pass@localhost:5432/hco |
CERT_OUTPUT_DIR |
Local directory for generated certificate files (default: generated_certificates) |
| Variable | Description |
|---|---|
MS_TENANT_ID |
Microsoft tenant ID (consumers for personal accounts) |
MS_CLIENT_ID |
Azure app registration client ID |
MS_REFRESH_TOKEN |
Microsoft refresh token for personal account auth |
EXCEL_SHARE_URL |
Share URL of the Excel workbook for certificate records |
ONEDRIVE_FOLDER_SHARE_URL |
Share URL of the OneDrive folder for certificate files |
EXCEL_TABLE_NAME |
Name of the Excel table (default: Certificates) |
EXCEL_FILE_NAME |
Name of the Excel file (default: Book.xlsx) |
| Variable | Description |
|---|---|
AGENTVERSE_URL |
Agentverse URL (default: https://agentverse.ai) |
ASI_ONE_API_KEY |
ASI:One API key (for chat protocol integration) |
ANTHROPIC_API_KEY |
Anthropic API key (alternative LLM, if configured) |
GOOGLE_SHEETS_URL |
Google Sheets Apps Script URL (legacy, optional) |
HCO_PUBLIC_GENERATION |
Set to true to allow certificate generation without login |
HCO_VERIFY_EXCEL_FIRST |
Set to true to check Excel before local DB during verification |
python agent.pyThe agent starts on http://localhost:8096.
| Method | Endpoint | Description |
|---|---|---|
| POST | /chat |
General chat (inquiry, verification, product verification) |
| POST | /image/upload |
Upload image or PDF for certificate verification |
| POST | /generate-certificate |
Generate a new certificate |
| POST | /certificate/query |
Query with intent classification (download, verify, etc.) |
| POST | /certificate/verify |
Verify a certificate by number |
| POST | /certificate/verify-products |
Verify products against a certificate |
| POST | /certificate/download |
Download a certificate file |
cd agents
docker compose up --buildThis builds the image, mounts generated_certificates/, and runs on port 8096.
cd frontend
npm installcp .env.example .env.localEdit .env.local:
| Variable | Description | Default |
|---|---|---|
VITE_USE_PRODUCTION |
true for production API, false for local dev |
false |
VITE_DEVELOPMENT_API_URL |
Local backend URL | http://localhost:8096 |
VITE_PRODUCTION_API_URL |
Production backend URL | https://hco.sandbox-london-b.fetch-ai.com |
For local development, the defaults work out of the box (connects to localhost:8096).
npm run devThe frontend starts on http://localhost:5173.
npm run buildOutput is written to dist/.
- Start the backend (in one terminal):
cd agents
source venv/bin/activate
python agent.py- Start the frontend (in another terminal):
cd frontend
npm run dev- Open http://localhost:5173 in your browser.
- Certificate Generation — Create Halal certificates (domestic, export meat, export non-meat, slaughterhouse) with PDF output
- Certificate Verification — Verify certificates by number, image upload, or PDF upload using OpenAI Vision
- Product Verification — Check if specific products are listed on a certificate
- Certificate Download — Download generated certificates as PDF/PNG
- Chat Interface — Natural language chat for inquiries, verification, and product checks
- ASI:One Integration — Chat protocol support for the Fetch.ai agent ecosystem
- Excel/OneDrive Integration — Read/write certificate records to Excel Online via Microsoft Graph
- Database Storage — PostgreSQL persistence with JSON file fallback
| Layer | Technology |
|---|---|
| Frontend | React 19, TypeScript, Vite, Tailwind CSS |
| Backend | Python, uAgents framework, OpenAI API |
| PDF Generation | WeasyPrint, ReportLab |
| Database | PostgreSQL (psycopg2), JSON fallback |
| Cloud | Microsoft Graph API (Excel, OneDrive), Azure MSAL |
| Auth | MSAL (Microsoft), simple token-based login |
For detailed usage instructions, see the HCO Usage Guide.
For migration instructions, see the HCO AI Certificate Validation System - Migration Guide.