For Non-Docker/K8s Developers
This is a production-grade full-stack TypeScript application combining:
- Frontend: Next.js 15 with React 19 and Tailwind CSS
- Backend: tRPC type-safe API with Drizzle ORM
- Services: WebSocket server, background job queue (BullMQ), SSH operations
- Database: PostgreSQL 16 with 10 interconnected tables
- Observability: Pino logging + Prometheus metrics
Target Audience: Non-Docker developers who want to run PostgreSQL and Redis locally rather than in containers.
| Item | Value |
|---|---|
| Node.js Requirement | 18+ |
| Package Manager | npm |
| TypeScript | Strict mode enabled |
| Main Framework | Next.js 15 (App Router) |
| API Framework | tRPC 11 |
| ORM | Drizzle ORM 0.44.6 |
| Database | PostgreSQL 16 |
| Cache/Queue Backend | Redis 7 |
| Default Port | 3000 (Web) + 3001 (WebSocket) |
| Authentication | Email/password + LDAP |
| Real-time Communication | WebSocket (ws library) |
| Background Jobs | BullMQ (Redis-based) |
| Monitoring | Pino (logging) + Prometheus (metrics) |
$CODEBASE/
├── package.json # 74 lines - Dependencies & npm scripts
├── tsconfig.json # TypeScript configuration
├── next.config.ts # Next.js configuration
├── eslint.config.mjs # ESLint rules (Next.js + TypeScript)
├── postcss.config.mjs # Tailwind CSS PostCSS config
├── drizzle.config.ts # Drizzle ORM migration config
├── .env.example # Environment variables template
├── .gitignore # Git ignore patterns
├── .husky/ # Git hooks (pre-push)
├── docker-compose.yml # Local service definitions
└── README.md # Main project documentation
app/
├── api/
│ ├── trpc/[trpc]/route.ts # tRPC endpoint handler
│ ├── health/
│ │ ├── startup/route.ts # Startup health check
│ │ ├── live/route.ts # Liveness probe
│ │ └── ready/route.ts # Readiness probe
│ ├── metrics/route.ts # Prometheus metrics endpoint
│ └── queue/add/route.ts # Queue job endpoint
├── login/page.tsx # Authentication page
├── projects/ # Project management pages
├── layout.tsx # Root layout wrapper
├── page.tsx # Home page
└── globals.css # Global styles
components/
├── UserList.tsx # User management UI (3047 lines)
├── WebSocketDemo.tsx # WebSocket testing UI
└── TaskQueueDemo.tsx # Queue job testing UI
lib/
├── auth/ # Authentication services
│ ├── service.ts # Main auth logic (154 lines)
│ ├── jwt.ts # JWT token signing/verification
│ ├── password.ts # bcryptjs hashing utilities
│ └── ldap.ts # LDAP directory integration
│
├── db/ # Database layer
│ ├── index.ts # Drizzle client setup
│ └── schema.ts # PostgreSQL schema definitions
│
├── trpc/ # tRPC API framework
│ ├── trpc.ts # tRPC instance + observability middleware
│ ├── context.ts # Request context setup
│ └── client.ts # Frontend tRPC client
│
├── queue/ # Task queue management
│ ├── index.ts # QueueManager class (3 queues)
│ └── config.ts # Redis configuration
│
├── websocket/ # WebSocket utilities
│ └── client.ts # WebSocket client wrapper
│
├── crypto/ # Encryption utilities
│ └── aes.ts # AES encryption/decryption
│
├── ssh/ # SSH operations
│ ├── types.ts # Type definitions
│ ├── pool.ts # Connection pooling
│ └── operations.ts # Remote command execution
│
├── notifications/ # Alert system
│ └── email.ts # Email sending
│
└── observability/ # Production monitoring
├── logger.ts # Pino structured logger
├── metrics.ts # Prometheus metric definitions
└── health.ts # Health check endpoints
server/
├── routers/ # tRPC endpoint definitions
│ ├── _app.ts # Router composition
│ ├── user.ts # User CRUD operations
│ ├── post.ts # Post CRUD operations
│ ├── auth.ts # Authentication endpoints
│ ├── project.ts # Project management (8964 lines)
│ ├── ssh-config.ts # SSH configuration (10358 lines)
│ └── ssh.ts # SSH operations (13650 lines)
│
├── queue/ # Background job processing
│ └── worker.ts # BullMQ worker with 3 queue handlers
│
└── websocket.ts # Standalone WebSocket server (187 lines)
cli/
└── index.ts # Commander.js CLI application
scripts/
└── seed.ts # Database seeding script
docs/
├── overview.md # Documentation index
├── architecture/ # System design docs
│ ├── architecture.md # (100% complete)
│ ├── api.md # (100% complete)
│ ├── database.md # (95% complete)
│ ├── authentication.md # (100% complete)
│ ├── development.md # (100% complete)
│ ├── deployment.md # (60% complete)
│ ├── websocket.md # (100% complete)
│ ├── task_queue.md # (100% complete)
│ ├── cli.md # (100% complete)
│ ├── ssh.md # (100% complete)
│ └── Flow diagrams
├── features/ # Implemented feature guides
└── proposal/ # Technology research (Bun adoption)
- Next.js 15.5.6 - React meta-framework with App Router
- React 19.1.0 - UI library
- Tailwind CSS 4 - Utility CSS with PostCSS
- TypeScript 5 - Type safety
- tRPC 11.0.0 - End-to-end typesafe API
- SuperJSON - Enhanced JSON serialization for complex types
- @tanstack/react-query 5.90.5 - Server state management
- Drizzle ORM 0.44.6 - Type-safe SQL query builder
- Drizzle Kit 0.31.5 - Schema management and migrations
- postgres 3.4.7 - PostgreSQL client library
- PostgreSQL 16 - Primary database (Alpine Docker image)
- jose 6.1.0 - JWT operations (sign/verify)
- bcryptjs 3.0.2 - Password hashing (Bcrypt)
- ldap-authentication 3.3.6 - LDAP/Active Directory support
- ws 8.18.3 - WebSocket server library
- BullMQ 5.61.0 - Redis-based task queue
- ioredis 5.8.1 - Redis client
- Redis 7 - In-memory data store (Alpine Docker image)
- pino 10.1.0 - Structured JSON logging
- pino-pretty 13.1.2 - Pretty-print logger (dev mode)
- prom-client 15.1.3 - Prometheus metrics collection
- node-ssh 13.2.1 - SSH client wrapper
- ssh2 1.17.0 - SSH protocol implementation
- commander 14.0.1 - CLI argument parsing
- tsx 4.20.6 - TypeScript runner (no build step)
- dotenv 17.2.3 - Environment variable loader
- zod 4.1.12 - TypeScript-first schema validation
- ESLint 9 - JavaScript/TypeScript linter
- Husky 9.1.7 - Git hooks manager
- lint-staged 16.2.6 - Pre-commit linting
- TypeScript - Type checking compiler
- Architecture Overview
- API Reference (tRPC endpoints)
- Authentication Setup (Email + LDAP)
- Development Workflow
- WebSocket Guide
- Task Queue Guide
- CLI Reference
- SSH Remote Operations
- Database Schema Guide (generated but not finalized)
- Deployment Guide (local Docker done, production CI/CD pending)
- Bun Runtime Adoption
All documentation is located in $CODEBASE/docs/
npm run dev # Start Next.js dev server (Turbopack)
npm run build # Production build
npm start # Run production buildnpm run lint # ESLint check
npm run lint:fix # Auto-fix ESLint issues
npm run type-check # TypeScript checking (no emit)
npm test # Tests (placeholder: no tests configured)npm run db:push # Push schema to DB (dev - no migrations)
npm run db:generate # Create migration files
npm run db:migrate # Apply migrations (production)
npm run db:studio # Open Drizzle Studio GUI
npm run db:seed # Seed database with initial datanpm run ws:server # Start WebSocket server on port 3001
npm run queue:worker # Start background job worker
npm run cli # Run CLI client
npm run prepare # Setup Husky git hooks- Turbopack: Used for fast builds (both dev and production)
- TypeScript Strict: ES2017 target, strict mode on
- Module System: ESNext with bundler resolution
- Path Alias:
@/*maps to project root
File: $CODEBASE/.husky/pre-push
npm run type-check # Must pass TypeScript checks
npm test # Must pass tests (placeholder)Connection String Format:
postgresql://username:password@host:port/database
Drizzle Config File: $CODEBASE/drizzle.config.ts
-
users - User accounts
- Columns: id, username, name, email, password (hashed), authType, mustChangePassword, createdAt, updatedAt, lastLogin
- Constraints: unique(username), unique(email)
-
posts - Blog/content posts
- Columns: id, title, content, authorId (FK->users), createdAt, updatedAt
-
tasks - Background job tracking
- Columns: id, name, status, data (JSONB), result (JSONB), createdAt, completedAt
-
projects - Projects
- Columns: id, projectVersion, projectCode, name, description, ownerId (FK->users), status, visibility, metadata (JSONB), timestamps
-
projectMembers - Project collaborators
- Columns: id, projectId (FK), userId (FK), role, joinedAt
- Roles: owner, admin, member, viewer
-
permissionRequests - Access request workflow
- Columns: id, projectId (FK), userId (FK), status (pending/approved/rejected), timestamps, resolvedBy (FK)
-
sshAccounts - SSH connection profiles
- Columns: id, accountName, host, port, username, encrypted credentials, authMethod, basePath, timeout, isActive, timestamps
-
projectSshConfigs - SSH config assignments
- Columns: id, projectId (FK cascade), sshAccountId (FK cascade), configAlias, overridePath, isDefault, timestamp
- Constraint: unique(projectId, configAlias)
-
sshOperationLogs - Audit trail
- Columns: id, projectId (FK), sshAccountId (FK), operation, parameters (JSONB), success, stdout, stderr, errorMessage, executionTime, timestamp
-
sshErrorNotifications - Error alert configuration
- Columns: id, projectId (FK cascade), sshAccountId (FK cascade), notifyOnError, emailAddresses, customHandler, customConfig (JSONB), maxRetries, retryDelay, timestamps
- Constraint: unique(projectId, sshAccountId)
File: $CODEBASE/lib/db/index.ts
export const db = drizzle(queryClient, { schema })- Uses postgres client for connections
- Drizzle ORM for type-safe queries
- Automatic schema typing
- Local PostgreSQL must be running
- Set
DATABASE_URLin.env - Run
npm run db:pushto apply schema - Run
npm run db:seedto add initial data
Location: $CODEBASE/.env.example
Required Variables:
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/mydb
REDIS_URL=redis://localhost:6379
PORT=3000
WS_PORT=3001
NODE_ENV=development
JWT_SECRET=your-secret-key-change-in-production-make-it-long-and-random
SSH_ENCRYPTION_KEY=<random-32-byte-hex>Optional Variables (LDAP):
LDAP_URL=ldap://your-ldap-server:389
LDAP_BIND_DN=cn=admin,dc=example,dc=com
LDAP_BIND_PASSWORD=password
LDAP_SEARCH_BASE=ou=users,dc=example,dc=com
LDAP_USERNAME_ATTRIBUTE=uidOptional Variables (Logging):
LOG_LEVEL=debug # trace|debug|info|warn|error|fatal| File | Purpose |
|---|---|
tsconfig.json |
TypeScript compiler settings (strict mode, ES2017 target) |
next.config.ts |
Next.js framework configuration |
eslint.config.mjs |
ESLint rules (flat config format) |
postcss.config.mjs |
Tailwind CSS processing |
drizzle.config.ts |
Database migration configuration |
.env.example |
Environment variable template |
.gitignore |
Git exclusions (node_modules, .next, .env) |
.husky/pre-push |
Git hook script |
docker-compose.yml |
Local service definitions (PostgreSQL, Redis) |
No tests are configured. The test script is a placeholder:
"test": "echo \"No tests configured yet\" && exit 0"- TypeScript support (strict mode)
- ESLint for code quality
- Type checking with
npm run type-check - Pre-push hooks (will run type-check)
- ESLint 9 - Linting with Next.js + TypeScript configs
- lint-staged - Pre-commit file linting
- Husky - Git hook execution
- TypeScript - Type safety validation
- Jest or Vitest - Unit and integration tests
- React Testing Library - Component testing
- Supertest - API route testing
- MSW (Mock Service Worker) - API mocking
Pre-push validation requires:
- TypeScript strict compilation (must pass)
- Tests (currently placeholder)
File: $CODEBASE/lib/auth/service.ts (154 lines)
Supported Methods:
- Email/password with bcryptjs hashing
- LDAP/Active Directory integration
- JWT tokens with 24-hour expiration
Default Test User:
- Username:
root - Password:
Must-Changed(must be changed in production)
File: $CODEBASE/server/websocket.ts (187 lines)
Features:
- Standalone service on port 3001
- Channel-based subscriptions
- Client-to-client broadcasting
- Ping/pong heartbeat
- Prometheus metrics tracking
- Graceful shutdown handling
Commands:
npm run ws:serverFiles:
- Manager:
$CODEBASE/lib/queue/index.ts - Worker:
$CODEBASE/server/queue/worker.ts - Config:
$CODEBASE/lib/queue/config.ts
Features:
- Three queues: DEFAULT, EMAIL, PROCESSING
- Redis-backed persistence
- Job retry logic
- Priority support
- Prometheus metrics
Commands:
npm run queue:workerFeatures:
- SSH connection pooling
- Encrypted credential storage (AES)
- Operation audit logging
- Error notifications
- Password + key-based authentication
Logging (Pino): $CODEBASE/lib/observability/logger.ts
- Structured JSON logs
- Development: pretty-printed
- Production: JSON format
- Context-aware child loggers
Metrics (Prometheus): $CODEBASE/lib/observability/metrics.ts
- HTTP request metrics
- tRPC procedure metrics
- WebSocket connection metrics
- Queue job metrics
- Prometheus endpoint:
/api/metrics
Health Checks: $CODEBASE/lib/observability/health.ts
/api/health/startup- Startup probe/api/health/live- Liveness probe/api/health/ready- Readiness probe
File: $CODEBASE/cli/index.ts
Commands:
npm run cli user list # List users
npm run cli user create "name" "email" # Create user
npm run cli user get <id> # Get user
npm run cli user delete <id> # Delete user
npm run cli post list # List posts
npm run cli post create "title" "[content]" # Create post
npm run cli ws listen <channel> # Listen WebSocket
npm run cli ws send <channel> "message" # Send message- Node.js 18+
- PostgreSQL 16 (local installation, not Docker)
- Redis 7 (local installation, not Docker)
- npm or yarn
Step 1: Install Dependencies
cd /home/user/corestack
npm installStep 2: Create Environment File
cp .env.example .env
# Edit .env with your local database/Redis URLsStep 3: Start Local Services
# PostgreSQL 16 must be running on localhost:5432
# Redis 7 must be running on localhost:6379
# Verify with: psql -U postgres -h localhost
# redis-cli pingStep 4: Initialize Database
npm run db:push # Apply schema
npm run db:seed # Seed initial dataStep 5: Start Development Servers (3 separate terminals)
# Terminal 1: Web application (http://localhost:3000)
npm run dev
# Terminal 2: WebSocket server (ws://localhost:3001)
npm run ws:server
# Terminal 3: Background job worker
npm run queue:workerStep 6: Access Application
- Web UI: http://localhost:3000
- Login: username
root, passwordMust-Changed - API: http://localhost:3000/api/trpc
- WebSocket: ws://localhost:3001
- Metrics: http://localhost:3000/api/metrics
- Health: http://localhost:3000/api/health/live
# Type checking
npm run type-check
# Linting
npm run lint
npm run lint:fix
# Production build test
npm run build
npm start
# Database operations
npm run db:studio # Open Drizzle GUI
npm run db:generate # Create migrations| Category | Technology | Version | Status |
|---|---|---|---|
| Frontend Framework | Next.js | 15.5.6 | Production |
| UI Library | React | 19.1.0 | Production |
| Styling | Tailwind CSS | 4 | Production |
| Language | TypeScript | 5 | Strict Mode |
| API Framework | tRPC | 11.0.0 | Production |
| ORM | Drizzle | 0.44.6 | Production |
| Primary Database | PostgreSQL | 16 | 10 tables |
| Cache/Queue | Redis | 7 | BullMQ queues |
| WebSocket | ws library | 8.18.3 | Production |
| Authentication | JWT + bcrypt | - | Email + LDAP |
| Logging | Pino | 10.1.0 | Structured JSON |
| Monitoring | Prometheus | prom-client 15.1.3 | /api/metrics |
| CLI | Commander.js | 14.0.1 | Production |
| SSH | ssh2 | 1.17.0 | Pooled + Encrypted |
| Testing | None | - | Ready for setup |
| Linting | ESLint | 9 | Next.js config |
| Build Tool | Turbopack | - | Via Next.js |
$CODEBASE/package.json- Dependencies$CODEBASE/tsconfig.json- TypeScript config$CODEBASE/next.config.ts- Next.js config$CODEBASE/eslint.config.mjs- Linting rules$CODEBASE/drizzle.config.ts- DB migrations$CODEBASE/.env.example- Env template
$CODEBASE/lib/db/schema.ts- Schema definitions$CODEBASE/lib/db/index.ts- DB client
$CODEBASE/lib/auth/service.ts- Auth logic$CODEBASE/lib/auth/jwt.ts- JWT handling$CODEBASE/lib/auth/ldap.ts- LDAP integration
$CODEBASE/lib/trpc/trpc.ts- tRPC setup$CODEBASE/server/routers/_app.ts- Root router$CODEBASE/app/api/trpc/[trpc]/route.ts- tRPC endpoint
$CODEBASE/server/websocket.ts- WebSocket server$CODEBASE/lib/queue/index.ts- Queue manager$CODEBASE/server/queue/worker.ts- Queue worker
$CODEBASE/lib/observability/logger.ts- Pino logger$CODEBASE/lib/observability/metrics.ts- Prometheus metrics$CODEBASE/lib/observability/health.ts- Health checks
$CODEBASE/cli/index.ts- CLI commands
$CODEBASE/docs/- All documentation$CODEBASE/README.md- Main README
# Setup
npm install
cp .env.example .env
# Development (3 terminals)
npm run dev # Terminal 1: Web app
npm run ws:server # Terminal 2: WebSocket
npm run queue:worker # Terminal 3: Queue worker
# Database
npm run db:push # Apply schema
npm run db:seed # Add test data
npm run db:studio # Open GUI editor
# Code Quality
npm run type-check # TypeScript validation
npm run lint # Check code
npm run lint:fix # Auto-fix issues
npm run build # Production build
# Testing (User/Post/WebSocket)
npm run cli user list # List users
npm run cli ws listen demo # WebSocket listenFor creating a Non-Docker development guide, focus on:
- PostgreSQL + Redis local installation
- Environment setup (.env)
- Database initialization workflow
- Three-terminal service startup
- Development best practices
- tRPC endpoint usage examples
- WebSocket integration guide
- Queue job implementation
All documentation foundation exists in $CODEBASE/docs/ directory.