Getting Started
Prerequisites
margin has two parts: a backend (AI engine) and a frontend (editor interface). You'll need both running.
Backend (Python)
Python 3.10 or newer
bashpython --version # macOS / Linux python --version # Windows (or python3 if using the Windows store alias)If you don't have Python, download it from python.org.
Frontend (Node.js)
Node.js 18 or newer
bashnode --versionDownload from nodejs.org if needed.
AI Provider (pick one)
margin needs an AI model to power its writing assistant. You have two options:
Option A -- Local (Private, Offline) Run a model entirely on your machine. No internet required, no data leaves your computer.
- Ollama -- runs on
http://localhost:11434 - LM Studio -- runs on
http://localhost:1234 - Any OpenAI-compatible local server
Option B -- Cloud API Use an online provider. Your content is sent to their servers for processing.
- OpenAI
- Anthropic
- Google Gemini
- Grok (xAI)
- OpenRouter
- Groq
- Any OpenAI-compatible cloud provider
All cloud providers require an API key. margin stores it securely in your local settings file.
You don't need to edit .env files -- everything is configured inside margin's settings UI.
Installation
Step 1: Clone the repository
git clone https://github.com/prxshetty/margin.git
cd marginStep 2: Set up the backend
margin includes startup scripts that handle everything automatically. Pick the right one for your OS:
./start.shstart.bat # double-click, or run in cmd
powershell -ExecutionPolicy Bypass -File start.ps1The script will:
- Create a Python virtual environment (if one doesn't exist)
- Install Python dependencies
- Install frontend dependencies
- Launch both the API server and the editor UI in parallel
Manual setup (optional)
If you prefer to run things step by step:
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env
uvicorn api.main:app --reload --host 0.0.0.0 --port 8000python -m venv .venv
.venv\Scripts\activate
pip install -r requirements.txt
copy .env.example .env
uvicorn api.main:app --reload --host 0.0.0.0 --port 8000The backend will be available at http://localhost:8000.
Step 3: Set up the frontend
If you used the startup script, this is already done. Otherwise, open a new terminal window and run:
cd ui
npm install
npm run devThe editor will open at http://localhost:5173.
Step 4: Configure your AI provider
- Open margin in your browser.
- Click the gear icon to open Settings.
- Go to Endpoints tab.
- Choose your AI provider:
- Select
.env Defaultif you already configured it in your.envfile. - Or click Add New Endpoint, give it a name (e.g., "Ollama"), enter the URL, and click Save Endpoint.
- Select
- Click Test Connection to verify everything works.
- Select your endpoint as the Active Endpoint.
Step 5: Start writing
The default workspace (sample-workspace) is loaded automatically. It includes sample characters, a chapter, and style presets so you can start experimenting right away.
You can link your own workspace folder from Settings > General > Workspace Directory.
Next Steps
- Learn about workspaces and settings
- Understand AI assist modes and the writing guide
- Create your own character profiles and style guides
