This guide covers running GritCMS on your local machine for development. The local setup uses SQLite for zero-configuration database access and includes hot reload for rapid iteration.
Prerequisites
Before starting, make sure you have the following installed:
- Go 1.24+ -- for the API backend
- Node.js 20+ -- for the frontend apps
- pnpm -- the package manager used by the monorepo (
npm install -g pnpm) - Git -- for cloning the repository
- Docker (optional) -- for running PostgreSQL, Redis, and MinIO via
docker-compose.yml
Project Structure
GritCMS is a pnpm monorepo with three main services:
| Service | Directory | Default Port | Description |
|---|---|---|---|
| API | apps/api | 8080 | Go backend (Gin + GORM) |
| Admin | apps/admin | 3000 | Next.js admin dashboard |
| Web | apps/web | 3001 | Next.js public-facing site |
| Shared | packages/shared | -- | Shared types, sections, and templates |
Installation
Clone the repository and install dependencies:
git clone https://github.com/your-org/gritcms.git
cd gritcms
pnpm installThis installs dependencies for all packages and apps in the monorepo.
Option A: SQLite (Simplest)
The API uses SQLite by default when no DATABASE_URL is set. This is the fastest way to get started -- no database server needed.
Running the Services
Open three terminal windows (or use a process manager):
Terminal 1 -- API:
cd apps/api
go run cmd/server/main.goThe API starts on http://localhost:8080 and stores data in a local grit.db file.
Terminal 2 -- Admin:
pnpm --filter admin devThe admin dashboard starts on http://localhost:3000.
Terminal 3 -- Web:
pnpm --filter web devThe public site starts on http://localhost:3001.
Option B: Docker Compose (Full Stack)
For a setup closer to production with PostgreSQL, Redis, and MinIO:
docker compose up -dThis starts PostgreSQL (port 5432), Redis (port 6379), MinIO (port 9000/9001), and MailHog (port 8025) using the docker-compose.yml in the project root.
Then create a .env file in apps/api/:
DATABASE_URL=postgres://grit:grit@localhost:5432/gritcms?sslmode=disable
REDIS_URL=redis://localhost:6379
MINIO_ENDPOINT=http://localhost:9000
MINIO_ACCESS_KEY=minioadmin
MINIO_SECRET_KEY=minioadmin
MINIO_BUCKET=uploads
STORAGE_DRIVER=minioStart the services the same way as Option A (three terminals).
Hot Reload
Frontend Hot Reload
Both Next.js apps (admin and web) run in development mode with Fast Refresh enabled. When you edit a React component, the change appears in the browser instantly without a full page reload.
Backend Restart
The Go backend does not hot-reload by default. After making changes to Go files, stop the server (Ctrl+C) and run go run cmd/server/main.go again.
For automatic restarts, use air:
go install github.com/cosmtrek/air@latest
cd apps/api
airAir watches for file changes and automatically rebuilds and restarts the Go server.
Initial Setup
After starting all services for the first time:
- Visit
http://localhost:3000(admin dashboard) - Register your admin account (first user becomes admin)
- Complete the Setup Wizard -- it saves your site settings and creates a default Home page
- Visit
http://localhost:3001to see the public site
Alternatively, seed defaults manually:
curl -X POST http://localhost:8080/api/seed-defaultsEnvironment Variables
For local development, the defaults work without configuration. Optional variables:
| Variable | Default | Description |
|---|---|---|
PORT | 8080 | API server port |
DATABASE_URL | (SQLite) | PostgreSQL connection string |
REDIS_URL | (none) | Redis connection string |
JWT_SECRET | (generated) | Secret for JWT token signing |
CORS_ORIGINS | * | Allowed origins for CORS |
STORAGE_DRIVER | local | File storage: local, minio, or r2 |
MINIO_ENDPOINT | -- | MinIO server URL |
MINIO_ACCESS_KEY | -- | MinIO access key |
MINIO_SECRET_KEY | -- | MinIO secret key |
RESEND_API_KEY | -- | Resend email API key |
MAIL_FROM | -- | Sender email address |
Next Steps
Once you are comfortable with local development, see the Docker guide for containerized deployments or the Dokploy guide for deploying to a VPS.