Local Development
Set up a complete SimpleNS development environment using VS Code Dev Containers. This guide covers the pre-configured devcontainer setup for streamlined local development.
Overview
SimpleNS includes a pre-configured Dev Container setup that provides a complete development environment with all required tools, extensions, and infrastructure services. This allows you to start contributing or customizing SimpleNS without manual environment setup.
Dev Containers work with VS Code and GitHub Codespaces. The configuration automatically sets up Node.js, Docker-in-Docker, and all required VS Code extensions.
Prerequisites
Before you begin, ensure you have the following installed:
- Docker Desktop (Windows/Mac) or Docker Engine (Linux)
- VS Code with the Dev Containers extension
- Git for cloning the repository
Alternatively, you can use GitHub Codespaces which requires no local setup—just a GitHub account.
Getting Started
Clone the Repository
git clone https://github.com/SimpleNotificationSystem/simplens-core.git
cd simplens-coreOpen in Dev Container
- Open the cloned folder in VS Code
- When prompted, click "Reopen in Container"
Or manually:
- Press
Ctrl+Shift+P(Windows/Linux) orCmd+Shift+P(Mac) - Type "Dev Containers: Reopen in Container"
- Press Enter
The first build may take a few minutes while Docker pulls the base image and installs dependencies.
- Navigate to the repository on GitHub
- Click the green "Code" button
- Select "Codespaces" tab
- Click "Create codespace on main"
GitHub Codespaces provides a cloud-hosted development environment with the same configuration.
Wait for Setup
The Dev Container automatically runs post-creation commands:
# Automatically executed on container creation:
npm install && cd dashboard && npm installOnce complete, infrastructure services start automatically:
# Automatically executed on container start:
docker compose -f docker-compose.infra.yaml up -dVerify Environment
After the container is ready, verify the setup:
# Check Node.js
node --version # Should show Node.js 18+
# Check Docker-in-Docker
docker ps # Should list running infrastructure containers
# Verify infrastructure services
docker compose -f docker-compose.infra.yaml psDev Container Configuration
The .devcontainer/devcontainer.json configures the development environment:
Base Image
{
"name": "SimpleNS Devcontainer",
"image": "mcr.microsoft.com/devcontainers/typescript-node"
}Uses Microsoft's TypeScript/Node.js development container image which includes:
- Node.js LTS
- TypeScript
- Common development utilities
Docker-in-Docker
{
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {
"moby": false
}
}
}Why Docker-in-Docker?
This allows you to run Docker commands inside the container to manage infrastructure services (MongoDB, Kafka, Redis) and test Docker-based deployments.
VS Code Extensions
The following extensions are automatically installed:
Prettier
Code formatting - esbenp.prettier-vscode
ESLint
Linting - dbaeumer.vscode-eslint
Tailwind CSS
IntelliSense - bradlc.vscode-tailwindcss
Docker
Container management - ms-azuretools.vscode-docker
Vitest
Test explorer - vitest.explorer
MongoDB
Database tools - mongodb.mongodb-vscode
Environment Variables
{
"remoteEnv": {
"NODE_ENV": "development",
"INFRA_HOST": "localhost"
}
}| Variable | Value | Description |
|---|---|---|
NODE_ENV | development | Enables development mode features |
INFRA_HOST | localhost | Infrastructure services hostname |
Infrastructure Services
The Dev Container automatically starts infrastructure services via docker-compose.infra.yaml:
MongoDB
Document database with replica set - Port 27017
Apache Kafka
Message broker (KRaft mode) - Port 9092
Kafka UI
Topic monitoring interface - Port 8080
Redis
In-memory cache & queues - Port 6379
Loki
Log aggregation - Port 3100
Grafana
Log visualization - Port 3001
Managing Infrastructure
# View running services
docker compose -f docker-compose.infra.yaml ps
# View logs
docker compose -f docker-compose.infra.yaml logs -f
# Stop services
docker compose -f docker-compose.infra.yaml down
# Restart services
docker compose -f docker-compose.infra.yaml restartRunning the Application
Once the Dev Container is ready, start the application services:
Configure Environment
# Copy example environment file
cp .env.example .env
# Edit the .env file with your settingsMake sure to update the required environment variables like NS_API_KEY and ADMIN_PASSWORD.
Generate Plugin Configuration
# Generate config for mock plugin (for testing)
npx @simplens/config-gen generate @simplens/mockStart Application Services
Start in development mode with hot reload. Each service runs in a separate terminal:
# Terminal 1: API Server
npm run dev
# Terminal 2: Background Worker (status updates processing)
npm run worker:dev
# Terminal 3: Notification Processor (plugin-based delivery)
npm run processor:dev
# Terminal 4: Delayed Processor (scheduled notifications)
npm run delayed-processor:dev
# Terminal 5: Recovery Service (stuck notification detection)
npm run recovery:dev# Terminal 6: Dashboard (in dashboard directory)
cd dashboard && npm run devUse VS Code's split terminal feature or terminal tabs to manage multiple processes.
Start all services with Docker Compose:
docker compose -f docker-compose.dev.yaml up -dVerify Services
- API Server: http://localhost:3000/health
- Dashboard: http://localhost:3002
- Kafka UI: http://localhost:8080
- Grafana: http://localhost:3001
Running Tests
The Dev Container includes the Vitest extension for running tests:
# Run all tests
npm test
# Run tests in watch mode
npm run test:watch
# Run tests with coverage
npm run test:coverageUse the Vitest Explorer extension in VS Code sidebar for an interactive test runner.
Troubleshooting
Container fails to start
Check Docker Desktop is running:
- Ensure Docker Desktop (or Docker Engine) is running before opening VS Code
Rebuild the container:
- Press
Ctrl+Shift+P→ "Dev Containers: Rebuild Container" - Wait for the rebuild to complete
Infrastructure services not running
Manually start services:
docker compose -f docker-compose.infra.yaml up -dCheck Docker-in-Docker:
docker ps
# Should show infrastructure containersMongoDB connection issues
Wait for replica set initialization: MongoDB replica set initialization can take up to 30 seconds. Check the health status:
docker compose -f docker-compose.infra.yaml ps mongo
# Should show 'healthy' statusExtension not working
Reload VS Code:
- Press
Ctrl+Shift+P→ "Developer: Reload Window" - Wait for extensions to activate
For more issues, see the Troubleshooting Guide.
Docs