Your translation & grammar assistant
Grammo is a full-stack web application that provides AI-powered translation and grammar correction services. Built with React and Django, it offers an intuitive chat interface for language assistance.
- 🌐 Translation - Get accurate translations between languages
- ✏️ Grammar Correction - Fix grammar, spelling, and punctuation errors
- 🎭 Customizable Modes - Switch between Default and Grammar modes
- 💬 Tone Control - Choose between Default, Formal, or Casual tones
- 💾 Session Management - Maintain conversation context across messages
- 📱 Progressive Web App - Installable PWA with offline support
- 🎨 Modern UI - Clean, responsive interface built with React and TypeScript
- React 19 with TypeScript
- Vite for build tooling
- React Markdown for formatted responses
- Vite PWA Plugin for Progressive Web App support
- Django 5.2.7 with Django REST Framework
- LangChain for AI agent orchestration
- HuggingFace (GPT-OSS-Safeguard-20B) for language model
- LangGraph for conversation management
- Python 3.14+
- Node.js (for pnpm/npm)
- pnpm (or npm/yarn)
- HuggingFace API Token - Get one from HuggingFace
Important: This repository uses Git submodules. Clone with the --recursive flag to automatically initialize submodules:
git clone --recursive <repository-url>
cd grammoIf you already cloned without --recursive, initialize and update submodules:
git submodule update --init --recursiveTo update submodules to their latest commits:
git submodule update --remotecd backend
# Create and activate virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Create a `.env` file from the example template
cp .env.example .env
# Edit .env and fill in your values (see Environment Variables section below)cd ../frontend
# Install dependencies
pnpm install
# Or: npm install / yarn installCreate a .env file in the backend directory. You can copy .env.example as a template:
cp backend/.env.example backend/.envThen edit .env and fill in your values. The following are the required variables:
# Required Settings
SECRET_KEY=your-secret-key-here # Generate: python -c "from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())"
HUGGINGFACEHUB_API_TOKEN=your-huggingface-api-token # Get from https://huggingface.co/settings/tokens
# Development Settings (defaults shown)
DEBUG=True
SESSION_COOKIE_SECURE=False # Set to True in production (requires HTTPS)
CSRF_COOKIE_SECURE=False # Set to True in production (requires HTTPS)
CORS_ALLOW_ALL_ORIGINS=True # Set to False in production
CSRF_TRUSTED_ORIGINS=http://localhost:5173,http://localhost:3000
# Optional: Production Security Settings
# ALLOWED_HOSTS=yourdomain.com,www.yourdomain.com
# SECURE_SSL_REDIRECT=True
# SECURE_CONTENT_TYPE_NOSNIFF=True
# SECURE_HSTS_SECONDS=31536000
# SECURE_HSTS_INCLUDE_SUBDOMAINS=True
# SECURE_HSTS_PRELOAD=TrueFor detailed documentation on all environment variables, see backend/.env.example
For the frontend, create a .env file in the frontend directory:
VITE_API_PROXY=http://localhost:8000Development (with warning):
cd backend
source venv/bin/activate # If not already activated
python manage.py runserverDevelopment (production-like server - no warning):
cd backend
source venv/bin/activate # If not already activated
uvicorn backend.asgi:application --host 0.0.0.0 --port 8000 --reloadThe backend will run on http://localhost:8000
cd frontend
pnpm dev
# Or: npm run dev / yarn devThe frontend will run on http://localhost:5173 (or another port if 5173 is taken)
Frontend:
cd frontend
pnpm build
# Or: npm run build / yarn buildThe production build will be in the frontend/dist directory.
Backend:
cd backend
# Set DEBUG=False and SESSION_COOKIE_SECURE=True in .env
python manage.py collectstatic # If using static files
# Run with production ASGI server:
uvicorn backend.asgi:application --host 0.0.0.0 --port 8000
# Or for production with multiple workers:
uvicorn backend.asgi:application --host 0.0.0.0 --port 8000 --workers 4Health check endpoint that returns a greeting message.
Response:
{
"message": "Hello from Grammo!"
}Send a message to start or continue a chat session.
Request Body:
{
"message": "Translate this text",
"chatSession": 0,
"mode": "default",
"tone": "default"
}Response:
{
"status": "success",
"response": "Markdown formatted response..."
}End the current chat session and clear conversation history.
Request Body:
{}Response:
{
"status": "success",
"message": "Session ended successfully"
}This repository uses Git submodules for the backend component. The backend directory is a separate repository that tracks its own version history.
Initial Setup:
- Always clone with
--recursiveto get submodules automatically - Or run
git submodule update --init --recursiveafter cloning
Updating Submodules:
- Update all submodules to their latest commits:
git submodule update --remote - Update submodules to the commit specified in the parent repo:
git submodule update
Switching Branches:
- After switching branches that change submodule commits, run:
git submodule update --init --recursive
Making Changes to Submodules:
- Navigate into the submodule directory (e.g.,
cd backend) - Make your changes and commit them in the submodule repository
- Go back to the parent repository and commit the submodule reference update
For more information, see Git Submodules Documentation.
grammo/
├── backend/ # Git submodule - Django backend API
│ ├── agent_manager/ # AI agent management and LangChain integration
│ ├── api/ # Django REST API views and URLs
│ ├── backend/ # Django project settings
│ ├── manage.py
│ ├── requirements.txt
│ └── README.md # See backend/README.md for backend-specific docs
├── frontend/
│ ├── src/
│ │ ├── components/ # React components (Chat, Dropdown)
│ │ ├── hooks/ # Custom React hooks
│ │ ├── utils/ # Utility functions
│ │ └── App.tsx # Main application component
│ ├── public/ # Static assets and PWA files
│ └── package.json
├── .gitmodules # Git submodule configuration
└── README.md # This file
- The Django app uses SQLite by default (good for development)
- Session management is handled via Django's cache backend (in-memory)
- AI agents are managed per session using LangGraph checkpoints
- The structured output model ensures consistent JSON responses
- Uses Vite for fast HMR (Hot Module Replacement)
- TypeScript for type safety
- React Markdown for rendering formatted AI responses
- LocalStorage for persisting user preferences (mode, tone)
The backend includes a Dockerfile for easy deployment to Hugging Face Spaces.
-
Create a new Space on Hugging Face:
- Go to https://huggingface.co/spaces
- Create a new Space
- Select "Docker" as the SDK
-
Configure Environment Variables in your Space settings:
SECRET_KEY: Your Django secret key (generate with:python -c "from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())")HUGGINGFACEHUB_API_TOKEN: Your Hugging Face API tokenDEBUG: Set toFalsefor productionALLOWED_HOSTS: Your Space domain (e.g.,your-space-name.hf.space)CORS_ALLOW_ALL_ORIGINS: Set toFalsefor productionCSRF_TRUSTED_ORIGINS: Include your Space URL (e.g.,https://your-space-name.hf.space)SESSION_COOKIE_SECURE: Set toTrue(Spaces use HTTPS)CSRF_COOKIE_SECURE: Set toTrue
-
Push your code to the Space repository:
git clone https://huggingface.co/spaces/your-username/your-space-name cd your-space-name # Copy the backend directory contents # Commit and push
-
The Dockerfile will automatically:
- Install all dependencies
- Run database migrations
- Start the server on port 7860
The API will be available at https://your-space-name.hf.space/api/v1/
- The application uses in-memory session storage for development. For production, consider using Redis for session and cache management.
- The HuggingFace model (
openai/gpt-oss-safeguard-20b) is used for language processing. - CORS is configured to allow cross-origin requests. Configure properly for production.
- The PWA features allow the app to be installed on mobile devices and work offline (with cached assets).
See the LICENSE file for details.