Client Invoice Manager

Click to zoom
Client Invoice Manager
Save clients with AI extraction, generate PDF invoices from plain text descriptions, and upload them automatically to Google Drive all from a single workflow.
Client Invoice Manager is a full-stack automation that combines AI text extraction with PDF generation and Google Drive integration to handle the full client-to-invoice lifecycle with minimal manual input.
What it does
- Client management : Paste any free-form text about a client and
save-clientuses OpenAI to extract structured fields (name, email, company, address) and stores them in a SQL database - Client listing : Browse all saved clients via
list-clients - Invoice generation : Describe invoice details in plain text, pick a client, and
generate-invoiceuses OpenAI to extract line items, calculates totals, renders a PDF invoice, and uploads it to Google Drive automatically
Environment variables (.env / keyring on apps)
| Variable | Purpose |
|---|---|
HABITS_OPENAI_API_KEY | OpenAI API key for client data and invoice content extraction |
HABITS_GOOGLE_DRIVE_CLIENT_ID | Google OAuth 2.0 Client ID for Drive upload |
HABITS_GOOGLE_DRIVE_CLIENT_SECRET | Google OAuth 2.0 Client Secret for Drive upload |
HABITS_GOOGLE_DRIVE_FOLDER_ID | Target Google Drive folder ID where invoices are uploaded |
How to set up
- Copy
.env.exampleto.envand fill in your credentials. - Create a Google Cloud project, enable the Google Drive API, configure the OAuth consent screen, and create OAuth 2.0 credentials with
http://localhost:13000/oauth/bit-google-drive/callbackas the redirect URI. - On first server start, open the printed authorization URL in your browser and grant Drive access.
- Create (or reuse) a Google Drive folder and copy its ID from the URL into
HABITS_GOOGLE_DRIVE_FOLDER_ID. - Run
save-clientto add clients, thengenerate-invoiceto create and upload invoices.
Tech stack
- habits framework for workflow orchestration
- OpenAI (
@ha-bits/bit-openai) for natural-language client data extraction and invoice line-item parsing - SQL database (
@ha-bits/bit-database-sql) for client record storage - Google Drive (
@ha-bits/bit-google-drive) for automatic PDF invoice upload - Frontend habit for interactive client and invoice management UI
Run Your .habit File
Run on Mobile
- [ ] Download the Cortex App from store or the downloads page
- [ ] Open the Cortex App on your device
- [ ] Tap "Open Habit" or "+" button
- [ ] Select your
.habitfile from your device storage - [ ] The habit will be loaded and ready to run
Run on Desktop
- [ ] Download the Cortex App for your platform from the downloads page
- [ ] Install and open the Cortex App
- [ ] Click "Open Habit" or drag & drop your
.habitfile - [ ] The habit will be loaded and ready to run
- [ ] Optional: Place a
.envfile in the same directory as your.habitfile to override environment variables
Run on Server
Run your .habit file as a server using the Cortex CLI:
bash
# Install and run in one command
npx @ha-bits/cortex --config ./your-app.habit- [ ] Make sure Node.js 20+ is installed
- [ ] Run the command above with your
.habitfile path - [ ] Server will start on the specified port (default: 3000)
- [ ] Access the app at
http://localhost:3000 - [ ] Optional: Place a
.envfile next to your.habitfile - it will automatically override any embedded environment variables
Run Serverless
For serverless or containerized deployments, we recommend using Docker:
bash
# Using Docker (recommended for serverless)
docker run -p 3000:3000 -v $(pwd)/your-app.habit:/app/habit.habit \
node:20-alpine npx @ha-bits/cortex --config /app/habit.habit --host 0.0.0.0Or create a Dockerfile:
dockerfile
FROM node:20-alpine
WORKDIR /app
COPY your-app.habit ./
COPY .env ./ # Optional: include environment variables
RUN npm install -g @ha-bits/cortex
EXPOSE 3000
CMD ["cortex", "--config", "./your-app.habit", "--host", "0.0.0.0"]- [ ] Create a Dockerfile or use the Docker run command above
- [ ] Deploy to your preferred cloud provider (AWS, GCP, Azure, etc.)
- [ ] Configure environment variables via your cloud provider's secrets management
- [ ] Set up health checks at
/habits/base/apiendpoint
Workflow Visualization
Requirements
- OPENAI_API_KEY (OpenAI API key)
- GOOGLE_DRIVE_CLIENT_ID (Google OAuth 2.0 Client ID)
- GOOGLE_DRIVE_CLIENT_SECRET (Google OAuth 2.0 Client Secret)
- GOOGLE_DRIVE_FOLDER_ID (Target Google Drive folder ID for uploads)
Quick Start
Run using the Habits CLI wrapper, recommended if you develop local Habits
# First, download the example files
npx habits@latest cortex --config ./client-invoice-manager/stack.yamlGet in touch
Want this habit running in your environment?
This habit is a starting point. Tell us about your stack and we'll help you get it working exactly the way your team needs.
