Development guide for GengoTavern, a React-based AI chat app for language learning with dual storage strategy and emotion detection
A comprehensive development guide for working with GengoTavern, a SillyTavern-inspired web application for practicing foreign languages with custom AI chatbots.
GengoTavern is a React-based chat application that combines language learning with AI characters. The app features a sophisticated dual storage strategy (File System Access API + localStorage fallback), sentiment-based visual novel mode, and seamless character import/export via PNG metadata embedding.
```bash
bun install
bun run dev
bun run build
bun run lint
bun run preview
```
The application uses a context-based architecture with three primary contexts:
1. **AppContext** - Application-wide state (storage strategy, panels, modals)
2. **CharacterContext** - Character management and CRUD operations
3. **UserSettingsContext** - User preferences and API keys
The `StorageManager` class (`src/utils/storageManager.ts`) implements a sophisticated storage system:
```
src/
├── components/ # React components organized by feature
├── contexts/ # React contexts for state management
├── utils/ # Utility functions and API clients
├── types/ # TypeScript interfaces
└── pages/App.tsx # Main application component
```
**Google Gemini API:**
**Sentiment Analysis:**
**Character Management:**
**File Operations Pattern:**
```typescript
// Always check storage strategy before file operations
if (storageStrategy === 'filesystem') {
// Use File System Access API
} else {
// Use localStorage fallback
}
```
**Asset Organization:**
**Emotion-Based Sprite System:**
```typescript
// Characters include:
// - Basic metadata (name, description, etc.)
// - Chat sessions array
// - Sprite collections organized by emotion
// - Background images
```
```typescript
// Messages support:
// - Editing existing messages
// - Regenerating AI responses
// - Continuing conversations
// - Error messages (handled separately with delete functionality)
```
```typescript
// Error messages:
// - Stored separately from regular messages
// - Can be deleted individually
// - Don't interfere with chat history
```
1. **Storage Operations:**
- Always verify storage strategy before file operations
- Handle both filesystem and localStorage cases
- Use sanitized filenames for cross-platform support
2. **State Management:**
- Use appropriate context for state (App/Character/UserSettings)
- Minimize unnecessary re-renders
- Keep contexts focused on single responsibilities
3. **AI Integration:**
- Handle API errors gracefully
- Provide user feedback during long operations
- Implement proper loading states
4. **Sentiment Analysis:**
- Run asynchronously to avoid UI blocking
- Provide fallback sentiment when model unavailable
- Cache results when appropriate
5. **Mobile Responsiveness:**
- Design with collapsible panels
- Test on various screen sizes
- Ensure touch-friendly interactions
The build process creates a single self-contained HTML file (`GengoTavern.html`) for easy distribution. This file includes all JavaScript, CSS, and embedded assets, making it portable across different environments.
GengoTavern is specifically designed for language practice:
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/gengotavern-development-guide/raw