Purpose of this post

This post publishes the source code used for the crossword web app. The code is loaded only when you open a file.

Tools used

  • Next.js 15, React 19, TypeScript: lobby, game room, APIs
  • node:sqlite: storing grids and input records
  • gemma4 on Ollama: grid design and clue writing. It is called through an OpenAI-compatible API, so it can be swapped for another model.
  • Google News RSS and the Korean Wikipedia API: current-affairs headlines and random words
  • OpenSubtitles Korean frequency ranking: word grades

Folder layout

  • lib/puzzle.ts: difficulty settings, turning a grid into a clue list, criteria checks
  • lib/gridFill.ts: grid validation and correction, pre-drawn grids, word filling, the word-joining placer
  • lib/dynamicBank.ts: AI grid design, AI clue writing, news and wiki words
  • lib/words.ts, freqRanks.ts: word bank and frequency ranks
  • lib/db.ts: game record DB, partial saves, cleaning up empty grids
  • app/page.tsx, app/play/page.tsx: lobby and game room
  • app/api: new grid, record saving, listing and resuming APIs
  • components/CrosswordBoard.tsx: drawing the grid
  • scripts/text-agent.ts, ai-pipeline-test.ts: tools that test the generator and the AI process as text

To run it, copy .env.local.example to .env.local and fill in the model address. Without a model, grids are built from the word bank and wiki words alone. The game record DB, ad and deployment scripts, and the server monitor are not included.

Full source

32 files · 6,788 lines — open a folder and click a file to load its code.

Project root4 files
.env.local.exampletext · 9 lines · 319B

Loading code…

next.config.tstypescript · 16 lines · 353B

Loading code…

package.jsonjson · 24 lines · 597B

Loading code…

tsconfig.jsonjson · 21 lines · 592B

Loading code…

app/12 files
app/api/game/[code]/move/route.tstypescript · 50 lines · 1KB

Loading code…

app/api/game/[code]/route.tstypescript · 51 lines · 2KB

Loading code…

app/api/game/abandon/route.tstypescript · 15 lines · 522B

Loading code…

app/api/game/list/route.tstypescript · 17 lines · 539B

Loading code…

app/api/game/route.tstypescript · 45 lines · 2KB

Loading code…

app/api/puzzle/route.tstypescript · 74 lines · 2KB

Loading code…

app/globals.csscss · 57 lines · 1KB

Loading code…

app/layout.tsxtsx · 34 lines · 1KB

Loading code…

app/page.module.csscss · 225 lines · 3KB

Loading code…

app/page.tsxtsx · 172 lines · 6KB

Loading code…

app/play/page.tsxtsx · 861 lines · 29KB

Loading code…

app/play/play.module.csscss · 425 lines · 6KB

Loading code…

components/2 files
components/CrosswordBoard.module.csscss · 83 lines · 1KB

Loading code…

components/CrosswordBoard.tsxtsx · 98 lines · 3KB

Loading code…

lib/10 files
lib/db.tstypescript · 433 lines · 13KB

Loading code…

lib/dynamicBank.tstypescript · 360 lines · 14KB

Loading code…

lib/freqRanks.tstypescript · 404 lines · 8KB

Loading code…

lib/gameTypes.tstypescript · 63 lines · 1KB

Loading code…

lib/gridFill.tstypescript · 970 lines · 32KB

Loading code…

lib/guest.tstypescript · 60 lines · 2KB

Loading code…

lib/puzzle.tstypescript · 579 lines · 17KB

Loading code…

lib/recentWords.tstypescript · 33 lines · 891B

Loading code…

lib/services.tstypescript · 88 lines · 2KB

Loading code…

lib/words.tstypescript · 1,229 lines · 88KB

Loading code…

scripts/3 files
scripts/ai-pipeline-test.tstypescript · 41 lines · 1KB

Loading code…

scripts/dev-with-ts.mjsjavascript · 91 lines · 2KB

Loading code…

scripts/text-agent.tstypescript · 147 lines · 4KB

Loading code…

types/1 file
types/node-sqlite.d.tstypescript · 13 lines · 378B

Loading code…