Configuration

The technology behind Doctor Bank and how to run your own copy.

This page is for developers and project reviewers. If you only want to fill in a form, start with the Quickstart instead.

Technology stack

ComponentTechnologyPurpose
FrontendNext.js (React)Full-stack web application framework
UI stylingTailwind CSSResponsive layouts and frosted-glass effects
AuthenticationNextAuth.js with Google OAuthSecure sign-in with a Google account
AI enginesGoogle Gemini and Mistral AIConversation and structured JSON extraction. Users choose between them.
PDF processingpdf-libReads and fills PDF form fields
DatabasePostgreSQL on NeonServerless cloud database
ORMPrismaBackend-to-database layer
BackendNext.js API routesServerless functions for the app's logic
HostingNetlifyProduction deployment
PaymentsPayHereFull House subscription checkout

Requirements

  • Node.js and npm.
  • A PostgreSQL database. A free Neon database works for development.
  • A Google Cloud OAuth client for sign-in.
  • A Google Gemini API key.
  • A Mistral API key, if you want the Mistral AI model (optional).

Set up your copy

  1. 1

    Install packages

    Run npm install in the project folder.

  2. 2

    Create your environment file

    Add a .env.local file in the project root using the variables in the table below.

  3. 3

    Prepare the database

    Run npx prisma generate, then npx prisma migrate dev.

  4. 4

    Start the app

    Run npm run dev and open http://localhost:3000.

npm install
npx prisma generate
npx prisma migrate dev
npm run dev

For production, npm run build runs prisma generate and then builds the app. Start it with npm start.

Environment variables

VariableRequiredWhat it does
DATABASE_URLYesPostgreSQL connection string.
NEXTAUTH_URLYesThe public address of your site.
NEXTAUTH_SECRETYesSecret used to sign sessions.
GOOGLE_CLIENT_IDYesGoogle OAuth client ID.
GOOGLE_CLIENT_SECRETYesGoogle OAuth client secret.
GEMINI_API_KEYAt least one AI keyKey for the Gemini API. Without it, Gemini isn't offered to users.
GEMINI_MODELNoWhich Gemini model to use. Defaults to gemini-3.5-flash-lite.
MISTRAL_API_KEYAt least one AI keyKey for the Mistral API. Without it, Mistral AI isn't offered to users.
MISTRAL_MODELNoWhich Mistral model to use. Defaults to ministral-14b-2512.
ADMIN_EMAILSNoEmails allowed to open the admin panel.
PAYHERE_MERCHANT_IDFor billingPayHere merchant ID.
PAYHERE_MERCHANT_SECRETFor billingPayHere merchant secret.
PAYHERE_MODENolive for real payments. Anything else uses the PayHere sandbox.
PAYHERE_NOTIFY_URLFor billingAddress PayHere calls to confirm a payment.
PAYHERE_PLAN_AMOUNTNoFull House price. Defaults to 3000.
PAYHERE_PLAN_CURRENCYNoCurrency for the price above.
NEXT_PUBLIC_PLAN_PRICE_LABELNoPrice text shown on the site. Defaults to “LKR 3,000”. Keep it in step with the amount above.

AI models and providers

A model appears for users only when its API key exists. Add MISTRAL_API_KEY and restart, and Mistral AI shows up in Settings and in the chat dropdown. Remove the key and it disappears. Keys are never sent to the browser.

FileWhat it does
lib/aiModels.tsThe list of models: names, descriptions, default model names, and which API key each needs.
lib/openaiCompat.tsA small client for OpenAI-style chat APIs, used for Mistral. No extra package is needed.
lib/systemPrompt.tsThe one set of banking rules shared by every model, plus the extra form-field instructions Mistral receives.
app/api/models/route.tsTells the chat page which models are switched on.
app/api/settings/model/route.tsTells the Settings page about every model and whether it is switched on.

Google sign-in

In Google Cloud, create an OAuth client and add http://localhost:3000/api/auth/callback/google as an authorized redirect address. When you deploy, add the same path on your live domain.

Protected areas

These routes require sign-in: /chat, /dashboard, /settings, and /admin. The landing page, login page, and this Academy are public.

Plan limits

Free plan limits live in one file, lib/plans.ts, so the server and the interface always show the same numbers.

SettingDefaultMeaning
FREE_CHAT_LIMIT1Chats a Free user can start, in total.
FREE_MESSAGE_LIMIT10Messages a Free user can send in that chat.