Skip to content

estherea07/ledgerlock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”’ LedgerLock

AI-powered guardrails for your business finances. Your money moves only when you say so.

Built for the Auth0 "Authorized to Act" Hackathon

Live Demo: https://ledgerlock-git-main-estherea07s-projects.vercel.app Youtube Demo Video: Demo Video GitHub: https://github.com/estherea07/ledgerlock


The Problem

Staff fraud costs SMEs billions annually β€” not through elaborate hacking, but through simple payment diversion. Employees give customers their personal account numbers instead of the company's. They transfer business funds to fake vendors. They exploit the gap between "someone initiated a payment" and "the owner noticed."

LedgerLock closes that gap with an AI agent named Elf who monitors every transaction, verifies every payment link, and never lets credentials leave a secure vault.


What LedgerLock Does

Feature Description
πŸ€– Elf AI Agent LangGraph-powered agent analyses every transaction against your policies in real time
πŸ”’ Auth0 Token Vault All bank/payment credentials stored encrypted - staff never see raw keys
πŸ“² CIBA Step-up Auth High-risk transactions push to owner's phone for one-tap approve/deny
πŸ”— Verified Payment Links Links locked to company account - customers always pay the business, not an employee
πŸ“Š Staff Risk Scoring Elf tracks payment behaviour per employee and flags patterns early
πŸ“‹ Audit Log Every Elf action logged with Auth0 reference - tamper-proof

Tech Stack

Layer Technology
Frontend Next.js 14 (App Router), TypeScript, Tailwind CSS
AI Agent LangGraph, Anthropic Claude Haiku (claude-haiku-4-5-20251001)
Auth & Identity Auth0 for AI Agents - Token Vault + CIBA, @auth0/nextjs-auth0
Database Prisma ORM + PostgreSQL (Neon) in production, SQLite locally
Payments Paystack (via Token Vault)
Notifications Twilio WhatsApp/SMS (via Token Vault)
Deployment Vercel

Quick Start (Local)

Prerequisites

1. Clone and install

git clone https://github.com/estherea07/ledgerlock.git
cd ledgerlock
npm install --legacy-peer-deps

2. Configure environment

cp .env.example .env.local

Open .env.local and fill in:

# Auth0 β€” from your Auth0 dashboard at manage.auth0.com
AUTH0_SECRET='run: node -e "console.log(require(crypto).randomBytes(32).toString(base64))"'
AUTH0_BASE_URL='http://localhost:3000'
AUTH0_ISSUER_BASE_URL='https://YOUR_TENANT.us.auth0.com'
AUTH0_CLIENT_ID='your_regular_web_app_client_id'
AUTH0_CLIENT_SECRET='your_regular_web_app_client_secret'
AUTH0_AUDIENCE='https://YOUR_TENANT.us.auth0.com/api/v2/'
AUTH0_TOKEN_VAULT_URL='https://YOUR_TENANT.us.auth0.com'
AUTH0_MGMT_CLIENT_ID='your_m2m_client_id'
AUTH0_MGMT_CLIENT_SECRET='your_m2m_client_secret'

# Database (SQLite for local dev)
DATABASE_URL='file:./ledgerlock.db'

# Anthropic β€” free credits on signup
ANTHROPIC_API_KEY='sk-ant-your-key'

# Paystack β€” use TEST keys (free, no real money)
PAYSTACK_SECRET_KEY='sk_test_your_key'
PAYSTACK_PUBLIC_KEY='pk_test_your_key'

# App
NEXT_PUBLIC_APP_URL='http://localhost:3000'
NEXT_PUBLIC_APP_NAME='LedgerLock'

3. Auth0 Setup

  1. Go to auth0.com β†’ create free account β†’ create tenant
  2. Applications β†’ + Create Application β†’ Regular Web Application β†’ name it LedgerLock
  3. In Settings tab:
    • Allowed Callback URLs: http://localhost:3000/api/auth/callback
    • Allowed Logout URLs: http://localhost:3000
    • Allowed Web Origins: http://localhost:3000
  4. Applications β†’ + Create Application β†’ Machine to Machine β†’ name it LedgerLock M2M
    • Select Auth0 Management API β†’ grant scopes: read:users, update:users
  5. Authentication β†’ Social β†’ GitHub β†’ enable Connected Accounts for Token Vault
  6. Applications β†’ APIs β†’ Auth0 My Account API β†’ Application Access β†’ authorize LedgerLock

