Japanese script learning application for Trails (Kiseki) series games.
- CSV File Upload - Upload CSV files containing game dialogue data
- Markdown File Upload - Upload MD files with pre-parsed learning materials (desktop only)
- Browse & Search - Browse through scripts with advanced search and filtering
- Learn Status Tracking - Filter by all/learned/unlearned scripts with progress badges
- File-Level Statistics - View total and learned counts per file
- AI-Powered Learning Materials - Generate vocabulary, grammar, and translations via DeepSeek API
- Cached Results - Avoid redundant API calls with intelligent caching
- Text-to-Speech - Listen to Japanese text with female voice (browser-based)
- Node.js 18+ installed
- PostgreSQL database
- DeepSeek API key (optional, for AI generation)
- Clone the repository:
git clone <your-repo-url>
cd japanese-script-learning- Install dependencies:
npm install- Set up environment variables:
cp .env.example .envEdit .env with your values:
DATABASE_URL="postgresql://user:password@localhost:5432/japanese_script_learning"
DEEPSEEK_API_KEY="sk-your-key-here"
NEXT_PUBLIC_APP_URL="http://localhost:3000"- Set up the database:
npm run db:push- Run the development server:
npm run dev- Open http://localhost:3000 in your browser
japanese-script-learning/
├── app/ # Next.js App Router
│ ├── api/ # API Routes
│ │ ├── csv/upload/ # CSV upload endpoint
│ │ ├── md/upload/ # Markdown upload endpoint
│ │ ├── script/ # Script list/get endpoints
│ │ ├── files/ # Files statistics endpoint
│ │ ├── learning/ # Learning material endpoints
│ │ └── health/ # Health check
│ ├── script/ # Script list page
│ └── learning/ # Learning material pages
├── components/ # React components
│ ├── csv-upload/ # CSV upload component (desktop only)
│ ├── md-upload/ # Markdown upload component (desktop only)
│ ├── tts-button/ # Text-to-speech button component
│ ├── script-list/ # Script list component
│ ├── learning-material/ # Learning material display component
│ └── ui/ # UI components (Card, Button, etc.)
├── lib/ # Utility libraries
│ ├── db/ # Prisma client
│ ├── deepseek/ # DeepSeek API integration
│ ├── csv/ # CSV parsing
│ └── md-parser/ # Markdown learning material parser
├── prisma/ # Database schema
└── types/ # TypeScript types
The CSV file should contain the following columns:
gameId- Game ID (number)scene- Scene ID (string)row- Row number within scene (number)jpnChrName- Japanese character namejpnSearchText- Japanese text without HTMLengChrName- English character nameengSearchText- English text without HTML
Example:
gameId,scene,row,jpnChrName,jpnSearchText,engChrName,engSearchText
8,c0820,15,1,ルース,俺が仕入れた『導力孫の手』の 売れ行きが悪いんだ……,Roose,The orbal back scratchers I bought in bulk haven't been selling well.Upload MD files containing pre-parsed learning materials. The parser supports:
- Sentence blocks separated by
### 句 Nheaders - Vocabulary tables with word, reading, pitch, part of speech, meaning, and context
- Grammar sections with form, usage, function, and notes
- Translation sections with literal, natural, original, and kana readings
The MD file name must match the CSV file name (excluding extension) for scripts to be matched.
Upload a CSV file containing game dialogue.
Upload a Markdown file containing learning materials. Matches scripts by filename and Japanese text.
List all scripts with pagination and filtering.
Query parameters:
page- Page number (default: 1)limit- Items per page (default: 50)fileName- Filter by file namesearch- Search in text fieldshasLearningMaterial- Filter by learn status ('true' or 'false')
Get list of all files with statistics (total and learned counts).
Get a specific script by ID.
Generate learning material for a script. Returns cached result if available.
Body:
{
"scriptId": "string"
}Get learning material by ID.
Health check endpoint.
Generated learning materials include:
-
Vocabulary Analysis
- Word/Phrase
- Reading with pitch accent
- Part of speech
- Meaning
- Context explanation
- Verb forms (for verbs)
-
Grammar Breakdown
- Grammar point name
- Form and structure
- Usage in context
- Function and nuance
- Common confusion points
- Speech notes (口语缩略)
-
Translation
- Literal translation
- Natural Chinese translation
- Original text
- Full kana reading
- Click on a file's "learned" badge to filter and show only learned scripts
- Filter options: All, Learned (学習済み), Unlearned (未学習)
- Status is preserved across page navigation
- Uses browser's built-in Web Speech API
- No API key required
- Defaults to female Japanese voice when available
- Play/Pause/Stop controls
- Available on all Japanese text (dialogue, original, kana readings)
- Upload components hidden on mobile (desktop only)
- Script list and learning materials fully responsive
- Table/card layouts adapt to screen size
The application is ready to deploy on Vercel.
- Push your code to GitHub
- Import project in Vercel
- Add environment variables:
DATABASE_URLDEEPSEEK_API_KEYNEXT_PUBLIC_APP_URL
- Deploy
For production database, consider using a managed PostgreSQL service like:
- Vercel Postgres
- Supabase
- Neon
- Railway
MIT