Skip to content

bwikbs/gateway

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gateway

A minimal ChatGPT-style chatbot gateway with rule-based intent routing.

Stack

  • Node.js (>=18) + Express
  • better-sqlite3 for persistence
  • Vanilla JS frontend (no build step)

Run

npm install
npm start
# Server: http://localhost:3003

Set PORT to override.

npm test   # node:test — no extra dependencies

Features

  • 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_cache table).
  • 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.

API

  • GET /api/sessions?mode=<mode> — list sessions, optionally filtered
  • POST /api/sessions — body { mode? }
  • GET /api/sessions/:id/messages
  • DELETE /api/sessions/:id
  • POST /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.

Caveats

  • 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.

About

ChatGPT-style chat gateway with Naver dictionary lookup (auto-detects Korean/English). SQLite history, pluggable handlers.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages