Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

FlowWrite — Sentence Autocomplete Writing Assistant

Type naturally and FlowWrite predicts the next word inline and offers full sentence continuations, so finishing a thought takes fewer keystrokes.

  • Frontend: Next.js 14 (App Router) + Tailwind CSS
  • Backend: FastAPI + a custom trigram/bigram/unigram backoff language model (no external API keys or model downloads required — fully offline)

1. Run the backend

cd backend
python3 -m venv venv
source venv/bin/activate        # Windows: venv\Scripts\activate
pip install -r requirements.txt

# (corpus.txt is already generated and included, but you can rebuild it with)
python3 corpus_builder.py

uvicorn main:app --reload --port 8000

The API is now live at http://localhost:8000. Check http://localhost:8000/api/health.

Endpoints:

  • POST /api/predict/next-word { "text": "I want to learn" }{ "prediction": "how" }
  • POST /api/predict/complete { "text": "I want to learn", "count": 4, "style": "casual" }{ "suggestions": [...] }

2. Run the frontend

cd frontend
cp .env.example .env.local     # points at http://localhost:8000 by default
npm install
npm run dev

Open http://localhost:3000.

For a production build:

npm run build
npm run start

Project structure

flowwrite/
├── backend/
│   ├── corpus_builder.py   # generates corpus.txt (diverse, modern sentences)
│   ├── ngram_model.py      # the language model (prediction + generation)
│   ├── main.py             # FastAPI app & endpoints
│   └── requirements.txt
└── frontend/
    ├── app/
    │   ├── page.tsx         # New Text (main editor)
    │   ├── history/         # History
    │   ├── favourites/      # Favourites
    │   ├── settings/        # Settings
    │   └── about/           # About
    ├── components/          # Sidebar, Header, SmartEditor, SuggestionList, ...
    └── lib/                 # api client, localStorage helpers, theme context

How the prediction works

ngram_model.py builds trigram, bigram, and unigram frequency tables from corpus.txt at startup. For inline prediction it takes the most likely next token via trigram → bigram → unigram backoff. For "Complete your thought" it samples several distinct continuations at different temperatures (for variety) and stops each one at a natural sentence boundary, optionally reweighting the vocabulary toward a chosen writing style (professional / casual / creative / simple).

This keeps the whole app self-contained and fast — no API keys, no GPU, no internet connection needed at runtime. If you'd like sharper, more fluent completions later, you can swap ngram_model.py's complete_thought to call an LLM API instead — main.py's request/response shapes won't need to change.

Notes

  • History, Favourites, and Settings are stored in the browser's localStorage (per-device, no backend database).
  • Dark/light theme is applied via a dark class on <html> and persisted to localStorage.
  • next is pinned to 14.2.35 (latest patched 14.x release). A next audit will still show advisories tied to Server Actions / Image Optimizer / Middleware — this app uses none of those features, so they don't apply, but you're welcome to upgrade to Next 15/16 later.

About

Real-time AI writing assistant with inline ghost autocomplete and multi-style sentence completion. Built with Next.js 14, FastAPI & Groq.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages