Skip to content

Repository files navigation

MicroManus

MicroManus is an evidence-first deep-research agent. It plans a question, searches the live web through Tavily, reads useful sources, identifies evidence gaps, and returns a cited report. Each user brings an OpenAI-compatible model key; MicroManus stores it with AES-256-GCM encryption and records input, output, and cache token costs per conversation.

Product flow

  1. Sign in with Google or GitHub through Supabase Auth.
  2. Unlock five credits with the reviewer coupon or a $5 Stripe test payment.
  3. Connect an OpenRouter or custom OpenAI-compatible key.
  4. Start persistent research conversations with live activity and sources.
  5. Review per-chat usage or export finished work as private PDF artifacts.

One completed research prompt consumes one credit. Failed, cancelled, or timed-out runs are refunded exactly once.

Architecture

  • Next.js 16 App Router and React 19
  • Supabase Auth, PostgreSQL, Row Level Security, and private Storage
  • Stripe Checkout and signed, idempotent webhooks
  • OpenAI-compatible tool-calling agent loop
  • Tavily advanced search and extraction with a short-lived database cache
  • OpenRouter prompt/response caching and session stickiness
  • Server-side pdf-lib report generation
  • Vitest unit coverage

The service-role key, model credentials, Tavily key, Stripe secret, and encryption key are server-only. Model keys are encrypted before persistence and plaintext is never returned from the credential API.

Local setup

Requirements: Node.js 22+, npm, and a Supabase project.

npm install
copy .env.example .env.local

Fill .env.local, then apply the migration in supabase/migrations/202607180001_initial_schema.sql using the Supabase SQL editor or a PostgreSQL client.

npm run dev

The app runs at http://localhost:3000.

Supabase OAuth

Enable Google and GitHub in Authentication → Providers. In each upstream OAuth application, set the callback URL to:

https://<project-ref>.supabase.co/auth/v1/callback

In Authentication → URL Configuration:

  • Set the Site URL to the deployed application URL.
  • Add http://localhost:3000/auth/callback for local work.
  • Add https://<production-host>/auth/callback for production.
  • Disable email/password signup; the product intentionally exposes only social authentication.

Stripe

Use test-mode keys. Register the webhook endpoint:

https://<production-host>/api/billing/webhook

Subscribe to checkout.session.completed and store the resulting whsec_... value as STRIPE_WEBHOOK_SECRET. For local webhook testing:

stripe listen --forward-to localhost:3000/api/billing/webhook

Use Stripe’s standard test card 4242 4242 4242 4242 with any future expiry and CVC.

Quality gates

Create the final Cloudflare-compatible Sites bundle with:

npm run build:sites

This runs OpenNext and Wrangler's final bundling pass. Ensure NEXT_PUBLIC_SUPABASE_URL and NEXT_PUBLIC_SUPABASE_ANON_KEY are present during this build because Next.js inlines them into the browser bundle. When producing a Sites archive, place the bundled .sites-bundle/worker.js at .open-next/worker.js and include .open-next/assets, .openai/hosting.json, and wrangler.jsonc. Keeping the worker and assets under .open-next ensures Sites recognizes the OpenNext package and publishes the static asset binding.

npm run lint
npm run typecheck
npm test
npm run build

The test suite covers cached-token accounting, encryption and tamper rejection, public URL/SSRF validation, and PDF generation. Database integration verification additionally covers signup triggers, one-time coupon redemption, atomic reserve/refund behavior, refund idempotency, and cross-user RLS isolation.

Security notes

  • Never commit .env.local; all .env* files are ignored except when explicitly forced.
  • Rotate any secret that has appeared in chat, logs, screenshots, or source control before deployment.
  • Keep CREDENTIAL_ENCRYPTION_KEY stable. Rotating it requires re-encrypting stored provider keys.
  • Custom model endpoints must be public HTTP/HTTPS targets. Localhost and private address ranges are rejected.
  • Stripe success redirects never grant credits; only verified webhook events can do so.
  • Historical costs use pricing snapshots captured at generation time.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages