This is a Next.js project bootstrapped with create-next-app.
First, run the development server:
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun devOpen http://localhost:3000 with your browser to see the result.
You can start editing the page by modifying app/page.tsx. The page auto-updates as you edit the file.
This project uses next/font to automatically optimize and load Geist, a new font family for Vercel.
To learn more about Next.js, take a look at the following resources:
- Next.js Documentation - learn about Next.js features and API.
- Learn Next.js - an interactive Next.js tutorial.
You can check out the Next.js GitHub repository - your feedback and contributions are welcome!
The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.
Check out our Next.js deployment documentation for more details.
This repository contains a small Next.js app (App Router) that implements a simple chatbot backed by a MySQL database.
Quick setup
- Copy
.env.local.exampleto.env.localand fill your MySQL credentials:
MYSQL_HOST=127.0.0.1
MYSQL_PORT=3306
MYSQL_USER=root
MYSQL_PASSWORD=your_password
MYSQL_DATABASE=bfsi_chat
- Create the database and messages table. A
database.sqlfile is included with the schema:
CREATE TABLE IF NOT EXISTS messages (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(255) NOT NULL,
content TEXT NOT NULL,
timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
- Install dependencies and run the dev server:
npm install
npm run dev- Open
http://localhost:3000and try the chat UI.
Notes
- The API route is located at
src/app/api/chat/route.tsand saves messages to MySQL. - Database helper is
src/lib/db.tswhich usesmysql2/promiseand expects env variables from.env.local. - If you need a different DB config (SSL, socket, etc.), update
src/lib/db.tsaccordingly.
If you run into errors, share the terminal output and I can help debug further.