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
| Component | Technology | Purpose |
|---|---|---|
| Frontend | Next.js (React) | Full-stack web application framework |
| UI styling | Tailwind CSS | Responsive layouts and frosted-glass effects |
| Authentication | NextAuth.js with Google OAuth | Secure sign-in with a Google account |
| AI engines | Google Gemini and Mistral AI | Conversation and structured JSON extraction. Users choose between them. |
| PDF processing | pdf-lib | Reads and fills PDF form fields |
| Database | PostgreSQL on Neon | Serverless cloud database |
| ORM | Prisma | Backend-to-database layer |
| Backend | Next.js API routes | Serverless functions for the app's logic |
| Hosting | Netlify | Production deployment |
| Payments | PayHere | Full 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
Install packages
Run
npm installin the project folder. - 2
Create your environment file
Add a
.env.localfile in the project root using the variables in the table below. - 3
Prepare the database
Run
npx prisma generate, thennpx prisma migrate dev. - 4
Start the app
Run
npm run devand openhttp://localhost:3000.
npm install
npx prisma generate
npx prisma migrate dev
npm run devFor production, npm run build runs prisma generate and then builds the app. Start it with npm start.
Environment variables
| Variable | Required | What it does |
|---|---|---|
DATABASE_URL | Yes | PostgreSQL connection string. |
NEXTAUTH_URL | Yes | The public address of your site. |
NEXTAUTH_SECRET | Yes | Secret used to sign sessions. |
GOOGLE_CLIENT_ID | Yes | Google OAuth client ID. |
GOOGLE_CLIENT_SECRET | Yes | Google OAuth client secret. |
GEMINI_API_KEY | At least one AI key | Key for the Gemini API. Without it, Gemini isn't offered to users. |
GEMINI_MODEL | No | Which Gemini model to use. Defaults to gemini-3.5-flash-lite. |
MISTRAL_API_KEY | At least one AI key | Key for the Mistral API. Without it, Mistral AI isn't offered to users. |
MISTRAL_MODEL | No | Which Mistral model to use. Defaults to ministral-14b-2512. |
ADMIN_EMAILS | No | Emails allowed to open the admin panel. |
PAYHERE_MERCHANT_ID | For billing | PayHere merchant ID. |
PAYHERE_MERCHANT_SECRET | For billing | PayHere merchant secret. |
PAYHERE_MODE | No | live for real payments. Anything else uses the PayHere sandbox. |
PAYHERE_NOTIFY_URL | For billing | Address PayHere calls to confirm a payment. |
PAYHERE_PLAN_AMOUNT | No | Full House price. Defaults to 3000. |
PAYHERE_PLAN_CURRENCY | No | Currency for the price above. |
NEXT_PUBLIC_PLAN_PRICE_LABEL | No | Price 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.
| File | What it does |
|---|---|
lib/aiModels.ts | The list of models: names, descriptions, default model names, and which API key each needs. |
lib/openaiCompat.ts | A small client for OpenAI-style chat APIs, used for Mistral. No extra package is needed. |
lib/systemPrompt.ts | The one set of banking rules shared by every model, plus the extra form-field instructions Mistral receives. |
app/api/models/route.ts | Tells the chat page which models are switched on. |
app/api/settings/model/route.ts | Tells 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.
| Setting | Default | Meaning |
|---|---|---|
FREE_CHAT_LIMIT | 1 | Chats a Free user can start, in total. |
FREE_MESSAGE_LIMIT | 10 | Messages a Free user can send in that chat. |