A minimal ChatGPT-style chatbot gateway with rule-based intent routing.
- Node.js (>=18) + Express
- better-sqlite3 for persistence
- Vanilla JS frontend (no build step)
npm install
npm start
# Server: http://localhost:3003Set PORT to override.
npm test # node:test — no extra dependencies- Sessions and messages persisted in SQLite (
data/gateway.db). - Rule-based intent classifier: each handler registers its own patterns
(
src/intent.js+src/handlers/). - Dictionary lookups are cached in SQLite for 7 days (
dict_cachetable). - Built-in handlers (all data from unofficial Naver APIs — see caveat below):
- 영한사전 (
dictionary.enko):hello 뜻,define serendipity - 국어사전 (
dictionary.ko):사과 뜻,행복의 의미— the default for bare Korean words - 한영사전 (
dictionary.koen):사과 영어로,행복 번역 - KBO 야구 (
baseball.kbo):오늘 야구,어제 야구 결과,7월 10일 LG 경기 - Fallback message for unsupported queries.
- 영한사전 (
GET /api/sessions?mode=<mode>— list sessions, optionally filteredPOST /api/sessions— body{ mode? }GET /api/sessions/:id/messagesDELETE /api/sessions/:idPOST /api/chat— body{ sessionId?, message, mode? }
mode is one of general | koen | enko | ko. When a dictionary mode is set,
the classifier is bypassed and the message goes straight to that dictionary
(the lookup word is still extracted from the message). Without a mode (or
general), the intent classifier decides.
- Dictionary and KBO data come from unofficial Naver endpoints
(
en.dict.naver.com,ko.dict.naver.com,api-gw.sports.naver.com). They can change or break without notice; the handlers log a warning when the response envelope no longer matches the expected shape. For anything beyond local experimentation, switch to official APIs (e.g. 국립국어원 오픈 API). - There is no authentication; every client shares the same session store.