QUICK REFERENCE - nself-org/cli GitHub Wiki

Quick Reference Card

One-page reference for all nself tutorials with common commands and patterns.


Tutorial Quick Links

Tutorial Time Command
SaaS 15 min nself init --template saas
B2B 20 min nself init --template b2b
Marketplace 25 min nself init --template marketplace
Agency 20 min nself init --template agency
Stripe 30 min nself plugin install stripe
Domains 15 min nself whitelabel domain add

Common Commands

Project Setup

# Install nself
curl -sSL https://install.nself.org | bash

# Create project
mkdir myapp && cd myapp
nself init

# Build and start
nself build
nself start

# Check status
nself status
nself urls

Database

# Apply schema
nself db schema apply schema.dbml

# Run migration
nself db migrate up

# Database shell
nself db shell

# Run query
nself db query "SELECT * FROM users"

# Backup
nself db backup

Stripe Integration

# Install plugin
nself plugin install stripe

# Configure in .env
STRIPE_API_KEY=sk_test_PLACEHOLDER
STRIPE_PUBLISHABLE_KEY=pk_test_xxxxx

# Sync data
nself plugin stripe sync

# View customers
nself plugin stripe customers list

# View subscriptions
nself plugin stripe subscriptions list

Custom Domains

# Add domain
nself whitelabel domain add app.myapp.com

# Verify domain
nself whitelabel domain verify app.myapp.com

# Generate SSL
nself ssl generate myapp.com --letsencrypt

# Check SSL
nself ssl check myapp.com

# Enable auto-renewal
nself ssl enable-auto-renew myapp.com

White-Label

# Initialize
nself whitelabel init

# Create brand
nself whitelabel branding create "My Brand"

# Set colors
nself whitelabel branding set-colors \
  --primary #0066cc \
  --secondary #00cc66

# Upload logo
nself whitelabel logo upload ./logo.png --type main

# Customize email
nself whitelabel email edit welcome

GraphQL Patterns

Create Organization

mutation CreateOrganization {
  insert_organizations_one(object: {
    name: "Acme Corp"
    slug: "acme"
    status: "active"
  }) {
    id
    name
  }
}

Create Subscription

mutation CreateSubscription {
  insert_subscriptions_one(object: {
    user_id: "user-id"
    stripe_subscription_id: "sub_xxxxx"
    plan: "pro"
    status: "active"
    price_amount: 2999
  }) {
    id
  }
}

Track Usage

mutation TrackUsage {
  insert_usage_one(object: {
    organization_id: "org-id"
    metric_name: "api_calls"
    quantity: 1000
  }) {
    id
  }
}

Query Dashboard

query Dashboard($userId: uuid!) {
  organizations(where: {members: {user_id: {_eq: $userId}}}) {
    id
    name
    subscription {
      plan
      status
    }
  }
}

Environment Variables

Core Settings

PROJECT_NAME=myapp
ENV=dev
BASE_DOMAIN=local.nself.org

# Database
POSTGRES_DB=myapp_db
POSTGRES_USER=postgres
POSTGRES_PASSWORD=secure-password

# Hasura
HASURA_GRAPHQL_ADMIN_SECRET=admin-secret
HASURA_GRAPHQL_JWT_SECRET=jwt-secret

Stripe

STRIPE_API_KEY=sk_test_PLACEHOLDER
STRIPE_PUBLISHABLE_KEY=pk_test_xxxxx
STRIPE_WEBHOOK_SECRET=whsec_xxxxx

Services

# Enable optional services
REDIS_ENABLED=true
MINIO_ENABLED=true
MONITORING_ENABLED=true
NSELF_ADMIN_ENABLED=true

# Enable email
MAILPIT_ENABLED=true

# Enable search
MEILISEARCH_ENABLED=true

Multi-Tenancy

TENANT_ISOLATION_ENABLED=true
TENANT_COLUMN_NAME=organization_id

DNS Records

Single Domain

Type    Name    Value               TTL
A       @       your-server-ip      300
A       *       your-server-ip      300

Specific Subdomains

Type    Name    Value               TTL
A       api     your-server-ip      300
A       auth    your-server-ip      300
A       admin   your-server-ip      300

Wildcard

Type    Name    Value               TTL
A       *       your-server-ip      300

Domain Verification

Type    Name                Value                   TTL
TXT     _nself-verify      "verification-token"     300

Stripe Test Cards

Successful Payments

4242 4242 4242 4242  # Visa
5555 5555 5555 4444  # Mastercard

Failed Payments

4000 0000 0000 0002  # Declined
4000 0000 0000 9995  # Insufficient funds

Expiry: Any future date (12/34) CVC: Any 3 digits (123)


Docker Commands

# View running containers
docker ps

# View all containers
docker ps -a

# View logs
docker logs <container-name>

# Follow logs
docker logs -f <container-name>

# Restart container
docker restart <container-name>

# Stop all
docker stop $(docker ps -q)

# Clean up
docker system prune -a

Troubleshooting Quick Fixes

Services not starting

nself doctor
nself logs
nself restart

Port conflicts

lsof -i :5432  # Check port
AUTO_FIX=true nself build

Database issues

nself db query "SELECT 1"  # Test connection
nself restart postgres

SSL issues

nself ssl check myapp.com
nself ssl renew myapp.com

Stripe sync issues

nself plugin stripe sync --verbose
nself plugin stripe webhook list

DNS not resolving

dig app.myapp.com A
nslookup app.myapp.com
# Wait for propagation (5 min - 48 hours)

File Locations

project/
โ”œโ”€โ”€ .env                        # Main config
โ”œโ”€โ”€ .env.secrets                # Sensitive data
โ”œโ”€โ”€ schema.dbml                 # Database schema
โ”œโ”€โ”€ docker-compose.yml          # Generated
โ”œโ”€โ”€ nginx/
โ”‚   โ”œโ”€โ”€ nginx.conf
โ”‚   โ””โ”€โ”€ sites/
โ”‚       โ””โ”€โ”€ *.conf
โ”œโ”€โ”€ postgres/
โ”‚   โ”œโ”€โ”€ init/
โ”‚   โ””โ”€โ”€ migrations/
โ”œโ”€โ”€ ssl/
โ”‚   โ”œโ”€โ”€ cert.pem
โ”‚   โ””โ”€โ”€ key.pem
โ”œโ”€โ”€ branding/                   # White-label
โ”‚   โ”œโ”€โ”€ config.json
โ”‚   โ”œโ”€โ”€ logos/
โ”‚   โ””โ”€โ”€ themes/
โ””โ”€โ”€ nself/
    โ”œโ”€โ”€ migrations/
    โ”œโ”€โ”€ seeds/
    โ””โ”€โ”€ backups/

URLs by Environment

Development

https://api.local.nself.org      (GraphQL)
https://auth.local.nself.org     (Auth)
https://admin.local.nself.org    (Admin)

Production

https://api.myapp.com            (GraphQL)
https://auth.myapp.com           (Auth)
https://admin.myapp.com          (Admin)

Time Estimates

Task Time
Install nself 2 min
Create project 3 min
Build & start 2 min (+ 2-5 min first time)
Apply schema 2 min
Configure Stripe 5 min
Add custom domain 10 min (+ DNS propagation)
Deploy to production 5-10 min

Support Resources


Print this page for quick reference while following tutorials!

โš ๏ธ **GitHub.com Fallback** โš ๏ธ