πŸ“š Fiction AI - AI-Powered Novel Writing Assistant

Let AI be your creative partner, not your replacement


🌟 Inspiration

As a web novel enthusiast and developer, I deeply understand the pain points of long-form fiction writing:

$$ \text{Writing Efficiency} = \frac{\text{Creative Output}}{\text{Repetitive Tasks} + \text{Context Management} + \text{Setting Maintenance}} $$

In traditional writing, authors spend enormous time on:

  • Memory Management: Who remembers that side character's name from Chapter 3 in a 500,000-word novel?
  • Setting Consistency: Did the protagonist's eye color just change in Chapter 10?
  • Plot Continuity: Foreshadowing planted but forgotten, storylines broken and disconnected

My inspiration came from a simple idea: AI shouldn't replace authorsβ€”it should be a "tireless assistant"β€”remembering all settings, managing all characters, tracking all plot lines, so authors can focus on what matters most: the creative work itself.


πŸŽ“ What I Learned

1. AI Agent Engineering in Practice

This project gave me deep insights into the power of Function Calling. Using Spring AI 1.0.2, I implemented 16+ specialized tools:

// Tool definition example - Chapter content search
@Tool(name = "SearchChapterContent", 
      description = "Search keywords in chapter content, supports single chapter or global search")
public SearchResult search(
    @ToolParam("Novel ID") Long novelId,
    @ToolParam("Search keyword") String keyword
) { ... }

AI is no longer a simple "Q&A machine"β€”it can now:

  • Read chapter content and character settings
  • Create and modify chapters
  • Apply Diff patches for precise editing
  • Generate character relationship diagrams and plot timelines

2. Multi-Model Compatibility Challenges

Supporting OpenAI, Claude, and Gemini taught me:

$$ \text{Compatibility Complexity} \propto \sum_{i=1}^{n} \text{API Differences}_i \times \text{Response Formats}_i $$

Each model has subtle differences in Tool Calling formats and streaming response handling. Designing a unified abstraction layer was crucial.

3. Real-Time Collaboration Depth

The WebSocket + SSE hybrid architecture revealed the complexity of real-time systems:

  • SSE for AI streaming output
  • WebSocket for multi-device synchronization
  • Redis for session state management

πŸ”§ How I Built It

Architecture Design

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                      Frontend Layer                          β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚   Vue 3     β”‚  β”‚  TipTap     β”‚  β”‚   Mermaid/G6        β”‚  β”‚
β”‚  β”‚   + Vite    β”‚  β”‚  Editor     β”‚  β”‚   Chart Rendering   β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚
                              β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                      Backend Layer                           β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚
β”‚  β”‚              Spring Boot 3.3.5                       β”‚    β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚    β”‚
β”‚  β”‚  β”‚ Spring AI β”‚  β”‚ WebSocket β”‚  β”‚ Sa-Token Auth β”‚    β”‚    β”‚
β”‚  β”‚  β”‚   1.0.2   β”‚  β”‚   + SSE   β”‚  β”‚               β”‚    β”‚    β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚    β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚
                              β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                      Data Layer                              β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚   MySQL     β”‚  β”‚   Redis     β”‚  β”‚   Dify Workflow     β”‚  β”‚
β”‚  β”‚   8.0       β”‚  β”‚   Cache     β”‚  β”‚   (One-Click Write) β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Core Modules

  1. AI Chat Service - Unified multi-model conversation service
  2. Tools System - 16+ specialized writing tools
  3. Novel Management - Novel, chapter, character, and outline management
  4. Chart Generation - Mermaid charts (character relationships, plot lines)
  5. Prompt Market - Prompt marketplace for sharing creative templates

🚧 Challenges I Faced

Challenge 1: Limited Context Window

Long novels can reach hundreds of thousands of words, but AI context windows are limited:

$$ \text{Token Limit}: \quad \text{Context} \leq 128K \ll \text{Total Novel Length} $$

Solution:

  • Chapter summary system: Generate structured JSON summaries for each chapter
  • Smart context building: Load only relevant chapters and character settings
  • Layered memory: Short-term (current conversation) + Long-term (database persistence)

Challenge 2: Precise Diff Patch Application

How to precisely apply AI-generated modification suggestions to the original text?

