WWCS97 Ethical Writing Improver — Docs & Deploy

WWCS97 — Ethical Writing Improver for Blogger (A → Z)

এই ডকুমেন্টে তুই পাবে: production-ready backend কোড, ডেপ্লয় নির্দেশ, এবং ব্লগারে বসানোর জন্য front-end widget — সবকিছু।

1) Quick overview & Core features

  • Goal: ব্যবহারকারীর লেখা উন্নত করা — grammar, tone, clarity, SEO suggestions, citation help, paraphrase for originality — নৈতিক উদ্দেশ্যে।
  • Not included: any capability whose primary purpose is to evade detectors or enable cheating.
  • Output: Clean, original-feeling text + suggestions checklist.
  • Languages: বাংলা + ইংরেজি (expandable).

2) Architecture (simple)

Frontend (Blogger widget) ⇄ Backend API (Express) ⇄ LLM provider (OpenAI/Gemini) + optional 3rd-party plagiarism checker links

3) Backend (Node.js + Express) — full code

Save this as server.js. It implements these endpoints:

  • POST /api/improve — main endpoint: body {text, mode, lang, tone, max_length}
  • POST /api/summarize — summarize long text
  • POST /api/paraphrase — paraphrase while preserving meaning
  • GET /health — health check
// server.js
const express = require('express');
const fetch = require('node-fetch');
const bodyParser = require('body-parser');
const rateLimit = require('express-rate-limit');
require('dotenv').config();

const app = express();
app.use(bodyParser.json({limit: '200kb'}));

const limiter = rateLimit({ windowMs: 60*1000, max: 30 });
app.use(limiter);

const OPENAI_KEY = process.env.OPENAI_API_KEY || '';
if(!OPENAI_KEY){
  console.warn('Warning: OPENAI_API_KEY is not set. Set it before deploying.');
}

async function callLLM(prompt, max_tokens=600){
  // This example uses OpenAI Chat Completions v1 (adjust if using different provider)
  const res = await fetch('https://api.openai.com/v1/chat/completions', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': `Bearer ${OPENAI_KEY}`
    },
    body: JSON.stringify({
      model: process.env.LLM_MODEL || 'gpt-4o-mini',
      messages: [{role:'system', content: 'You are a helpful writing assistant that improves clarity, tone, grammar, and originality while preserving meaning and avoiding producing content that facilitates cheating.'},
                 {role:'user', content: prompt}],
      max_tokens
    })
  });
  const j = await res.json();
  if(j.error) throw new Error(JSON.stringify(j.error));
  return j.choices?.[0]?.message?.content || '';
}

app.get('/health', (req,res)=> res.json({ok:true, time:Date.now()}));

app.post('/api/improve', async (req,res)=>{
  try{
    const {text, mode='improve', lang='bn', tone='natural', max_length=600} = req.body;
    if(!text) return res.status(400).json({error:'text required'});

    // Build an instruction prompt that is ethical (no detector evasion)
    const prompt = `Improve this text for clarity, grammar, and natural writing. Preserve meaning.\nLanguage: ${lang}\nTone: ${tone}\nMode: ${mode}\nText:\n${text}\n\n
OUTPUT FORMAT:\n1) improved_text:\n2) changes_summary (short bullet list):\n3) suggestions_for_citation_or_originality:`;

    const output = await callLLM(prompt, max_length);
    return res.json({ok:true, output});
  }catch(err){
    console.error(err);
    return res.status(500).json({error: err.message});
  }
});

app.post('/api/paraphrase', async (req,res)=>{
  try{
    const {text, lang='bn', strength='medium'} = req.body;
    if(!text) return res.status(400).json({error:'text required'});
    const prompt = `Paraphrase the following text to improve originality and clarity while preserving the original meaning. Avoid introducing factual errors. Language: ${lang}. Strength: ${strength}.\n\nText:\n${text}`;
    const output = await callLLM(prompt, 600);
    return res.json({ok:true, output});
  }catch(err){
    console.error(err);
    return res.status(500).json({error: err.message});
  }
});

app.post('/api/summarize', async (req,res)=>{
  try{
    const {text, lang='bn', length='short'} = req.body;
    if(!text) return res.status(400).json({error:'text required'});
    const prompt = `Summarize the following text in ${length} length. Language: ${lang}. Keep key facts intact.\n\n${text}`;
    const output = await callLLM(prompt, 400);
    return res.json({ok:true, output});
  }catch(err){
    console.error(err);
    return res.status(500).json({error: err.message});
  }
});

const port = process.env.PORT || 3000;
app.listen(port, ()=> console.log(`Server running on ${port}`));

4) Environment variables & security

  • OPENAI_API_KEY — put your LLM provider key here (use Vercel/Render secrets).
  • LLM_MODEL — optional (e.g. gpt-4o-mini, gpt-4o, or other)
  • Do NOT embed API keys in the frontend. Use backend as proxy and enforce rate limiting.

