NativeX is an AI-powered code generation and orchestration platform. It allows users to prompt for full-stack applications, generates the code using LLMs, and instantaneously spins up live, isolated development environments running in Docker containers.
NativeX operates as a monorepo using TurboRepo and Bun. It employs a "Docker-Sibling" architecture to manage dynamic development environments.
- Frontend: Next.js 15 (App Router), TailwindCSS, Clerk Auth
- Primary Backend: Express/Node.js (TypeScript) handling API requests and orchestration
- Worker/Builder: Background services that process AI generation tasks
- Infrastructure: Docker Compose, Traefik (Reverse Proxy), Postgres, Redis
- User sends a prompt via the Frontend
- Backend creates a DB entry and pushes a job to Redis
- Worker picks up the job, uses LLMs to generate code, and writes files to the Host Filesystem
- Backend interacts with the Docker Socket (
/var/run/docker.sock) to spin up a new "Editor" container on the host - Traefik dynamically routes
https://{project-id}.nativex.yourdomain.comto that specific container
- Package Manager: Bun (v1.x)
- Monorepo: TurboRepo
- Frontend: Next.js 15, Shadcn/UI, Lucide React
- Database: PostgreSQL (via Prisma ORM)
- Queue: Redis
- Containerization: Docker & Docker Compose
- Reverse Proxy: Traefik v3
- Bun installed locally
- Docker & Docker Compose running
- PostgreSQL (Local or Containerized)
- Redis (Local or Containerized)
git clone https://github.com/yourusername/nativex.git
cd nativex
# Install dependencies from root (using Bun Workspaces)
bun installCreate a .env file in apps/primary-backend and apps/frontend.
PORT=3002
# IMPORTANT: Use port 5432 if running inside Docker network, 5434/5432 if local
DATABASE_URL="postgresql://postgres:password@localhost:5432/postgres"
REDIS_URL="redis://localhost:6379"
# Directory on the HOST machine where projects are stored
HOST_ROOT="/home/user/projects"
# Google Gemini / OpenAI Key
GEMINI_API_KEY="AIzaSy..."
# JWT Configuration (PEM Format)
# β οΈ CRITICAL: Ensure newlines are preserved if pasting into Docker envs
# Use actual line breaks in .env files, NOT \n escape sequences
JWT_PUBLIC_KEY="-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCA...
-----END PUBLIC KEY-----"
# Clerk Keys (Frontend)
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY="pk_test_..."
CLERK_SECRET_KEY="sk_test_..."NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY="pk_test_..."
CLERK_SECRET_KEY="sk_test_..."
NEXT_PUBLIC_API_URL="http://localhost:3002"Push the Prisma schema to your database:
# Run from root or packages/db
bunx prisma db push
bunx prisma generate# Starts Frontend, Backend, and Worker via Turbo
bun run devThe services will be available at:
- Frontend: http://localhost:3000
- Backend: http://localhost:3002
NativeX relies heavily on Docker networking and the Docker-Sibling pattern.
Ensure the HOST_ROOT directory exists on your server so the backend can write project files to it:
mkdir -p /home/user/projects
chmod -R 777 /home/user/projectsRun the entire stack (Traefik, Postgres, Redis, Backend) using the compose file:
docker compose -f docker-compose.nativex.yml up -d --build- Frontend: https://nativex.yourdomain.com
- Backend: https://backend.nativex.yourdomain.com
- Traefik Dashboard: http://localhost:8080 (if enabled)
Internal vs External Ports:
- When services talk inside Docker (e.g., Backend β Redis), use the Service Name and Internal Port:
- β
redis:6379 - β
postgres:5432
- β
- Do NOT use
localhostor external mapped ports (like6381or5434) insidedocker-composeservice definitions
Example:
# β WRONG - will fail inside Docker
DATABASE_URL="postgresql://postgres:password@localhost:5434/postgres"
# β
CORRECT - uses internal Docker network
DATABASE_URL="postgresql://postgres:password@postgres:5432/postgres"The backend must have access to the host's Docker daemon to spawn new environments. Ensure your docker run or compose file includes:
volumes:
- /var/run/docker.sock:/var/run/docker.sockSecurity Note: This grants the container significant privileges. Only use in trusted environments.
If the Worker crashes with "Permission Denied" when creating folders:
- Ensure
HOST_ROOTin your.envmatches the mounted volume indocker-compose - Ensure the directory on the host allows writing:
chmod -R 777 /home/user/projects # Quick fix for dev - For production, use proper user/group permissions instead of 777
If you see PrismaClientInitializationError:
- Ensure you ran
bunx prisma generateafter installing dependencies - If running in Docker, ensure the
DATABASE_URLusespostgres:5432(the container name), notlocalhost
Problem: PEM keys contain newlines that must be preserved exactly.
Common Mistakes:
- β Using
\nliteral strings instead of actual newlines - β Stripping newlines when copying keys
- β Adding quotes incorrectly in
.envfiles
Solutions:
For .env files (local development):
# Use actual line breaks (multiline string)
JWT_PUBLIC_KEY="-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCA...
-----END PUBLIC KEY-----"For Docker environment variables:
environment:
JWT_PUBLIC_KEY: |
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCA...
-----END PUBLIC KEY-----For inline Docker commands:
docker run -e JWT_PUBLIC_KEY="$(cat public_key.pem)" ...Symptom: Error: connect ECONNREFUSED 127.0.0.1:6379
Cause: Backend trying to connect to localhost:6379 from inside Docker.
Solution: Update REDIS_URL to use the service name:
# β WRONG (inside Docker)
REDIS_URL="redis://localhost:6379"
# β
CORRECT (inside Docker)
REDIS_URL="redis://redis:6379"If dynamic project URLs aren't working:
- Verify Traefik is running:
docker ps | grep traefik - Check Traefik dashboard at http://localhost:8080
- Ensure containers have proper labels:
labels: - "traefik.enable=true" - "traefik.http.routers.myapp.rule=Host(`myapp.nativex.yourdomain.com`)"
- Verify DNS points
*.nativex.yourdomain.comto your server
nativex/
βββ apps/
β βββ frontend/ # Next.js 15 frontend
β βββ primary-backend/ # Express API server
β βββ worker/ # Background job processor
βββ packages/
β βββ db/ # Prisma schema & client
β βββ shared/ # Shared types & utilities
βββ docker-compose.nativex.yml
βββ turbo.json
βββ README.md
# Frontend only
cd apps/frontend && bun run dev
# Backend only
cd apps/primary-backend && bun run dev
# Worker only
cd apps/worker && bun run dev# Create a new migration
bunx prisma migrate dev --name add_new_feature
# Apply migrations in production
bunx prisma migrate deploy# All services
docker compose -f docker-compose.nativex.yml logs -f
# Specific service
docker compose -f docker-compose.nativex.yml logs -f primary-backend- Fork the repo
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
MIT
If you encounter issues not covered in this README:
- Review Docker logs:
docker compose logs -f - Open an issue on GitHub with:
- Error messages
- Relevant logs
- Your environment (OS, Docker version, etc.)