- He walked into the room and saw a stranger.
+ He cautiously pushed open the door. In the dim room, a dark figure stood with its back to him.

Solution:

  • Implemented ApplyChapterPatchTool supporting Unified Diff format
  • Used java-diff-utils for precise text difference calculation
  • Real-time preview of modifications on frontend

Challenge 3: Multi-Model Tool Calling Differences

OpenAI, Claude, and Gemini have different function calling formats:

Solution:

  • Abstract ChatService interface
  • Implement adapters for each model (Adapter Pattern)
  • Unified tool registration and execution mechanism

πŸ› οΈ Tech Stack

Backend

Technology Version Purpose
Java 17 Primary Language
Spring Boot 3.3.5 Application Framework
Spring AI 1.0.2 AI Model Integration
MyBatis Plus 3.5.12 ORM Framework
MySQL 8.0 Primary Database
Redis - Cache & Session Management
Sa-Token 1.34.0 Authentication & Authorization
WebSocket - Real-time Communication

Frontend

Technology Version Purpose
Vue 3.5 UI Framework
Vite 6.0 Build Tool
TipTap 2.4 Rich Text Editor
Element Plus 2.9 UI Component Library
Mermaid 11.8 Chart Rendering
AntV G6 4.8 Relationship Graph Visualization
Tailwind CSS 3.4 Styling Framework
Tauri 2.7 Desktop App Packaging

AI Services

Service Purpose
OpenAI API GPT Series Models
Anthropic API Claude Series Models
Google Vertex AI Gemini Series Models
Dify Workflow Orchestration (One-Click Write)

Payment Integration

Service Purpose
WeChat Pay Membership Subscription
Alipay Membership Subscription

🎯 Core Features

  1. AI Conversational Writing - Collaborate with AI to complete chapters
  2. Intelligent Tool Calling - AI automatically reads settings, searches content, modifies chapters
  3. Character Management - Complete character settings and relationship management
  4. Outline System - Multi-level outlines (master outline, volume outline, chapter outline)
  5. Chart Generation - Character relationship diagrams, plot timelines, faction distribution maps
  6. Prompt Marketplace - Share and use creative templates
  7. One-Click Writing - Automated writing based on Dify workflows

⚠️ Current Limitations & Honest Reflections

As a university student with limited budget, I want to be transparent about the current constraints:

1. Third-Party API Relay Services

Due to regional restrictions and cost considerations, I'm using third-party API relay services instead of direct official API access:

$$ \text{API Cost}{direct} \gg \text{Budget}{student} \Rightarrow \text{Solution: Relay Services} $$

Trade-offs:

  • βœ… Lower cost, accessible for students
  • ❌ Potential latency and stability issues
  • ❌ Limited access to the latest model versions

2. Tool Calling Accuracy

The models accessible through relay services are often not the top-tier versions, which affects the accuracy of function calling:

Aspect Ideal Current Reality
Tool Selection 95%+ accuracy ~70-80% accuracy
Parameter Extraction Precise Sometimes misses context
Multi-step Reasoning Reliable Occasionally needs retry

Why this happens:

  • Premium models (GPT-4, Claude 3 Opus) have better tool-calling capabilities
  • Budget constraints limit us to more affordable model tiers
  • Complex writing tasks require sophisticated reasoning

3. What I Learned from These Limitations

These constraints actually taught me valuable lessons:

  1. Graceful Degradation: Design systems that handle AI failures gracefully
  2. User Feedback Loops: Let users correct AI mistakes and improve over time
  3. Cost-Aware Architecture: Build with scalability in mindβ€”upgrade models when budget allows

"Constraints breed creativity. Building with limited resources taught me more than unlimited access ever could."


πŸ“ˆ Future Vision

$$ \text{Fiction AI}_{v2.0} = \text{Current Features} + \text{Writing Style Learning} + \text{Book Analysis} + \text{Community Collaboration} $$

  • Writing Style Learning: Learn specific authors' writing styles
  • Book Analysis: Analyze structure and techniques of excellent works
  • Community Features: Author communication, work sharing
  • Dynamic Model Selection: Automatically choose models based on task complexity

"AI is the pen, creativity is the ink, but the story always belongs to humanity."

Built With

  • vue
Share this project:

Updates