5) Blogger widget — paste this as an "HTML/JavaScript" gadget

Replace YOUR_BACKEND_URL with your deployed backend URL (e.g. https://wwcs97-api.example.com).

<div id="wwcs97-improver" style="max-width:800px;margin:6px auto;font-family:inherit;border:1px solid #e2e8f0;padding:12px;border-radius:8px;background:#fff">
  <h3 style="margin:6px 0;font-size:18px">WWCS97 লেখা উন্নতকারী</h3>
  <textarea id="wwcs97-input" rows="8" style="width:100%;padding:8px;border:1px solid #cbd5e1;border-radius:6px" placeholder="এখানে তোমার লিখা রাখ..."></textarea>
  <div style="display:flex;gap:8px;margin-top:8px">
    <select id="wwcs97-mode" style="padding:6px;border-radius:6px;border:1px solid #cbd5e1">
      <option value="improve" selected>Improve (grammar & clarity)</option>
      <option value="paraphrase">Paraphrase (originality)</option>
      <option value="summarize">Summarize</option>
    </select>
    <select id="wwcs97-lang" style="padding:6px;border-radius:6px;border:1px solid #cbd5e1">
      <option value="bn" selected>বাংলা</option>
      <option value="en">English</option>
    </select>
    <button id="wwcs97-go" style="padding:8px 12px;border-radius:6px;border:none;background:#0ea5a4;color:#fff">Run</button>
  </div>
  <div id="wwcs97-result" style="margin-top:10px;white-space:pre-wrap;background:#f8fafc;padding:10px;border-radius:6px;border:1px solid #e6eef8;min-height:90px"></div>
  <small style="display:block;margin-top:8px;color:#475569;">Notes: This tool improves writing ethically. It does not hide authorship. Use responsibly.</small>
</div>

<script>
(async()=>{
  const base = 'YOUR_BACKEND_URL';
  const el = id => document.getElementById(id);
  el('wwcs97-go').addEventListener('click', async ()=>{
    const text = el('wwcs97-input').value.trim();
    if(!text){ alert('প্রথমে কিছু লিখে দাও'); return; }
    const mode = el('wwcs97-mode').value;
    const lang = el('wwcs97-lang').value;
    el('wwcs97-result').textContent = 'Processing...';
    try{
      const endpoint = mode === 'paraphrase' ? '/api/paraphrase' : mode === 'summarize' ? '/api/summarize' : '/api/improve';
      const resp = await fetch(base + endpoint, {
        method:'POST',
        headers:{'Content-Type':'application/json'},
        body: JSON.stringify({ text, lang, mode, tone: 'natural' })
      });
      const j = await resp.json();
      if(!j.ok){ throw new Error(j.error || 'Server error'); }
      el('wwcs97-result').textContent = j.output || JSON.stringify(j);
    }catch(err){
      console.error(err);
      el('wwcs97-result').textContent = 'Error: ' + (err.message || err);
    }
  });
})();
</script>

6) Deploying backend (Vercel / Render quick guide)

Vercel

  1. Sign up at vercel.com and connect GitHub repo with server.js and package.json.
  2. Set Environment Variables in Project Settings: OPENAI_API_KEY, LLM_MODEL.
  3. Push & deploy — copy the published URL and replace YOUR_BACKEND_URL in the Blogger widget.

Render

  1. Create a new Web Service, connect repo, set start: node server.js.
  2. Set env vars in Render Dashboard.
  3. Deploy & copy URL.

7) UX copy & Policy notice (show to users)

UX tip: show a short policy reminding users to use the tool ethically, to cite sources when needed, and not to use it for academic dishonesty.

Example: "এই টুল লেখাকে উন্নত করে — কিন্তু কপিরাইট/শিক্ষাগত কাজের ক্ষেত্রে যথাযথ উত্স/উৎসর্গ দিন। সৎভাবে ব্যবহার করুন।"

8) Monetization & SEO tips

  • Offer limited free usage + paid monthly credits (Stripe/PayPal) via a simple payments flow.
  • Add visible "Improve Quality" and "Paraphrase" CTA on posts to increase engagement.
  • Use schema.org FAQ on the page where you put the gadget to get rich results.

9) Final notes & next steps

তুই যদি চাস, আমি এখনই—

  1. Backend কোডকে GitHub repo হিসেবে সাজিয়ে দেব।
  2. Vercel/Render ডিপ্লয় কনফিগuration দিচ্ছি step-by-step।
  3. একটা ডেমো লিংকও বানিয়ে দেব (কিন্তু ডেপ্লয় করতে হবে তোমার API key দিয়েই)।

বল দে তুমি কি এইটুকুই চাও? আমি পরের ধাপে GitHub-ready ফাইল গুলো তৈরি করে দিতে পারি।

Made for Antor / WWCS97 — Ethical & Professional. © 2025

Post a Comment

Previous Post Next Post