Deployment & Production Hosting
Deployment models, environment configurations, and production hosting for both the cloud Hono API server and desktop installers.
By the end of this guide, you will have the Hono API server running in a production environment and understand how to build local desktop installers.
Prerequisites
- MongoDB Instance: A running cluster (local or MongoDB Atlas).
- Environment Access: Ability to define host environment variables.
- Node.js & pnpm: Required for building and packaging code.
Hono Cloud API Server Configuration
Configure the API server (apps/api) using the following environment variables:
| Variable | Description | Example Value |
|---|---|---|
NODE_ENV | Target execution environment | production |
PORT | Local runtime port | 3000 |
MONGODB_URI | MongoDB connection connection string | mongodb+srv://user:pass@cluster.mongodb.net/leadforge |
BETTER_AUTH_SECRET | 32+ character auth security secret | random_secret_string_here |
BETTER_AUTH_URL | Callback URL matching the API domain | https://api.leadforge.dev/api/v1/auth |
Deployment Options
Vercel Serverless (Recommended)
- Push the code repository to GitHub.
- In your Vercel Dashboard, import the repository.
- Configure the build parameters:
- Root Directory:
apps/api - Framework Preset:
Other
- Root Directory:
- Set the production environment variables.
- Trigger the deploy.
Note: The background SequenceWorker will not run under serverless environments. All HTTP synchronizations, CRUD, and auth endpoints function fully.
PM2 Process Manager
To run persistent server daemons on virtual servers (e.g. AWS, DigitalOcean):
pnpm -F api build
pm2 start dist/index.js --name "leadforge-api" --update-envDocker Container
Build and launch using the provided Dockerfile:
FROM node:20-alpine AS base
WORKDIR /app
COPY . .
RUN npm install -g pnpm && pnpm install
RUN pnpm -F api build
EXPOSE 3000
CMD ["pnpm", "-F", "api", "start"]Desktop Installer Packaging
The desktop application resolves configuration variables using this precedence:
- Environment Variables: Reads
API_URLorOPENROUTER_API_KEYfrom the shell. - Local JSON: Reads
apiUrloropenRouterKeyfromconfig.jsoninside theuserDatadirectory. - Build Defaults: Falls back to
https://api.leadforge.kapiljangid.pro/api/v1.
Build Windows Installer
To build the setup installer executable:
pnpm packageThis compiles main and renderer processes using electron-builder, outputting LeadForge OS-Setup-<version>.exe in the apps/desktop/dist/ directory.
Verification
To verify the API deployment:
- Perform a
GETquery to/health. - Confirm the response returns database status connectivity confirmation.