4. Run

npx prisma db push
npx prisma generate
npm run dev

Open http://localhost:3000

5. Load demo data (optional)

npx ts-node prisma/seed.ts

This loads Greenfield Laundry Ltd with 3 staff members, sample flagged transactions, and demo vault tokens.


How to Test Elf

Once running (local or live), do this to see all features:

1. Sign in with GitHub via Auth0

2. Add a staff member - Staff β†’ Add Staff Member β†’ name: "David Kalu", role: Sales Rep

3. Test Elf blocking a transaction - Payments β†’ New Payment Request:

  • Amount: ₦200,000
  • Description: "transfer to personal account"
  • Submit β†’ Elf blocks immediately (score: critical)

4. Test Elf flagging for CIBA - New Payment Request:

  • Amount: ₦85,000
  • Vendor: "Apex Supplies Ltd"
  • Submit β†’ Elf flags (new vendor + over limit) β†’ CIBA approval required

5. Test auto-approval - New Payment Request:

  • Amount: ₦5,000
  • Vendor: "EKEDC"
  • Description: "electricity bill"
  • Submit β†’ Elf auto-approves (low risk, known vendor)

6. Generate a verified payment link - Payment Links β†’ Generate Verified Link

  • See how the URL is locked to company account via Token Vault

7. Connect a service to vault - Token Vault β†’ Connect Service

  • See how only a reference ID is stored, never the raw key

Architecture: How Token Vault Works

Business Owner
    β”‚
    β–Ό
Connects API credentials β†’ Auth0 Token Vault (encrypted, never in our DB)
    β”‚
    β–Ό (only tokenRef stored in LedgerLock DB)

Elf Agent (LangGraph 6-node pipeline)
    β”‚
    β”œβ”€β”€ load_policies     β†’ fetch owner's guardrails from DB
    β”œβ”€β”€ policy_check      β†’ rule-based risk scoring
    β”œβ”€β”€ anomaly_detection β†’ Claude Haiku AI reasoning
    β”œβ”€β”€ make_decision     β†’ approve / flag / block
    β”œβ”€β”€ trigger_ciba      β†’ Auth0 CIBA push to owner's phone (if flagged)
    └── persist_and_notify β†’ log everything, update risk scores
    β”‚
    β–Ό (API calls go through Token Vault - Elf never sees raw credentials)

Bank API / Paystack / Twilio

Deployment (Vercel)

  1. Push to GitHub
  2. Go to vercel.com/new β†’ import repo
  3. Add all .env.local variables in Vercel β†’ Environment Variables
  4. Change DATABASE_URL to a PostgreSQL connection string (free at neon.tech)
  5. Change AUTH0_BASE_URL and NEXT_PUBLIC_APP_URL to your Vercel domain
  6. Update Auth0 Allowed Callback URLs to include your Vercel domain
  7. Deploy

Project Structure

