chore: Repository documentation cleanup and rewrite
Swadhin Biswas committed 7 months ago
bc27d51
1 parent 137ee96
commit bc27d51
18 files changed
+54 -4131
Showing 18 changed files+54-4004
README.mdopengrammar/FEATURES_IMPLEMENTATION.mdopengrammar/GRAMMARLY_CLONE.mdopengrammar/GROQ_SETUP.mdopengrammar/IMPROVEMENTS.mdopengrammar/PRODUCTION.mdopengrammar/SELF_HOSTING.mdopengrammar/SETUP_GUIDE.mdopengrammar/TESTING_GUIDE.mdopengrammar/TEST_GRAMMARLY_STYLE.mdopengrammar/TROUBLESHOOTING.mdopengrammar/WHATS_NEW.mdopengrammar/backend/.gitignoreopengrammar/backend/MULTI_PLATFORM.mdopengrammar/backend/RAILWAY_DEPLOYMENT.mdopengrammar/backend/README.npm.mdopengrammar/backend/RENDER_DEPLOYMENT.mdopengrammar/backend/VERCEL_DEPLOYMENT.md
βΌREADME.md
+53-63
| @@ -7,105 +7,95 @@ | ||
7 | 7 | *The completely free, zero-compromise Grammarly alternative you can host yourself.* |
8 | 8 | |
9 | 9 | [](https://opensource.org/licenses/Apache-2.0) |
10 | - [](http://makeapullrequest.com) | |
11 | - [](https://reactjs.org/) | |
12 | - [](https://vitejs.dev/) | |
10 | + [](https://www.npmjs.com/package/opengrammar-server) | |
11 | + [](https://hub.docker.com/r/swadhinbiswas/opengrammar-backend) | |
12 | + [](http://makeapullrequest.com) | |
13 | + | |
14 | + π **[Official Website](https://opengrammer.eu.cc)** | π **[Documentation](https://opengrammer.eu.cc/docs)** | |
13 | 15 | </div> |
14 | 16 | |
15 | 17 | --- |
16 | 18 | |
17 | 19 | Writing clearly matters. But achieving perfect grammar shouldn't mean sacrificing your privacy or paying a premium monthly subscription to a tech giant. |
18 | 20 | |
19 | -Welcome to **OpenGrammar**βa powerful, robust browser extension built from the ground up to match the premium writing tools you already know, but with one massive difference: **You own your data, and it runs completely for free.** | |
21 | +**OpenGrammar** is a powerful, robust intelligent writing assistant built from the ground up to match the premium writing tools you already know, but with one massive difference: **You own your data, and it runs completely for free.** | |
20 | 22 | |
21 | 23 | ## π Why OpenGrammar? |
22 | 24 | |
23 | -For too long, the industry standard has been to quietly siphon every keystroke you type to remote servers, locking advanced features behind hefty paywalls. OpenGrammar is our answer to that: | |
24 | - | |
25 | 25 | 1. **The Zero-Cost Foundation:** Out of the box, our core engine runs 100% locally in your browser. With a massive 156,000-word offline dictionary, it instantly catches misspellings, passive voice, and weak phrasing without ever pinging a server. |
26 | -2. **Bring Your Own Brain (BYOK):** Want deep, context-aware AI corrections? Just plug in your own API key (OpenAI, Groq, Together, OpenRouter, or even local open-source models via Ollama). You pay fractions of a cent exclusively for what you use, cutting out the middleman entirely. | |
27 | -3. **Paranoid-Level Privacy:** We don't have a database. We don't want your user data. Your API key never leaves your browser storage. If you choose to use the AI features, your text is processed through a stateless edge function and immediately deleted. | |
28 | -4. **Deploy It Yourself:** Trust no one? Perfect. You can deploy our lightweight backend to Cloudflare Workers or Vercel Edge for free, in a single command. You own the entire pipeline. | |
26 | +2. **Bring Your Own Brain (BYOK):** Want deep, context-aware AI corrections? Just plug in your own API key (OpenAI, Groq, Together, OpenRouter, or even local models via Ollama). You pay fractions of a cent exclusively for what you use. | |
27 | +3. **Paranoid-Level Privacy:** We don't have a database. We don't want your user data. Your API key never leaves your browser storage. Text processed through the AI is immediately deleted via stateless edge functions. | |
28 | +4. **Deploy It Yourself:** You own the entire pipeline. Host our lightweight backend instantly via Docker, npm, Cloudflare, Vercel, or Netlify. | |
29 | 29 | |
30 | -## β¨ Under The Hood | |
31 | - | |
32 | -OpenGrammar 2.0 isn't just a wrapperβit's a dual-engine powerhouse. | |
30 | +--- | |
33 | 31 | |
34 | -- **Blazing Fast & Works Everywhere:** We seamlessly inject directly into text inputs, textareas, and complex rich-text editors (Gmail, Google Docs, Notion, Reddit). Built on React, Vite, and Manifest V3 so it never bogs down your browser. | |
35 | -- **The Dual-Engine Architecture:** | |
36 | - 1. *The Offline Sentinel:* A Damerau-Levenshtein edit-distance and phonetic matching spellchecker catches immediate typos. 40+ granular grammar rules instantly flag subject-verb agreement issues, sentence fragments, and commonly confused words (like affect/effect). | |
37 | - 2. *The AI Enforcer:* An intelligent LLM router. Thanks to our **Deduplication Logic**, the AI is completely aware of what the Offline Sentinel already caught. It *never* wastes expensive tokens repeating basic fixes. | |
38 | -- **Smart Context Awareness:** Are you writing a casual tweet, a highly technical documentation page, or a formal business email? The engine automatically detects your domain and scales its strictness appropriately. | |
39 | -- **Deep Analytics & History:** | |
40 | - - **Dynamic Writing Score:** Evaluates your text dynamically from 0-100 based on your Correctness, Readability, Engagement (vocabulary diversity), and Sentence Delivery variation. | |
41 | - - **Private Daily Tracking:** Silently logs your writing history, words checked, and average daily score directly to your local extension storage. | |
42 | -- **Tone & Style Rewriting:** Right-click context menus or a quick `Ctrl+Shift+R` to instantly rethink highlighted text into 8 different tones. | |
43 | -- **Flawless UI:** The classic red, yellow, and blue squiggly underlines you grew up with, paired with slick, interactive click-to-apply tooltips and a gorgeous stats dashboard. | |
32 | +## π Live Production Endpoints | |
44 | 33 | |
45 | -## π Getting Started (For Users) | |
34 | +Don't want to host the backend yourself? OpenGrammar comes with incredibly fast, globally-distributed public edge deployments that you can connect your browser extension to instantly: | |
46 | 35 | |
47 | -*Note: As an open-source tool in active development, OpenGrammar is currently installed via developer mode.* | |
36 | +- βοΈ **Cloudflare Workers:** [`https://cf.opengrammer.eu.cc/`](https://cf.opengrammer.eu.cc/) | |
37 | +- β³ **Vercel Edge:** [`https://vercel.opengrammer.eu.cc/`](https://vercel.opengrammer.eu.cc/) | |
38 | +- π© **Netlify Functions:** [`https://nl.opengrammer.eu.cc/`](https://nl.opengrammer.eu.cc/) | |
48 | 39 | |
49 | -1. **Download the Extension:** Grab the latest release or clone this repository. | |
50 | -2. **Open Extensions Page:** In Chrome/Brave/Edge, navigate to `chrome://extensions/`. | |
51 | -3. **Enable Developer Mode:** Toggle the switch in the top right corner. | |
52 | -4. **Load Unpacked:** Click the "Load unpacked" button and select the `opengrammar/extension/dist` folder you built or downloaded. | |
53 | -5. **Configure:** Click the OpenGrammar feather icon in your browser toolbar. Paste in your OpenAI, Groq, or OpenRouter API key to unlock the advanced AI engine. | |
40 | +--- | |
54 | 41 | |
55 | -## π» Developer Guide: Build & Deploy | |
42 | +## π οΈ Installation & Self-Hosting | |
56 | 43 | |
57 | -Want to build OpenGrammar from scratch or deploy your own serverless backend? Let's get to it. | |
44 | +Our backend is natively multi-platform. Choose the environment that best fits your workflow. | |
58 | 45 | |
59 | -### Prerequisites | |
46 | +### π¦ Option 1: NPM / Mobile / Node Environments | |
47 | +Run the OpenGrammar server on any machine with Node.js. You can effortlessly run this on an old laptop, a VPS, or even an Android phone using Termux! | |
60 | 48 | |
61 | -- Node.js (v18 or newer) | |
62 | -- [Bun](https://bun.sh/) (Highly Recommended) or npm/pnpm | |
49 | +```bash | |
50 | +# Run instantly without installing | |
51 | +npx opengrammar-server | |
63 | 52 | |
64 | -### 1. Set up the Backend (Serverless Edge API) | |
53 | +# Or install globally for persistent usage | |
54 | +npm install -g opengrammar-server | |
55 | +opengrammar-server --port 8787 | |
56 | +``` | |
65 | 57 | |
66 | -Our backend isn't a bloated server. It's an ultra-lightweight Hono API that securely masks and handles AI routing. | |
58 | +### π³ Option 2: Docker | |
59 | +We maintain a highly optimized, multi-architecture Docker image. This is the recommended route for standard server environments or local homelabs. | |
67 | 60 | |
68 | 61 | ```bash |
69 | -# Navigate to the backend folder | |
70 | -cd opengrammar/backend | |
71 | - | |
72 | -# Install dependencies lightning fast with Bun | |
73 | -bun install | |
62 | +# Pull the production image | |
63 | +docker pull swadhinbiswas/opengrammar-backend:latest | |
74 | 64 | |
75 | -# Run locally for testing (runs on http://localhost:8787) | |
76 | -bun run dev | |
77 | - | |
78 | -# Deploy globally to Cloudflare Workers (requires a free Cloudflare account) | |
79 | -bun run deploy | |
65 | +# Run the container (exposes port 8787) | |
66 | +docker run -d -p 8787:8787 --name opengrammar swadhinbiswas/opengrammar-backend:latest | |
80 | 67 | ``` |
81 | 68 | |
82 | -### 2. Set up the Chrome Extension | |
69 | +### π§© Option 3: Browser Extension (For Users) | |
83 | 70 | |
84 | -```bash | |
85 | -# Navigate to the extension folder | |
86 | -cd opengrammar/extension | |
71 | +1. Download the latest release from the `opengrammar/extension/dist` build. | |
72 | +2. Open Chrome/Brave/Edge and navigate to `chrome://extensions/`. | |
73 | +3. Enable **Developer Mode**. | |
74 | +4. Click **Load unpacked** and select the extension folder. | |
75 | +5. Click the OpenGrammar feather icon in your toolbar, input your custom AI API keys, and link it to one of the **Live Production Endpoints** listed above! | |
87 | 76 | |
88 | -# Install dependencies | |
89 | -bun install | |
77 | +--- | |
90 | 78 | |
91 | -# Build the extension into an optimized bundle | |
92 | -bun run build | |
93 | -``` | |
79 | +## β¨ Core Features | |
94 | 80 | |
95 | -The build process will generate a `dist/` folder. Load this folder into your browser following the user instructions above! | |
81 | +- **The Dual-Engine Architecture:** A blazing fast local (offline) RegEx + Dictionary matching engine, paired securely with a configurable LLM router framework for tone rewriting and smart context adjustments. | |
82 | +- **Deduplication Logic:** The AI is fully synchronized with the local spellchecker. It never wastes expensive AI tokens re-checking typos already caught locally. | |
83 | +- **Smart Context Awareness:** Automatically detects if you are writing a casual tweet, a technical document, or a formal business email, scaling its strictness appropriately. | |
84 | +- **Dynamic Writing Score:** Evaluates your text dynamically (0-100) based on Correctness, Readability, Engagement, and Sentence Delivery. | |
85 | +- **Flawless Integrations:** Securely injects into rich-text editors including Gmail, Google Docs, Notion, and Reddit. | |
86 | + | |
87 | +--- | |
96 | 88 | |
97 | 89 | ## π€ Join the Rebellion |
98 | 90 | |
99 | 91 | **We need your help to unseat the monopolies and make OpenGrammar the definitive open-source writing assistant.** |
100 | 92 | |
101 | -Our biggest mission right now is building the ultimate library of local (offline) grammar and style rules. You don't even need to be a software engineer to contributeβif you're a language nerd with a good eye for grammar, we want you! | |
102 | - | |
103 | -- **π Add Grammar Rules:** Help us expand `analyzer.ts` with more regex-based rules for common mistakes, style improvements, and clarity checks. See our [GRAMMAR_RULES.md](./GRAMMAR_RULES.md) guide. | |
104 | -- **π Hunt Bugs:** Found a weird website where the text highlighting breaks? Open an issue. | |
105 | -- **π‘ Dream Up Features:** Have an idea for something cool? Start a thread in our Discussions tab. | |
93 | +Whether you are a TypeScript developer wanting to optimize edge latency, or a language nerd looking to build out our offline Regex `GRAMMAR_RULES.md`βwe want you! | |
106 | 94 | |
107 | -Check out our [CONTRIBUTING.md](./CONTRIBUTING.md) and peek at the `ROADMAP.md` to see where we're headed next. | |
95 | +- Read our [CONTRIBUTING.md](./CONTRIBUTING.md) guide. | |
96 | +- Check our `ROADMAP.md` to see what we are currently building. | |
97 | +- Open an issue for bugs or start a thread in our Discussions tab. | |
108 | 98 | |
109 | 99 | ## π License |
110 | 100 | |
111 | -This project is open-source and proudly licensed under the Apache 2.0 License. See the LICENSE file for details. Let's build the future of writing together. | |
101 | +This project is proudly open-source under the **Apache 2.0 License**. See the `LICENSE` file for details. Let's build the future of writing together. | |
112 | 102 | |
βΌopengrammar/FEATURES_IMPLEMENTATION.md
+0-451
| @@ -1,464 +0,0 @@ | ||
1 | -# π OpenGrammar Feature Implementation Guide | |
2 | - | |
3 | -This document provides implementation details for Phase 2, 3, and 4 features. | |
4 | - | |
5 | - | |
6 | -## β
Phase 2: Enhanced UX (Completed) | |
7 | - | |
8 | -### 1. Tone & Style Adjustments β | |
9 | -**Status:** Implemented | |
10 | -**Files:** `extension/src/rewrite/` | |
11 | - | |
12 | -**Features:** | |
13 | -- 8 tone options (formal, casual, professional, friendly, concise, detailed, persuasive, neutral) | |
14 | -- Context menu integration (right-click β Rewrite) | |
15 | -- Keyboard shortcut (Ctrl+Shift+R) | |
16 | -- Side-by-side comparison UI | |
17 | -- Apply/Copy buttons | |
18 | - | |
19 | -**Usage:** | |
20 | -```javascript | |
21 | -// Select text β Right-click β "Rewrite with OpenGrammar" | |
22 | -// Or press Ctrl+Shift+R | |
23 | -``` | |
24 | - | |
25 | -### 2. Writing Statistics β | |
26 | -**Status:** Implemented | |
27 | -**Files:** `extension/src/stats/` | |
28 | - | |
29 | -**Metrics:** | |
30 | -- Word count, character count, sentence count, paragraph count | |
31 | -- Flesch Reading Ease Score | |
32 | -- Flesch-Kincaid Grade Level | |
33 | -- Automated Readability Index (ARI) | |
34 | -- Vocabulary diversity | |
35 | -- Reading/speaking time estimates | |
36 | -- Issue breakdown by type | |
37 | - | |
38 | -**Usage:** | |
39 | -```javascript | |
40 | -// Access via popup β Statistics tab | |
41 | -// Or future: keyboard shortcut | |
42 | -``` | |
43 | - | |
44 | -### 3. Custom Prompts for AI β | |
45 | -**Status:** Implemented (Library) | |
46 | -**Files:** `extension/src/prompts/` | |
47 | - | |
48 | -**Preset Prompts:** | |
49 | -- Fix Grammar | |
50 | -- Make Formal/Casual | |
51 | -- Simplify | |
52 | -- Expand | |
53 | -- Summarize | |
54 | -- British English | |
55 | -- Persuade | |
56 | - | |
57 | -**Next Steps:** | |
58 | -- Add UI for prompt selection in rewrite popup | |
59 | -- Allow users to create custom prompts | |
60 | -- Save favorite prompts to storage | |
61 | - | |
62 | - | |
63 | -## π¨ Phase 3: Advanced Features (Implementation Guide) | |
64 | - | |
65 | -### 4. Better Google Docs Support | |
66 | - | |
67 | -**Implementation Steps:** | |
68 | - | |
69 | -1. **Create Google Docs-specific content script:** | |
70 | -```typescript | |
71 | -// extension/src/content/google-docs.ts | |
72 | -export class GoogleDocsHandler { | |
73 | - private editorElement: HTMLElement | null = null; | |
74 | - | |
75 | - findEditor() { | |
76 | - // Google Docs uses a complex iframe structure | |
77 | - const iframe = document.querySelector('.docs-texteventtarget-iframe'); | |
78 | - if (iframe) { | |
79 | - const doc = (iframe as HTMLIFrameElement).contentDocument; | |
80 | - this.editorElement = doc?.querySelector('.kix-appview-editor'); | |
81 | - } | |
82 | - } | |
83 | - | |
84 | - extractText() { | |
85 | - // Google Docs stores content in paragraph spans | |
86 | - const paragraphs = this.editorElement?.querySelectorAll('.kix-paragraphrenderer'); | |
87 | - return Array.from(paragraphs || []).map(p => p.textContent).join('\n'); | |
88 | - } | |
89 | -} | |
90 | -``` | |
91 | - | |
92 | -2. **Update manifest for iframe access:** | |
93 | -```json | |
94 | -"content_scripts": [ | |
95 | - { | |
96 | - "matches": ["https://docs.google.com/*"], | |
97 | - "js": ["src/content/google-docs.ts"], | |
98 | - "all_frames": true | |
99 | - } | |
100 | -] | |
101 | -``` | |
102 | - | |
103 | -3. **Handle Google Docs-specific events:** | |
104 | -- Listen for `docs-chapter-renderer` events | |
105 | -- Monitor selection changes in iframe | |
106 | -- Position highlights relative to editor viewport | |
107 | - | |
108 | -**Estimated Effort:** 2-3 days | |
109 | - | |
110 | - | |
111 | -### 5. Autocomplete & Prediction | |
112 | - | |
113 | -**Implementation:** | |
114 | - | |
115 | -1. **Add autocomplete API endpoint:** | |
116 | -```typescript | |
117 | -// backend/src/index.ts | |
118 | -app.post('/autocomplete', async (c) => { | |
119 | - const { text, cursor, apiKey, model } = await c.req.json(); | |
120 | - | |
121 | - // Get last 50 characters before cursor | |
122 | - const context = text.substring(Math.max(0, cursor - 50), cursor); | |
123 | - | |
124 | - const prompt = `Continue this text naturally (max 20 words): | |
125 | - | |
126 | -Context: ${context}... | |
127 | - | |
128 | -Continuation:`; | |
129 | - | |
130 | - // Call LLM with max_tokens=20 | |
131 | - const completion = await openai.chat.completions.create({ | |
132 | - messages: [{ role: 'user', content: prompt }], | |
133 | - model, | |
134 | - max_tokens: 20, | |
135 | - temperature: 0.8, | |
136 | - }); | |
137 | - | |
138 | - return c.json({ | |
139 | - suggestion: completion.choices[0].message.content?.trim(), | |
140 | - }); | |
141 | -}); | |
142 | -``` | |
143 | - | |
144 | -2. **Add content script autocomplete UI:** | |
145 | -```typescript | |
146 | -// extension/src/content/autocomplete.ts | |
147 | -export class AutocompletePopup { | |
148 | - private popup: HTMLElement | null = null; | |
149 | - | |
150 | - showSuggestion(suggestion: string, position: { top: number; left: number }) { | |
151 | - this.popup = document.createElement('div'); | |
152 | - this.popup.className = 'opengrammar-autocomplete'; | |
153 | - this.popup.innerHTML = ` | |
154 | - <span class="ghost-text">${text}</span> | |
155 | - <span class="suggestion">${suggestion}</span> | |
156 | - `; | |
157 | - // Position at cursor | |
158 | - } | |
159 | - | |
160 | - accept() { | |
161 | - // Insert suggestion at cursor | |
162 | - } | |
163 | -} | |
164 | -``` | |
165 | - | |
166 | -3. **Debounce API calls (300ms after typing stops)** | |
167 | - | |
168 | -**Estimated Effort:** 3-4 days | |
169 | - | |
170 | - | |
171 | -### 6. Contextual Understanding | |
172 | - | |
173 | -**Implementation:** | |
174 | - | |
175 | -1. **Add context window to analysis:** | |
176 | -```typescript | |
177 | -// backend/src/analyzer.ts | |
178 | -export async function analyzeWithContext( | |
179 | - text: string, | |
180 | - context: { | |
181 | - previousParagraphs: string[]; | |
182 | - documentType?: string; | |
183 | - tone?: string; | |
184 | - } | |
185 | -) { | |
186 | - const prompt = `Analyze this text considering the context: | |
187 | - | |
188 | -Previous context: ${context.previousParagraphs.join(' ')} | |
189 | -Document type: ${context.documentType || 'general'} | |
190 | - | |
191 | -Text to analyze: ${text} | |
192 | - | |
193 | -Consider consistency with previous content and overall tone.`; | |
194 | - | |
195 | - // Call LLM with context | |
196 | -} | |
197 | -``` | |
198 | - | |
199 | -2. **Store document context in background:** | |
200 | -```typescript | |
201 | -// extension/src/background/index.ts | |
202 | -const documentContexts = new Map<string, { | |
203 | - text: string; | |
204 | - timestamp: number; | |
205 | - tone?: string; | |
206 | -}>(); | |
207 | - | |
208 | -// Keep last 5000 characters per domain | |
209 | -chrome.tabs.onActivated.addListener((tab) => { | |
210 | - // Load context for this tab | |
211 | -}); | |
212 | -``` | |
213 | - | |
214 | -**Estimated Effort:** 2-3 days | |
215 | - | |
216 | - | |
217 | -### 7. Reading Time Estimates β | |
218 | -**Status:** Already implemented in Writing Statistics | |
219 | - | |
220 | -**Current Features:** | |
221 | -- Reading time (200 wpm) | |
222 | -- Speaking time (150 wpm) | |
223 | - | |
224 | -**Enhancements:** | |
225 | -- Add detailed breakdown (by paragraph) | |
226 | -- Show progress indicator while reading | |
227 | -- Add customizable reading speed | |
228 | - | |
229 | - | |
230 | -### 8. Vocabulary Diversity Metrics β | |
231 | -**Status:** Already implemented in Writing Statistics | |
232 | - | |
233 | -**Current Features:** | |
234 | -- Unique word count | |
235 | -- Vocabulary diversity percentage | |
236 | -- Average word length | |
237 | - | |
238 | -**Enhancements:** | |
239 | -- Track most used words | |
240 | -- Suggest synonyms for overused words | |
241 | -- Show vocabulary level (basic, intermediate, advanced) | |
242 | - | |
243 | - | |
244 | -## π Phase 4: Expansion (Implementation Guide) | |
245 | - | |
246 | -### 9. Firefox Support | |
247 | - | |
248 | -**Steps:** | |
249 | - | |
250 | -1. **Create Firefox-specific manifest:** | |
251 | -```json | |
252 | -// extension/manifest-firefox.json | |
253 | -{ | |
254 | - "browser_specific_settings": { | |
255 | - "gecko": { | |
256 | - "id": "[email protected]", | |
257 | - "strict_min_version": "109.0" | |
258 | - } | |
259 | - }, | |
260 | - // Rest same as Chrome manifest | |
261 | -} | |
262 | -``` | |
263 | - | |
264 | -2. **Adjust Chrome-specific APIs:** | |
265 | -```typescript | |
266 | -// Use browser polyfill | |
267 | -import browser from 'webextension-polyfill'; | |
268 | - | |
269 | -// Replace chrome.* with browser.* | |
270 | -browser.storage.sync.get(...); | |
271 | -browser.contextMenus.create(...); | |
272 | -``` | |
273 | - | |
274 | -3. **Add Firefox build script:** | |
275 | -```json | |
276 | -// package.json | |
277 | -"scripts": { | |
278 | - "build:firefox": "vite build --mode firefox" | |
279 | -} | |
280 | -``` | |
281 | - | |
282 | -4. **Test in Firefox:** | |
283 | -- Load temporary add-on in about:debugging | |
284 | -- Submit to Firefox Add-ons | |
285 | - | |
286 | -**Estimated Effort:** 1-2 days | |
287 | - | |
288 | - | |
289 | -### 10. Safari Support | |
290 | - | |
291 | -**Steps:** | |
292 | - | |
293 | -1. **Use Xcode to create Safari Web Extension:** | |
294 | -```bash | |
295 | -xcrun safari-web-extension-converter extension/dist/ \ | |
296 | - --project-location ./safari \ | |
297 | - --bundle-identifier com.opengrammar.safari | |
298 | -``` | |
299 | - | |
300 | -2. **Adjust manifest for Safari:** | |
301 | -- Some Chrome APIs not supported | |
302 | -- May need native app for full functionality | |
303 | - | |
304 | -3. **Create macOS app wrapper:** | |
305 | -- Swift app to host extension | |
306 | -- Notarize for App Store distribution | |
307 | - | |
308 | -**Estimated Effort:** 3-5 days | |
309 | - | |
310 | - | |
311 | -### 11. Desktop Apps | |
312 | - | |
313 | -**Implementation:** | |
314 | - | |
315 | -1. **Use Electron for cross-platform desktop app:** | |
316 | -```bash | |
317 | -npm install electron | |
318 | -``` | |
319 | - | |
320 | -2. **Create Electron main process:** | |
321 | -```typescript | |
322 | -// desktop/main.ts | |
323 | -import { app, BrowserWindow } from 'electron'; | |
324 | - | |
325 | -function createWindow() { | |
326 | - const win = new BrowserWindow({ | |
327 | - width: 800, | |
328 | - height: 600, | |
329 | - webPreferences: { | |
330 | - nodeIntegration: true, | |
331 | - }, | |
332 | - }); | |
333 | - | |
334 | - win.loadURL('https://opengrammar.app'); | |
335 | -} | |
336 | - | |
337 | -app.whenReady().then(createWindow); | |
338 | -``` | |
339 | - | |
340 | -3. **Integrate with system-wide text inputs:** | |
341 | -- Use native messaging for system-wide support | |
342 | -- Create keyboard shortcut for global access | |
343 | - | |
344 | -**Estimated Effort:** 5-7 days | |
345 | - | |
346 | - | |
347 | -### 12. Developer API | |
348 | - | |
349 | -**Implementation:** | |
350 | - | |
351 | -1. **Add API key management:** | |
352 | -```typescript | |
353 | -// backend/src/index.ts | |
354 | -app.post('/api/v1/analyze', async (c) => { | |
355 | - const apiKey = c.req.header('Authorization')?.replace('Bearer ', ''); | |
356 | - | |
357 | - // Validate API key against database | |
358 | - const user = await validateApiKey(apiKey); | |
359 | - if (!user) { | |
360 | - return c.json({ error: 'Invalid API key' }, 401); | |
361 | - } | |
362 | - | |
363 | - // Process request | |
364 | - const { text } = await c.req.json(); | |
365 | - const issues = RuleBasedAnalyzer.analyze(text); | |
366 | - | |
367 | - return c.json({ issues }); | |
368 | -}); | |
369 | -``` | |
370 | - | |
371 | -2. **Add rate limiting:** | |
372 | -```typescript | |
373 | -import { rateLimit } from 'hono-rate-limit'; | |
374 | - | |
375 | -app.use('/api/*', rateLimit({ | |
376 | - windowMs: 60 * 1000, // 1 minute | |
377 | - max: 100, // 100 requests per minute | |
378 | -})); | |
379 | -``` | |
380 | - | |
381 | -3. **Create API documentation:** | |
382 | -```markdown | |
383 | -# OpenGrammar API | |
384 | - | |
385 | -## POST /api/v1/analyze | |
386 | - | |
387 | -Analyze text for grammar and style issues. | |
388 | - | |
389 | -### Request | |
390 | -```json | |
391 | -{ | |
392 | - "text": "string", | |
393 | - "options": { | |
394 | - "checkGrammar": true, | |
395 | - "checkStyle": true | |
396 | - } | |
397 | -} | |
398 | -``` | |
399 | - | |
400 | -### Response | |
401 | -```json | |
402 | -{ | |
403 | - "issues": [...], | |
404 | - "metadata": {...} | |
405 | -} | |
406 | -``` | |
407 | -``` | |
408 | - | |
409 | -4. **Add SDK packages:** | |
410 | -```bash | |
411 | -npm publish @opengrammar/js | |
412 | -pip publish opengrammar | |
413 | -``` | |
414 | - | |
415 | -**Estimated Effort:** 3-4 days | |
416 | - | |
417 | - | |
418 | -## π Priority & Timeline | |
419 | - | |
420 | -| Feature | Priority | Effort | Dependencies | | |
421 | -|---------|----------|--------|--------------| | |
422 | -| Google Docs Support | High | 2-3 days | None | | |
423 | -| Autocomplete | High | 3-4 days | None | | |
424 | -| Firefox Support | Medium | 1-2 days | None | | |
425 | -| Developer API | Medium | 3-4 days | Backend updates | | |
426 | -| Contextual Understanding | Medium | 2-3 days | Storage updates | | |
427 | -| Desktop Apps | Low | 5-7 days | None | | |
428 | -| Safari Support | Low | 3-5 days | macOS required | | |
429 | - | |
430 | -**Total Estimated Effort:** 19-28 days | |
431 | - | |
432 | - | |
433 | -## π― Next Steps | |
434 | - | |
435 | -1. **Immediate (Week 1):** | |
436 | - - [ ] Add UI for custom prompts in rewrite popup | |
437 | - - [ ] Implement Google Docs support | |
438 | - - [ ] Add autocomplete feature | |
439 | - | |
440 | -2. **Short-term (Week 2-3):** | |
441 | - - [ ] Build Firefox extension | |
442 | - - [ ] Add contextual understanding | |
443 | - - [ ] Create developer API | |
444 | - | |
445 | -3. **Long-term (Month 2+):** | |
446 | - - [ ] Build desktop apps | |
447 | - - [ ] Safari extension | |
448 | - - [ ] Advanced AI features | |
449 | - | |
450 | - | |
451 | -**Contributing:** Pick a feature from the list above and create a PR! Each feature includes implementation details to get you started. | |
452 | 0 | |
βΌopengrammar/GRAMMARLY_CLONE.md
+0-328
| @@ -1,339 +0,0 @@ | ||
1 | -# π― OpenGrammar vs Grammarly - Exact Feature Comparison | |
2 | - | |
3 | -## β
OpenGrammar IS Now a Grammarly Clone! | |
4 | - | |
5 | -OpenGrammar uses the **same hybrid approach** as Grammarly: | |
6 | - | |
7 | -``` | |
8 | -Grammarly = Rule-based + AI | |
9 | -OpenGrammar = Rule-based + AI β
| |
10 | -``` | |
11 | - | |
12 | - | |
13 | -## π Feature-by-Feature Comparison | |
14 | - | |
15 | -| Feature | Grammarly | OpenGrammar | Status | | |
16 | -|---------|-----------|-------------|--------| | |
17 | -| **Rule-Based Checking** | β
| β
| β
Complete | | |
18 | -| **AI-Powered Checking** | β
| β
| β
Complete | | |
19 | -| **Spelling Correction** | β
| β
(100+ words) | β
Complete | | |
20 | -| **Basic Grammar** | β
| β
(35+ rules) | β
Complete | | |
21 | -| **Punctuation** | β
| β
| β
Complete | | |
22 | -| **Tone Detection** | β
| β
(8 tones) | β
Complete | | |
23 | -| **Style Suggestions** | β
| β
| β
Complete | | |
24 | -| **Sentence Rewriting** | β
| β
| β
Complete | | |
25 | -| **Context Understanding** | β
| β
(LLM-based) | β
Complete | | |
26 | -| **Passive Voice** | β
| β
| β
Complete | | |
27 | -| **Readability Scores** | β
| β
(Flesch, ARI) | β
Complete | | |
28 | -| **Word Count** | β
| β
| β
Complete | | |
29 | -| **Reading Time** | β
| β
| β
Complete | | |
30 | -| **Vocabulary Analysis** | β
| β
| β
Complete | | |
31 | -| **Custom Dictionary** | β
| β
| β
Complete | | |
32 | -| **Ignore Suggestions** | β
| β
| β
Complete | | |
33 | -| **Multi-Platform** | β
| β
(Chrome + more) | β
Complete | | |
34 | -| **Privacy-First** | β | β
| β
Better! | | |
35 | -| **Free** | β (Freemium) | β
(100% Free) | β
Better! | | |
36 | -| **Open Source** | β | β
| β
Better! | | |
37 | -| **Self-Hostable** | β | β
| β
Better! | | |
38 | -| **Multiple AI Providers** | β | β
(6 providers) | β
Better! | | |
39 | -| **Local LLM Support** | β | β
(Ollama) | β
Better! | | |
40 | - | |
41 | - | |
42 | -## π§ How OpenGrammar Matches Grammarly | |
43 | - | |
44 | -### 1οΈβ£ Rule-Based System (Like Grammarly) | |
45 | - | |
46 | -**Grammarly's Approach:** | |
47 | -- Uses traditional grammar rules | |
48 | -- Fast, works offline | |
49 | -- Catches basic errors instantly | |
50 | - | |
51 | -**OpenGrammar's Implementation:** | |
52 | -```typescript | |
53 | -// 140+ rule-based checks | |
54 | -β
checkBasicGrammar() - 35+ grammar rules | |
55 | -β
checkCommonMisspellings() - 100+ words | |
56 | -β
checkPassiveVoice() | |
57 | -β
checkRepetition() | |
58 | -β
checkSpacingErrors() | |
59 | -β
checkApostropheErrors() | |
60 | -β
checkPunctuation() | |
61 | -β
checkLongSentences() | |
62 | -β
checkDoubleNegatives() | |
63 | -β
checkRedundantPhrases() | |
64 | -β
checkWeakWords() | |
65 | -β
checkCliches() | |
66 | -``` | |
67 | - | |
68 | -**Examples:** | |
69 | -``` | |
70 | -Input: "me and him went and buyed milks" | |
71 | - | |
72 | -Rule-based detects: | |
73 | -β "me and him" β "he and I" (pronoun error) | |
74 | -β "buyed" β "bought" (irregular verb) | |
75 | - | |
76 | -β
Works WITHOUT AI - instant & free! | |
77 | -``` | |
78 | - | |
79 | - | |
80 | -### 2οΈβ£ AI-Powered System (Like Grammarly) | |
81 | - | |
82 | -**Grammarly's Approach:** | |
83 | -- Uses machine learning models | |
84 | -- Understands context | |
85 | -- Provides advanced suggestions | |
86 | -- Detects tone and style | |
87 | - | |
88 | -**OpenGrammar's Implementation:** | |
89 | -```typescript | |
90 | -// Multi-provider AI support | |
91 | -β
Groq (Llama 3.1 70B) - Fast & Free | |
92 | -β
OpenAI (GPT-4, GPT-3.5) - Best quality | |
93 | -β
OpenRouter (100+ models) | |
94 | -β
Together AI (Open source) | |
95 | -β
Ollama (Local LLM) - Offline & Private | |
96 | -β
Custom endpoints | |
97 | - | |
98 | -// AI handles: | |
99 | -β
Advanced grammar | |
100 | -β
Context understanding | |
101 | -β
Tone suggestions | |
102 | -β
Style improvements | |
103 | -β
Sentence rewriting | |
104 | -``` | |
105 | - | |
106 | -**Examples:** | |
107 | -``` | |
108 | -Input: "The report was written by John yesterday" | |
109 | - | |
110 | -AI detects: | |
111 | -β οΈ Passive voice β "John wrote the report yesterday" | |
112 | -π‘ Style suggestion β More direct and clear | |
113 | - | |
114 | -β
Contextual understanding! | |
115 | -``` | |
116 | - | |
117 | - | |
118 | -### 3οΈβ£ Hybrid System (Grammarly's Secret) | |
119 | - | |
120 | -**How Grammarly Works:** | |
121 | -``` | |
122 | -User types β Rule check (instant) β AI check (contextual) β Combine results β Show suggestions | |
123 | -``` | |
124 | - | |
125 | -**How OpenGrammar Works:** | |
126 | -```typescript | |
127 | -// Exact same hybrid approach! | |
128 | -app.post('/analyze', async (c) => { | |
129 | - // 1. Rule-based (instant, free) | |
130 | - let issues = RuleBasedAnalyzer.analyze(text); | |
131 | - | |
132 | - // 2. AI-powered (contextual, smart) | |
133 | - if (apiKey || provider === 'ollama') { | |
134 | - const llmIssues = await LLMAnalyzer.analyze(text, apiKey, model, provider); | |
135 | - issues = [...issues, ...llmIssues]; | |
136 | - } | |
137 | - | |
138 | - // 3. Return combined results | |
139 | - return { issues }; | |
140 | -}); | |
141 | -``` | |
142 | - | |
143 | -**Result:** | |
144 | -- β
Fast rule-based catches simple errors | |
145 | -- β
Smart AI catches complex issues | |
146 | -- β
Best of both worlds! | |
147 | - | |
148 | - | |
149 | -## π― Grammarly Features We've Cloned | |
150 | - | |
151 | -### β
Spelling & Grammar | |
152 | -- [x] Common misspellings (100+ words) | |
153 | -- [x] Basic grammar rules (35+ rules) | |
154 | -- [x] Irregular verbs (buyed β bought) | |
155 | -- [x] Pronoun errors (me and him β he and I) | |
156 | -- [x] Subject-verb agreement | |
157 | -- [x] Punctuation | |
158 | -- [x] Apostrophes | |
159 | - | |
160 | -### β
Advanced Writing | |
161 | -- [x] Passive voice detection | |
162 | -- [x] Sentence length analysis | |
163 | -- [x] Readability scores (Flesch, ARI) | |
164 | -- [x] Redundant phrases | |
165 | -- [x] Weak words | |
166 | -- [x] ClichΓ©s | |
167 | - | |
168 | -### β
Tone & Style | |
169 | -- [x] 8 tone options (Formal, Casual, Professional, etc.) | |
170 | -- [x] Tone rewriting | |
171 | -- [x] Style suggestions | |
172 | -- [x] Sentence improvement | |
173 | - | |
174 | -### β
Smart Features | |
175 | -- [x] Context understanding | |
176 | -- [x] Vocabulary diversity | |
177 | -- [x] Reading time estimates | |
178 | -- [x] Word/sentence/paragraph counts | |
179 | -- [x] Custom dictionary | |
180 | -- [x] Ignore suggestions | |
181 | - | |
182 | -### β
User Experience | |
183 | -- [x] Real-time checking | |
184 | -- [x] Click-to-apply suggestions | |
185 | -- [x] Interactive tooltips | |
186 | -- [x] Color-coded highlights | |
187 | -- [x] Works everywhere on web | |
188 | - | |
189 | - | |
190 | -## π OpenGrammar Advantages Over Grammarly | |
191 | - | |
192 | -| Feature | Grammarly | OpenGrammar | | |
193 | -|---------|-----------|-------------| | |
194 | -| **Cost** | $12/month for premium | 100% Free | | |
195 | -| **Privacy** | Sends all data to servers | Your data stays local | | |
196 | -| **AI Choice** | Only Grammarly's AI | Choose from 6+ providers | | |
197 | -| **Offline** | Limited | Full offline with Ollama | | |
198 | -| **Customization** | Limited | Fully customizable | | |
199 | -| **Self-Hosting** | No | Yes (Docker, Cloudflare) | | |
200 | -| **Open Source** | No | Yes | | |
201 | -| **API Access** | Paid API | Free self-hosted API | | |
202 | - | |
203 | - | |
204 | -## π¦ What's Included | |
205 | - | |
206 | -### Backend (Serverless API) | |
207 | -``` | |
208 | -β
Rule-based analyzer (140+ rules) | |
209 | -β
AI analyzer (6 providers) | |
210 | -β
Hybrid checking system | |
211 | -β
Tone rewriting API | |
212 | -β
Statistics/metrics API | |
213 | -β
Health monitoring | |
214 | -β
Docker support | |
215 | -``` | |
216 | - | |
217 | -### Extension (Chrome) | |
218 | -``` | |
219 | -β
Real-time grammar checking | |
220 | -β
Interactive tooltips | |
221 | -β
Click-to-apply | |
222 | -β
Multi-provider selection | |
223 | -β
Tone rewriting popup | |
224 | -β
Statistics dashboard | |
225 | -β
Options page | |
226 | -β
Custom dictionary | |
227 | -β
Ignore functionality | |
228 | -``` | |
229 | - | |
230 | -### Documentation | |
231 | -``` | |
232 | -β
README.md - Getting started | |
233 | -β
TESTING_GUIDE.md - How to test | |
234 | -β
GROQ_SETUP.md - Groq API setup | |
235 | -β
SELF_HOSTING.md - Docker deployment | |
236 | -β
PRODUCTION.md - Production guide | |
237 | -β
TROUBLESHOOTING.md - Fix common issues | |
238 | -β
FEATURES_IMPLEMENTATION.md - Feature details | |
239 | -β
GRAMMARLY_CLONE.md - This file! | |
240 | -``` | |
241 | - | |
242 | - | |
243 | -## π― How to Use (Grammarly-Style) | |
244 | - | |
245 | -### 1. Install Extension | |
246 | -``` | |
247 | -1. Build: cd extension && npm run build | |
248 | -2. Load: chrome://extensions/ β Load unpacked β dist/ | |
249 | -3. Click icon β Configure settings | |
250 | -``` | |
251 | - | |
252 | -### 2. Configure (Choose Your Mode) | |
253 | - | |
254 | -**Mode A: Free + Offline (Rule-based only)** | |
255 | -``` | |
256 | -- No API key needed | |
257 | -- Works offline | |
258 | -- Catches basic errors | |
259 | -- Instant results | |
260 | -``` | |
261 | - | |
262 | -**Mode B: Free + Smart (Groq free tier)** | |
263 | -``` | |
264 | -- Get free Groq key: console.groq.com | |
265 | -- 100 requests/day free | |
266 | -- Advanced grammar | |
267 | -- Context understanding | |
268 | -``` | |
269 | - | |
270 | -**Mode C: Private + Smart (Ollama local)** | |
271 | -``` | |
272 | -- Install Ollama | |
273 | -- Pull model: ollama pull qwen2.5:1.5b | |
274 | -- 100% private, offline | |
275 | -- No API costs | |
276 | -``` | |
277 | - | |
278 | -**Mode D: Best Quality (OpenAI/GPT-4)** | |
279 | -``` | |
280 | -- Use your OpenAI key | |
281 | -- Best grammar detection | |
282 | -- Most accurate suggestions | |
283 | -``` | |
284 | - | |
285 | -### 3. Write Like Grammarly | |
286 | -``` | |
287 | -1. Open any text box (Gmail, Docs, etc.) | |
288 | -2. Start typing | |
289 | -3. Red underlines = grammar/spelling errors | |
290 | -4. Yellow underlines = clarity issues | |
291 | -5. Blue underlines = style suggestions | |
292 | -6. Click underline β See suggestion β Apply fix | |
293 | -``` | |
294 | - | |
295 | - | |
296 | -## β
Final Verdict | |
297 | - | |
298 | -**Is OpenGrammar a Grammarly clone?** | |
299 | - | |
300 | -β
**YES!** OpenGrammar uses the exact same hybrid approach: | |
301 | -- Rule-based for fast, basic errors | |
302 | -- AI-powered for smart, contextual suggestions | |
303 | -- Both working together seamlessly | |
304 | - | |
305 | -**Plus these advantages:** | |
306 | -- 100% Free (no premium tier needed) | |
307 | -- Privacy-first (your data stays yours) | |
308 | -- Open source (customize anything) | |
309 | -- Self-hostable (run your own) | |
310 | -- Multiple AI providers (choose what works best) | |
311 | -- Offline capable (with Ollama) | |
312 | - | |
313 | - | |
314 | -## π Conclusion | |
315 | - | |
316 | -**Grammarly = Rule-based + AI** | |
317 | - | |
318 | -**OpenGrammar = Rule-based (140+ rules) + AI (6 providers)** | |
319 | - | |
320 | -**OpenGrammar IS a complete Grammarly clone with more freedom and privacy!** π | |
321 | - | |
322 | - | |
323 | -**Ready to use?** | |
324 | -1. Check `TESTING_GUIDE.md` for testing instructions | |
325 | -2. Check `GROQ_SETUP.md` for free AI setup | |
326 | -3. Check `SELF_HOSTING.md` for deployment | |
327 | - | |
328 | -Happy writing! β¨ | |
329 | 0 | |
βΌopengrammar/GROQ_SETUP.md
+0-186
| @@ -1,196 +0,0 @@ | ||
1 | -# π Quick Start with Groq API | |
2 | - | |
3 | -## Step 1: Get Your Free Groq API Key | |
4 | - | |
5 | -1. Visit: https://console.groq.com | |
6 | -2. Sign up / Log in | |
7 | -3. Go to **API Keys** section | |
8 | -4. Click **Create API Key** | |
9 | -5. Copy your API key (starts with `gsk_`) | |
10 | - | |
11 | -**Free Tier Limits:** | |
12 | -- 100 requests/day | |
13 | -- Fast inference (LPU technology) | |
14 | -- Access to Llama 3.1 70B, Mixtral, Gemma, etc. | |
15 | - | |
16 | - | |
17 | -## Step 2: Configure Backend | |
18 | - | |
19 | -1. **Edit `.env` file:** | |
20 | - ```bash | |
21 | - cd opengrammar/backend | |
22 | - nano .env # or use your favorite editor | |
23 | - ``` | |
24 | - | |
25 | -2. **Add your Groq API key:** | |
26 | - ```env | |
27 | - GROQ_API_KEY=gsk_your_actual_api_key_here | |
28 | - ``` | |
29 | - | |
30 | -3. **Save the file** | |
31 | - | |
32 | - | |
33 | -## Step 3: Test Groq Integration | |
34 | - | |
35 | -### Option A: Test with Test Script | |
36 | - | |
37 | -```bash | |
38 | -cd opengrammar/backend | |
39 | -node test-groq.js | |
40 | -``` | |
41 | - | |
42 | -**Expected Output:** | |
43 | -``` | |
44 | -π§ͺ Testing Groq Grammar Check API... | |
45 | - | |
46 | -Input text: me and him went to the store and buyed some milks | |
47 | - | |
48 | -Sending request to Groq... | |
49 | - | |
50 | -β
Success! Response: | |
51 | -{ | |
52 | - "issues": [ | |
53 | - { | |
54 | - "type": "grammar", | |
55 | - "original": "me and him", | |
56 | - "suggestion": "he and I", | |
57 | - "reason": "Subject pronoun error" | |
58 | - }, | |
59 | - { | |
60 | - "type": "spelling", | |
61 | - "original": "buyed", | |
62 | - "suggestion": "bought", | |
63 | - "reason": "Irregular verb form" | |
64 | - } | |
65 | - ] | |
66 | -} | |
67 | - | |
68 | -β
Found 2 issues: | |
69 | -... | |
70 | -``` | |
71 | - | |
72 | -### Option B: Start Backend Server | |
73 | - | |
74 | -```bash | |
75 | -npm run dev | |
76 | -``` | |
77 | - | |
78 | -Server will start on `http://localhost:8787` | |
79 | - | |
80 | - | |
81 | -## Step 4: Configure Extension | |
82 | - | |
83 | -1. **Click extension icon** in Chrome | |
84 | - | |
85 | -2. **Select Provider:** Groq | |
86 | - | |
87 | -3. **Enter API Key:** (same key from Step 1) | |
88 | - | |
89 | -4. **Select Model:** `llama-3.1-70b-versatile` (recommended) | |
90 | - | |
91 | -5. **Verify Connection:** Green dot should appear | |
92 | - | |
93 | - | |
94 | -## Step 5: Test Grammar Checking | |
95 | - | |
96 | -1. **Open any text box** (Gmail, Google Docs, etc.) | |
97 | - | |
98 | -2. **Type text with errors:** | |
99 | - ``` | |
100 | - me and him went to store and buyed milks | |
101 | - ``` | |
102 | - | |
103 | -3. **Wait 1 second** - Grammar highlights should appear | |
104 | - | |
105 | -4. **Click highlight** to see suggestions | |
106 | - | |
107 | -5. **Click "Apply"** to fix the error | |
108 | - | |
109 | - | |
110 | -## π― Recommended Groq Models | |
111 | - | |
112 | -| Model | Speed | Quality | Best For | | |
113 | -|-------|-------|---------|----------| | |
114 | -| **llama-3.1-70b-versatile** | β‘β‘β‘ | βββββ | General grammar checking | | |
115 | -| **llama-3.1-8b-instant** | β‘β‘β‘β‘ | ββββ | Fast, simple checks | | |
116 | -| **mixtral-8x7b-32768** | β‘β‘ | βββββ | Complex writing | | |
117 | -| **gemma2-9b-it** | β‘β‘β‘ | ββββ | Balanced performance | | |
118 | - | |
119 | - | |
120 | -## π§ Troubleshooting | |
121 | - | |
122 | -### Error: "Invalid API key" | |
123 | -- Check your API key in `.env` file | |
124 | -- Make sure there are no spaces | |
125 | -- Key should start with `gsk_` | |
126 | - | |
127 | -### Error: "Rate limit exceeded" | |
128 | -- Groq free tier: 100 requests/day | |
129 | -- Wait 24 hours or upgrade plan | |
130 | - | |
131 | -### Backend won't start | |
132 | -```bash | |
133 | -# Check if Groq SDK is installed | |
134 | -npm install | |
135 | - | |
136 | -# Check TypeScript | |
137 | -npx tsc --noEmit | |
138 | - | |
139 | -# Restart server | |
140 | -npm run dev | |
141 | -``` | |
142 | - | |
143 | -### No grammar highlights | |
144 | -- Verify backend is running: `curl http://localhost:8787/health` | |
145 | -- Check extension settings β Provider should be "Groq" | |
146 | -- Check browser console for errors (F12) | |
147 | - | |
148 | - | |
149 | -## π API Usage | |
150 | - | |
151 | -### Check Usage Dashboard | |
152 | -Visit: https://console.groq.com/usage | |
153 | - | |
154 | -### Monitor in Real-Time | |
155 | -```bash | |
156 | -# Backend logs | |
157 | -npm run dev | |
158 | - | |
159 | -# Watch for API calls | |
160 | -# Look for: "LLM Analysis Error (groq):" in console | |
161 | -``` | |
162 | - | |
163 | - | |
164 | -## π‘ Tips | |
165 | - | |
166 | -1. **Use `.env` for testing** - Don't commit API keys to git | |
167 | -2. **Start with llama-3.1-70b** - Best balance of speed/quality | |
168 | -3. **Test with test-groq.js first** - Easier to debug | |
169 | -4. **Monitor usage** - Free tier resets daily | |
170 | -5. **Upgrade when ready** - Paid plans available | |
171 | - | |
172 | - | |
173 | -## π You're Ready! | |
174 | - | |
175 | -Your OpenGrammar backend is now powered by **Groq's blazing-fast LPU inference**! | |
176 | - | |
177 | -**Next Steps:** | |
178 | -1. Test with real text in browser | |
179 | -2. Try different Groq models | |
180 | -3. Compare with other providers (OpenAI, Ollama) | |
181 | -4. Deploy to production when ready | |
182 | - | |
183 | - | |
184 | -**Need Help?** | |
185 | -- Groq Docs: https://console.groq.com/docs | |
186 | -- OpenGrammar Docs: `TESTING_GUIDE.md`, `SELF_HOSTING.md` | |
187 | 0 | |
βΌopengrammar/IMPROVEMENTS.md
+0-291
| @@ -1,306 +0,0 @@ | ||
1 | -# Production Improvements Summary | |
2 | - | |
3 | -This document summarizes all improvements made to transform OpenGrammar from MVP to production-ready. | |
4 | - | |
5 | - | |
6 | -## β
Completed Improvements | |
7 | - | |
8 | -### 1. Environment Configuration β | |
9 | - | |
10 | -**Files Modified/Created:** | |
11 | -- `backend/.dev.vars` - Local development environment variables | |
12 | -- `backend/.dev.vars.example` - Template for developers | |
13 | -- `backend/.env.example` - Production environment template | |
14 | -- `backend/wrangler.toml` - Added production environment config | |
15 | - | |
16 | -**Changes:** | |
17 | -- Separated dev/prod environments in Cloudflare Workers | |
18 | -- Added environment variables for configuration | |
19 | -- Configured debug logging (enabled in dev, disabled in prod) | |
20 | - | |
21 | - | |
22 | -### 2. Interactive Tooltips with Click-to-Apply β | |
23 | - | |
24 | -**Files Modified/Created:** | |
25 | -- `extension/src/content/highlighter.ts` - Complete rewrite (555 lines) | |
26 | - | |
27 | -**Features:** | |
28 | -- Beautiful floating tooltips with issue details | |
29 | -- Color-coded by issue type (red=grammar/spelling, amber=clarity, blue=style) | |
30 | -- Three action buttons: Apply, Ignore, Add to Dictionary | |
31 | -- Smooth animations and hover effects | |
32 | -- Click-outside-to-close functionality | |
33 | -- Position-aware rendering (stays within viewport) | |
34 | - | |
35 | - | |
36 | -### 3. Ignore & Dictionary Functionality β | |
37 | - | |
38 | -**Files Modified/Created:** | |
39 | -- `extension/src/content/highlighter.ts` - Ignore/dictionary integration | |
40 | -- `extension/src/background/index.ts` - Storage management | |
41 | -- `extension/src/options/options.tsx` - Management UI | |
42 | - | |
43 | -**Features:** | |
44 | -- Ignore issues with persistent storage | |
45 | -- Custom dictionary for false positives | |
46 | -- Manage ignored issues in options page | |
47 | -- Manage dictionary words in options page | |
48 | -- Filter issues before display | |
49 | - | |
50 | - | |
51 | -### 4. Expanded Local Rule Engine β | |
52 | - | |
53 | -**Files Modified/Created:** | |
54 | -- `backend/src/analyzer.ts` - Complete rewrite (696 lines) | |
55 | - | |
56 | -**New Rules Added (40+ total):** | |
57 | -- Passive voice detection (enhanced) | |
58 | -- Repetition detection | |
59 | -- Long sentences (>35 words) | |
60 | -- Spacing errors (double spaces, space before punctuation) | |
61 | -- Apostrophe errors (it's/its, your/you're, their/they're) | |
62 | -- That/which usage | |
63 | -- Less/fewer confusion | |
64 | -- Comma splices | |
65 | -- Double negatives | |
66 | -- Redundant phrases (50+ phrases) | |
67 | -- Weak words (100+ replacements) | |
68 | -- ClichΓ©s (50+ common clichΓ©s) | |
69 | - | |
70 | - | |
71 | -### 5. ContentEditable Highlighting β | |
72 | - | |
73 | -**Files Modified/Created:** | |
74 | -- `extension/src/content/index.ts` - Complete rewrite | |
75 | -- `extension/src/content/textExtractor.ts` - Enhanced extraction | |
76 | -- `extension/src/content/utils.ts` - Utility functions | |
77 | - | |
78 | -**Features:** | |
79 | -- MutationObserver for contenteditable elements | |
80 | -- Better text extraction for complex editors | |
81 | -- Caret position tracking | |
82 | -- Scroll handling for highlights | |
83 | -- Support for Gmail, Google Docs, Notion, etc. | |
84 | -- Visibility detection | |
85 | - | |
86 | - | |
87 | -### 6. Error Handling & User Notifications β | |
88 | - | |
89 | -**Files Modified/Created:** | |
90 | -- `extension/src/content/index.ts` - Notification system | |
91 | -- `extension/src/background/index.ts` - Error handling | |
92 | -- `backend/src/index.ts` - Error middleware | |
93 | - | |
94 | -**Features:** | |
95 | -- Toast notifications for errors | |
96 | -- Backend health monitoring | |
97 | -- Graceful degradation (AI fails β use rules only) | |
98 | -- User-friendly error messages | |
99 | -- Connection status indicator | |
100 | - | |
101 | - | |
102 | -### 7. Logging & Monitoring β | |
103 | - | |
104 | -**Files Modified/Created:** | |
105 | -- `backend/src/index.ts` - Hono logger integration | |
106 | -- `backend/src/index.ts` - Health endpoint | |
107 | - | |
108 | -**Features:** | |
109 | -- Structured logging with Hono logger | |
110 | -- `/health` endpoint for monitoring | |
111 | -- Request/response timing | |
112 | -- Error logging with stack traces | |
113 | -- Periodic health checks (5 min interval) | |
114 | - | |
115 | - | |
116 | -### 8. Comprehensive Options Page β | |
117 | - | |
118 | -**Files Modified/Created:** | |
119 | -- `extension/src/options/index.html` - New options page | |
120 | -- `extension/src/options/options.css` - Styling | |
121 | -- `extension/src/options/options.tsx` - Logic | |
122 | - | |
123 | -**Features:** | |
124 | -- General settings (enable/disable, notifications) | |
125 | -- API settings (key, model, backend URL) | |
126 | -- Site-specific settings (disable per domain) | |
127 | -- Custom dictionary management | |
128 | -- Ignored issues management | |
129 | -- Data export/import | |
130 | -- Reset to defaults | |
131 | -- Backend health indicator | |
132 | -- About section with links | |
133 | - | |
134 | - | |
135 | -### 9. Build Verification β | |
136 | - | |
137 | -**Files Modified/Created:** | |
138 | -- `extension/vite.config.ts` - Production build config | |
139 | -- `extension/manifest.json` - Updated manifest | |
140 | -- `extension/package.json` - Dependencies | |
141 | -- `backend/package.json` - ES modules | |
142 | -- `backend/src/analyzer.ts` - Type fixes | |
143 | -- `backend/src/index.ts` - Type fixes | |
144 | - | |
145 | -**Build Status:** | |
146 | -- β
Extension builds without errors | |
147 | -- β
Backend type-checks successfully | |
148 | -- β
All TypeScript errors resolved | |
149 | -- β
Production assets generated | |
150 | - | |
151 | - | |
152 | -## π Code Metrics | |
153 | - | |
154 | -| Metric | Before | After | Change | | |
155 | -|--------|--------|-------|--------| | |
156 | -| Extension LOC | ~500 | ~2,500 | +400% | | |
157 | -| Backend LOC | ~100 | ~800 | +700% | | |
158 | -| Grammar Rules | 3 | 40+ | +1,233% | | |
159 | -| Files | 15 | 35 | +133% | | |
160 | -| Build Size | ~50KB | ~175KB | +250% | | |
161 | - | |
162 | - | |
163 | -## π Production Readiness Checklist | |
164 | - | |
165 | -### Code Quality | |
166 | -- [x] TypeScript strict mode | |
167 | -- [x] No type errors | |
168 | -- [x] Proper error handling | |
169 | -- [x] Logging implemented | |
170 | -- [x] Code comments where needed | |
171 | - | |
172 | -### Features | |
173 | -- [x] Interactive tooltips | |
174 | -- [x] Click-to-apply | |
175 | -- [x] Ignore functionality | |
176 | -- [x] Custom dictionary | |
177 | -- [x] Site-specific settings | |
178 | -- [x] 40+ grammar rules | |
179 | -- [x] AI integration | |
180 | -- [x] Real-time checking | |
181 | - | |
182 | -### Infrastructure | |
183 | -- [x] Environment config | |
184 | -- [x] Health monitoring | |
185 | -- [x] Deployment script | |
186 | -- [x] Production documentation | |
187 | -- [x] Build pipeline | |
188 | - | |
189 | -### Security | |
190 | -- [x] API keys stored securely | |
191 | -- [x] No data retention | |
192 | -- [x] CORS configured | |
193 | -- [x] Input validation | |
194 | -- [x] CSP compliance (Manifest V3) | |
195 | - | |
196 | -### UX | |
197 | -- [x] Beautiful UI | |
198 | -- [x] Smooth animations | |
199 | -- [x] Error notifications | |
200 | -- [x] Status indicators | |
201 | -- [x] Responsive design | |
202 | - | |
203 | - | |
204 | -## π¦ Deployment | |
205 | - | |
206 | -### One-Command Deploy | |
207 | - | |
208 | -```bash | |
209 | -./deploy.sh | |
210 | -``` | |
211 | - | |
212 | -This script: | |
213 | -1. Checks Node.js version | |
214 | -2. Installs dependencies | |
215 | -3. Deploys backend to Cloudflare Workers | |
216 | -4. Builds extension | |
217 | -5. Provides next steps | |
218 | - | |
219 | -### Manual Deploy | |
220 | - | |
221 | -```bash | |
222 | -# Backend | |
223 | -cd opengrammar/backend | |
224 | -npm install | |
225 | -npx wrangler deploy --env production | |
226 | - | |
227 | -# Extension | |
228 | -cd opengrammar/extension | |
229 | -npm install | |
230 | -npm run build | |
231 | -# Load dist/ in chrome://extensions/ | |
232 | -``` | |
233 | - | |
234 | - | |
235 | -## π New Files Created | |
236 | - | |
237 | -### Documentation | |
238 | -- `PRODUCTION.md` - Production deployment guide | |
239 | -- `IMPROVEMENTS.md` - This file | |
240 | - | |
241 | -### Configuration | |
242 | -- `backend/.dev.vars` | |
243 | -- `backend/.dev.vars.example` | |
244 | -- `backend/.env.example` | |
245 | - | |
246 | -### Scripts | |
247 | -- `deploy.sh` - Deployment automation | |
248 | -- `extension/public/create_icons.py` - Icon generation | |
249 | - | |
250 | -### Source Code | |
251 | -- `extension/src/options/index.html` | |
252 | -- `extension/src/options/options.css` | |
253 | -- `extension/src/options/options.tsx` | |
254 | - | |
255 | -### Rewritten Files | |
256 | -- `extension/src/content/highlighter.ts` (555 lines) | |
257 | -- `extension/src/content/index.ts` (282 lines) | |
258 | -- `extension/src/content/textExtractor.ts` (142 lines) | |
259 | -- `extension/src/content/utils.ts` (99 lines) | |
260 | -- `extension/src/background/index.ts` (126 lines) | |
261 | -- `extension/src/popup/popup.tsx` (180 lines) | |
262 | -- `extension/src/popup/popup.css` (220 lines) | |
263 | -- `backend/src/analyzer.ts` (696 lines) | |
264 | -- `backend/src/index.ts` (89 lines) | |
265 | -- `backend/src/shared-types.ts` (42 lines) | |
266 | -- `extension/src/types.ts` (36 lines) | |
267 | -- `shared/src/types.ts` (40 lines) | |
268 | - | |
269 | - | |
270 | -## π― Next Steps (Post-Launch) | |
271 | - | |
272 | -### Phase 2 (Enhanced UX) | |
273 | -- [ ] Tone & style adjustments | |
274 | -- [ ] Writing statistics | |
275 | -- [ ] Custom prompts for AI | |
276 | -- [ ] Better Google Docs support | |
277 | - | |
278 | -### Phase 3 (Advanced Features) | |
279 | -- [ ] Autocomplete | |
280 | -- [ ] Contextual understanding | |
281 | -- [ ] Reading time estimates | |
282 | -- [ ] Vocabulary diversity metrics | |
283 | - | |
284 | -### Phase 4 (Expansion) | |
285 | -- [ ] Firefox support | |
286 | -- [ ] Safari support | |
287 | -- [ ] Desktop apps | |
288 | -- [ ] Developer API | |
289 | - | |
290 | - | |
291 | -**OpenGrammar is now production-ready! π** | |
292 | 0 | |
βΌopengrammar/PRODUCTION.md
+0-394
| @@ -1,409 +0,0 @@ | ||
1 | -# πͺΆ OpenGrammar - Production Documentation | |
2 | - | |
3 | -**Your privacy-first, open-source writing assistant.** | |
4 | - | |
5 | -OpenGrammar is a powerful, self-hostable browser extension that helps you write clearly and confidently everywhere on the web. Built with production-grade architecture for reliability, scalability, and security. | |
6 | - | |
7 | - | |
8 | -## π¦ Production Features | |
9 | - | |
10 | -### β
Completed (v1.0.0) | |
11 | - | |
12 | -#### Extension | |
13 | -- **Interactive Tooltips**: Click-to-apply suggestions with beautiful UI | |
14 | -- **Ignore & Dictionary**: Manage ignored issues and custom dictionary words | |
15 | -- **Site-Specific Settings**: Disable on specific domains | |
16 | -- **Smart Notifications**: User-friendly error and status messages | |
17 | -- **Comprehensive Options Page**: Full settings management | |
18 | -- **ContentEditable Support**: Works with Gmail, Google Docs, Notion, etc. | |
19 | -- **Real-time Checking**: Debounced analysis as you type | |
20 | - | |
21 | -#### Backend | |
22 | -- **40+ Grammar Rules**: Passive voice, repetition, spacing, apostrophes, clichΓ©s, redundant phrases, weak words, and more | |
23 | -- **AI Integration**: OpenAI/OpenRouter compatible for advanced checking | |
24 | -- **Health Monitoring**: Built-in `/health` endpoint | |
25 | -- **Request Validation**: Input size limits and type checking | |
26 | -- **Error Handling**: Graceful degradation when AI fails | |
27 | -- **Logging**: Structured logging with Hono logger | |
28 | -- **CORS**: Proper cross-origin configuration | |
29 | - | |
30 | -#### Infrastructure | |
31 | -- **Environment Configuration**: Dev/prod separation | |
32 | -- **TypeScript**: Full type safety across codebase | |
33 | -- **Build Pipeline**: Vite + CRX for extension, Wrangler for backend | |
34 | -- **Cloudflare Workers**: Serverless deployment ready | |
35 | - | |
36 | - | |
37 | -## π Quick Start | |
38 | - | |
39 | -### 1. Deploy Backend (Cloudflare Workers) | |
40 | - | |
41 | -```bash | |
42 | -cd opengrammar/backend | |
43 | - | |
44 | -# Install dependencies | |
45 | -npm install | |
46 | - | |
47 | -# Login to Cloudflare (first time only) | |
48 | -npx wrangler login | |
49 | - | |
50 | -# Deploy to production | |
51 | -npx wrangler deploy --env production | |
52 | - | |
53 | -# Note the deployed URL (e.g., https://opengrammar.yourname.workers.dev) | |
54 | -``` | |
55 | - | |
56 | -### 2. Build Extension | |
57 | - | |
58 | -```bash | |
59 | -cd opengrammar/extension | |
60 | - | |
61 | -# Install dependencies | |
62 | -npm install | |
63 | - | |
64 | -# Update backend URL in src/background/index.ts (or set via options page) | |
65 | -# Replace DEFAULT_BACKEND_URL with your deployed URL | |
66 | - | |
67 | -# Build for production | |
68 | -npm run build | |
69 | - | |
70 | -# The built extension will be in dist/ | |
71 | -``` | |
72 | - | |
73 | -### 3. Load Extension | |
74 | - | |
75 | -1. Open Chrome: `chrome://extensions/` | |
76 | -2. Enable "Developer mode" (top right) | |
77 | -3. Click "Load unpacked" | |
78 | -4. Select `opengrammar/extension/dist` folder | |
79 | -5. Extension icon appears in toolbar | |
80 | - | |
81 | -### 4. Configure | |
82 | - | |
83 | -1. Click extension icon | |
84 | -2. Add your OpenAI/OpenRouter API key (optional, for AI features) | |
85 | -3. Select preferred model | |
86 | -4. Verify backend connection (green status dot) | |
87 | - | |
88 | - | |
89 | -## ποΈ Architecture | |
90 | - | |
91 | -``` | |
92 | -βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
93 | -β Chrome Extension β | |
94 | -β βββββββββββββββ ββββββββββββββββ ββββββββββββββββββββ β | |
95 | -β β Popup β β Options β β Content Script β β | |
96 | -β β (React) β β Page β β (Vanilla TS) β β | |
97 | -β βββββββββββββββ ββββββββββββββββ ββββββββββββββββββββ β | |
98 | -β β β | |
99 | -β βββββββββΌβββββββββ β | |
100 | -β β Background β β | |
101 | -β β Service Workerβ β | |
102 | -β βββββββββ¬βββββββββ β | |
103 | -ββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββ | |
104 | - β HTTP | |
105 | - βΌ | |
106 | -βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
107 | -β Cloudflare Worker (Hono) β | |
108 | -β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β | |
109 | -β β /analyze β Rule Engine + AI (OpenAI/OpenRouter) β β | |
110 | -β β /health β Status endpoint β β | |
111 | -β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β | |
112 | -βββββββββββββββββββββββββββββββ ββββββββββββββββββββββββββββββββ | |
113 | -``` | |
114 | - | |
115 | - | |
116 | -## π Project Structure | |
117 | - | |
118 | -``` | |
119 | -opengrammar/ | |
120 | -βββ backend/ | |
121 | -β βββ src/ | |
122 | -β β βββ index.ts # Hono API server | |
123 | -β β βββ analyzer.ts # Rule-based + LLM analyzers | |
124 | -β β βββ shared-types.ts # TypeScript interfaces | |
125 | -β βββ .dev.vars # Local environment variables | |
126 | -β βββ wrangler.toml # Cloudflare Workers config | |
127 | -β βββ package.json | |
128 | -β | |
129 | -βββ extension/ | |
130 | -β βββ src/ | |
131 | - | |