How albertnjobo/procurely works
1. Overall shape: Procurely is a single-page React application with a TypeScript/Express backend in the same repository. The browser talks to the app server over HTTPS, and the server acts as the orchestration layer for AI calls, workflow execution, persistence, and outbound email.
2. Frontend surface area: The main UI lives under src/pages/ and is organized by procurement function: Agent Chat, Dashboard, Intake, Requisitions, RFQs, Suppliers, Knowledge Base, Workflow Designer, Vendor Portal, Settings, and Request Tracker. Shared UI primitives are in components/ui/ and the app uses a component-driven design system built around shadcn/ui and Tailwind.
3. Agent experience boundary: The agent-facing UI is centered on src/pages/AgentChat.tsx and the src/components/agent/ cards. These cards represent human-in-the-loop checkpoints such as item details, supplier selection, impact analysis, bid matrix review, upload prompts, and process timeline. That means the browser is not just a chat client; it also renders approval and decision artifacts returned by the backend.
4. Backend/API layer: server.ts is the runtime entry point for the Express server. The server exposes modular route handlers in src/routes/ for agent actions, documents, email, knowledge base, memory, and workflows. This separates request handling from the domain logic that lives in src/lib/.
5. AI orchestration: Core LLM behavior is centralized in src/lib/agent-tools.ts, tool-executor.ts, and agent-prompts.ts. The agent can call 30+ procurement tools, delegate specialist sub-tasks, and stream responses back to the chat UI. Qwen Cloud is the primary AI dependency, with multiple models used for reasoning, tool calling, embedding, reranking, speech-to-text, and specialist analysis.
6. RAG and knowledge governance: The knowledge base pipeline in src/lib/rag.ts and src/lib/zvec-store.ts handles document chunking, embedding, retrieval, and reranking. Policy content is injected as mandatory context so the agent can refuse non-compliant requests and cite the relevant rule. This is a critical architectural boundary: the KB is not just search, it is a policy enforcement layer for the agent.
7. Persistent memory: User preferences and prior decisions are stored separately from the knowledge base in the memory subsystem (src/routes/memory.ts, src/lib/zvec-store.ts). This gives the agent long-term recall across sessions without mixing personal memory with organizational policy documents.
8. Workflow automation: The workflow subsystem combines a visual designer (src/pages/WorkflowDesigner.tsx) with execution logic in src/lib/workflow-engine.ts, templates in workflow-templates.ts, and triggers in workflow-triggers.ts. Workflows model procurement events such as submission, approval, notification, and PO generation, and they produce execution logs for auditability.
9. Data and identity: Firebase is the system of record for authentication and Firestore-backed application data. The client auth state is managed through src/lib/auth-context.tsx, while server-side protection uses auth-middleware.ts. Firestore rules and the demo seeding logic indicate that user/session identity is enforced at the data boundary, not only in the UI.
10. Outbound communications: Transactional email is a dedicated subsystem, with React Email templates in src/emails/ and delivery through src/lib/email-sender.ts. Emails cover approval requests, RFQs, POs, invoices, and workflow-complete notifications, so the workflow engine can trigger real-world procurement actions outside the app.
11. Deployment and ingress: The repo is containerized with Dockerfile and docker-compose.yml, and nginx.conf sits in front of the Node server in production. Cloudflare provides DNS/SSL termination for the public domain, then forwards traffic to Nginx, which proxies to the Express app on port 3000. This makes the deployment boundary: browser → Cloudflare → Nginx → Express → Firebase/Qwen/Resend.
12. Supporting artifacts: The repo also includes documentation for the architecture and workflow design, plus Firebase config files and a local .env.example. These files reinforce that the app is designed as a full-stack procurement automation system, not just a UI demo: it has persistent state, AI orchestration, workflow execution, and external integrations built into the architecture.
Main entry points: App.tsx App shell · server.ts Server entry · workflow-engine.ts Workflow engine · agent.ts Agent API
Components 24
Frontend
React SPA, shared UI, and user-facing procurement workflows
- App shell · Top-level client routing and app composition
src/App.tsx - Entry pages · Landing and login surfaces for the application
src/pages/Landing.tsx - Procurement pages · Dashboard, intake, requisitions, RFQs, suppliers, catalog, tracker, settings, and vendor portal
src/pages/Dashboard.tsx - Agent chat · Chat workspace that renders decisions, approvals, and specialist cards
src/pages/AgentChat.tsx - Workflow designer · Visual authoring surface for procurement workflows
src/pages/WorkflowDesigner.tsx - UI kit · Reusable shadcn/ui and Tailwind primitives
components/ui/button.tsx - Agent cards · Specialized cards for item details, supplier selection, impact analysis, bid review, uploads, and timeline
src/components/agent/ItemDetailsCard.tsx
Backend
Express API routes and orchestration logic
- Server entry · Node server bootstrap and HTTPS-facing app runtime
server.ts - Agent API · Request handling for chat actions and tool-driven agent flows
src/routes/agent.ts - KB API · Document and policy retrieval endpoints
src/routes/kb.ts - Memory API · Endpoints for persistent user preferences and prior decisions
src/routes/memory.ts - Workflow API · Workflow execution, templates, and trigger endpoints
src/routes/workflows.ts - Agent tools · Procurement-specific tool definitions and specialist task delegation
src/lib/agent-tools.ts - Tool executor · Runs tool calls and streams results back to the chat layer
src/lib/tool-executor.ts
Knowledge & Memory
RAG, policy enforcement, and persistent recall
- RAG pipeline · Chunking, embedding, retrieval, reranking, and policy-context injection
src/lib/rag.ts - Vector store · Shared vector-backed storage for knowledge and user memory
src/lib/zvec-store.ts
Workflow & Comms
Workflow execution and outbound notifications
- Workflow engine · Executes procurement workflows and writes execution logs
src/lib/workflow-engine.ts - Workflow templates · Reusable workflow blueprints
src/lib/workflow-templates.ts - Workflow triggers · Event-to-workflow trigger definitions
src/lib/workflow-triggers.ts - Email sender · Transactional delivery for approvals, RFQs, POs, invoices, and completion notices
src/lib/email-sender.ts - Email templates · Message templates used by outbound procurement notifications
src/emails/ApprovalRequest.tsx
Platform
Auth, data, and deployment boundary
- Auth & data · Client auth state, server protection, and Firestore-backed system of record
src/lib/firebase.ts - Auth middleware · Request-time protection for backend routes
src/lib/auth-middleware.ts - Deployment · Containerized app and reverse-proxy boundary
nginx.conf
Connections 25
- App shell → Entry pages: routes to · Hosts unauthenticated entry flows
- App shell → Procurement pages: renders · Main procurement modules in the SPA
- App shell → Agent chat: renders · Agent workspace and decision artifacts
- App shell → Workflow designer: renders · Workflow authoring surface
- App shell → UI kit: composes · Shared UI primitives
- Agent chat → Agent cards: shows · Human-in-the-loop checkpoints and outputs
- Server entry → Agent API: mounts · API surface for agent interactions
- Server entry → KB API: mounts · Knowledge and document endpoints
- Server entry → Memory API: mounts · Persistent memory endpoints
- Server entry → Workflow API: mounts · Workflow endpoints
- Agent API → Tool executor: invokes · Streams tool execution back to the client
- Tool executor → Agent tools: uses · Executes procurement-specific tools
- Agent tools → RAG pipeline: queries · Retrieves policies and knowledge when needed
- KB API → RAG pipeline: serves · Retrieval and policy-governed context
- Memory API → Vector store: stores · Long-term user and decision memory
- RAG pipeline → Vector store: reads/writes · Document chunks, embeddings, and rerank inputs
- Workflow API → Workflow engine: executes · Runs procurement workflows
- Workflow engine → Workflow templates: loads · Blueprints for workflow execution
- Workflow engine → Workflow triggers: reacts to · Event-driven automation entry points
- Workflow engine → Email sender: notifies · Sends approval and completion emails
- Email sender → Email templates: renders · Transactional message content
- Server entry → Auth middleware: protects · Server-side route authorization
- Auth & data → Agent API: authorizes · Authenticated backend requests
- Auth & data → App shell: hydrates · Client auth state for the SPA
- Deployment → Server entry: proxies to · Nginx forwards requests to the Node app