src/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”œβ”€β”€ agent/route.ts            # Direct Elf agent endpoint
β”‚   β”‚   β”œβ”€β”€ audit/route.ts            # Audit log API
β”‚   β”‚   β”œβ”€β”€ auth/[auth0]/route.ts     # Auth0 handler β€” login, callback, logout
β”‚   β”‚   β”œβ”€β”€ dashboard/route.ts        # Aggregated metrics
β”‚   β”‚   β”œβ”€β”€ links/route.ts            # Generate verified payment links
β”‚   β”‚   β”œβ”€β”€ onboarding/route.ts       # First-time business setup
β”‚   β”‚   β”œβ”€β”€ payments/route.ts         # Payments list
β”‚   β”‚   β”œβ”€β”€ payments/ciba/route.ts    # CIBA approve/deny for payments
β”‚   β”‚   β”œβ”€β”€ staff/route.ts            # Staff management
β”‚   β”‚   β”œβ”€β”€ staff/suspend/route.ts    # Suspend a staff member
β”‚   β”‚   β”œβ”€β”€ transactions/route.ts     # Submit transactions to Elf
β”‚   β”‚   β”œβ”€β”€ transactions/ciba/route.ts # CIBA approve/deny for transactions
β”‚   β”‚   β”œβ”€β”€ vault/route.ts            # Token Vault connections
β”‚   β”‚   └── webhook/paystack/route.ts # Paystack payment webhooks
β”‚   β”œβ”€β”€ audit/page.tsx                # Full audit log
β”‚   β”œβ”€β”€ dashboard/page.tsx            # Owner dashboard
β”‚   β”œβ”€β”€ links/page.tsx                # Payment link management
β”‚   β”œβ”€β”€ onboarding/page.tsx           # First-time business setup
β”‚   β”œβ”€β”€ pay/[reference]/page.tsx      # Public payment page (customer-facing)
β”‚   β”œβ”€β”€ payments/page.tsx             # Transaction list + CIBA approval UI
β”‚   β”œβ”€β”€ staff/page.tsx                # Staff risk monitoring
β”‚   β”œβ”€β”€ vault/page.tsx                # Token Vault UI
β”‚   β”œβ”€β”€ globals.css
β”‚   β”œβ”€β”€ layout.tsx
β”‚   └── page.tsx                      # Landing page
β”œβ”€β”€ components/
β”‚   β”œβ”€β”€ dashboard/
β”‚   β”‚   β”œβ”€β”€ AlertsPanel.tsx
β”‚   β”‚   β”œβ”€β”€ ElfInsight.tsx
β”‚   β”‚   β”œβ”€β”€ MetricsRow.tsx
β”‚   β”‚   β”œβ”€β”€ Sidebar.tsx
β”‚   β”‚   β”œβ”€β”€ StaffRisk.tsx
β”‚   β”‚   └── TransactionList.tsx
β”‚   β”œβ”€β”€ links/
β”‚   β”‚   └── GenerateLinkModal.tsx
β”‚   β”œβ”€β”€ payments/
β”‚   β”‚   β”œβ”€β”€ CIBACard.tsx
β”‚   β”‚   └── NewTransactionModal.tsx
β”‚   β”œβ”€β”€ staff/
β”‚   β”‚   └── AddStaffModal.tsx
β”‚   └── ui/
β”‚       β”œβ”€β”€ Badge.tsx
β”‚       β”œβ”€β”€ Button.tsx
β”‚       β”œβ”€β”€ Card.tsx
β”‚       β”œβ”€β”€ EmptyState.tsx
β”‚       β”œβ”€β”€ Input.tsx
β”‚       β”œβ”€β”€ LoadingSpinner.tsx
β”‚       β”œβ”€β”€ Modal.tsx
β”‚       └── Select.tsx
β”œβ”€β”€ hooks/
β”‚   β”œβ”€β”€ useDashboard.ts
β”‚   β”œβ”€β”€ usePaymentLinks.ts
β”‚   β”œβ”€β”€ useStaff.ts
β”‚   └── useTransactions.ts
β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ agent/
β”‚   β”‚   β”œβ”€β”€ audit.ts                  # Audit log helper
β”‚   β”‚   β”œβ”€β”€ elf.ts                    # Elf LangGraph agent (core AI)
β”‚   β”‚   └── payment-links.ts          # Payment link generation helper
β”‚   β”œβ”€β”€ auth/
β”‚   β”‚   └── auth0.ts                  # Auth0 helpers (legacy)
β”‚   β”œβ”€β”€ auth.ts                       # Auth0 Token Vault + CIBA helpers
β”‚   β”œβ”€β”€ db.ts                         # Prisma client
β”‚   β”œβ”€β”€ notifications.ts              # Twilio via Token Vault
β”‚   └── paystack.ts                   # Paystack via Token Vault
β”œβ”€β”€ types/
β”‚   └── index.ts                      # TypeScript interfaces
└── middleware.ts                      # Auth0 route protection

License

MIT Β© 2026 LedgerLock

Built with Auth0 for AI Agents, LangGraph, Anthropic Claude, and a conviction that SME owners deserve financial guardrails that actually work.

About

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages