Skip to content

Latest commit

Β 

History

24 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

MyOrg Monorepo

Production-ready full-stack monorepo with Turborepo, React, Node.js, oRPC, Prisma, Redis, and WebSocket.

πŸš€ Quick Start

Local Development (Recommended)

# Clone and install (Automated Prisma client generation)
pnpm install

# Setup environment
cp .env.example .env
# Edit .env with your values

# Start databases (requires Docker)
pnpm docker:up

# Run database migrations
pnpm db:migrate

# Seed database
pnpm db:seed

# Start development
pnpm dev

Docker Development (Full Containerization)

# Setup environment
cp .env.example .env

# Start everything in Docker with hot reload
pnpm docker:dev

# Or rebuild and start
pnpm docker:dev:build

Features:

  • βœ… Hot reload for apps AND packages
  • βœ… No local Node.js installation needed
  • βœ… Consistent environment across team
  • βœ… Changes reflected in 1-3 seconds

Verify Configuration:

# Windows
.\verify-hot-reload.ps1

# Linux/Mac
./verify-hot-reload.sh

See README_HOT_RELOAD.md for complete guide.

Open:

πŸ“ Project Structure

/
β”œβ”€β”€ apps/
β”‚ β”œβ”€β”€ api/ # Backend API (Hono + Prisma + Redis)
β”‚ └── web/ # Frontend (Vite + React + React Query)
β”œβ”€β”€ packages/
β”‚ β”œβ”€β”€ types/ # Shared TypeScript types & Zod schemas
β”‚ β”œβ”€β”€ db/ # Shared Database layer (Prisma)
β”‚ β”œβ”€β”€ utils/ # Shared utilities (env, logger)
β”‚ └── ui/ # Shared UI components (shadcn)
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ turbo.json
β”œβ”€β”€ pnpm-workspace.yaml
└── .github/workflows # CI/CD configurations

πŸ› οΈ Technology Stack

Layer Technology
Monorepo Turborepo + pnpm workspaces
Frontend Vite, React 18, TypeScript, React Query, Zustand
UI Tailwind CSS, shadcn/ui, Radix UI
Backend Node.js, Hono, TypeScript
RPC oRPC (type-safe), ArkType validation
Database PostgreSQL, Prisma ORM
Cache Redis (caching, rate limiting, sessions)
Auth JWT, bcrypt, role-based access
Realtime WebSocket with Redis pub/sub
Container Docker, Docker Compose
CI/CD GitHub Actions (Standardized Pipeline)
Code Quality ESLint, Prettier, Commitlint, Lefthook

πŸ“¦ Available Scripts

# Development
pnpm dev           # Start all apps in dev mode
pnpm build         # Build all packages and apps (with automated Prisma generation)
pnpm lint          # Run linting
pnpm typecheck     # Type checking

# Database
pnpm db:generate   # Generate Prisma client (triggered automatically on install)
pnpm db:migrate    # Run migrations
pnpm db:seed       # Seed database
pnpm db:studio     # Open Prisma Studio

# Docker
pnpm docker:up     # Start all containers
pnpm docker:down   # Stop all containers
pnpm docker:build  # Build production Docker images

πŸ” Authentication

Default seeded users:

Email Password Role
admin@example.com admin123 Admin
user@example.com user1234 User

πŸ“‘ API Endpoints

Auth

  • POST /api/auth/register - Register new user
  • POST /api/auth/login - Login
  • GET /api/auth/me - Get current user
  • POST /api/auth/logout - Logout
  • POST /api/auth/refresh - Refresh token

Tasks

  • GET /api/tasks - List tasks
  • GET /api/tasks/:id - Get task
  • POST /api/tasks - Create task
  • PATCH /api/tasks/:id - Update task
  • DELETE /api/tasks/:id - Delete task

Files

  • POST /api/upload - Upload file
  • GET /api/files - List files
  • DELETE /api/files/:id - Delete file

Admin

  • GET /api/admin/users - List users (admin only)
  • GET /api/admin/users/:id - Get user (admin only)
  • DELETE /api/admin/users/:id - Delete user (admin only)

Health

  • GET /health - Health check
  • GET /ready - Readiness check

🐳 Docker Deployment

The project uses multi-stage Docker builds for optimized production images.

# Build and run with Docker Compose
pnpm docker:build
pnpm docker:up

# View logs
docker-compose logs -f api

πŸ› οΈ Docker Development Environment

We provide a separate, standalone Docker environment for development that includes hot-reloading for both the API and Web applications.

# Start the development environment
pnpm docker:dev

# Rebuild containers (if dependencies change)
pnpm docker:dev:build

Access services at:

βš™οΈ CI/CD & Commit Standards

GitHub Actions

The pipeline (.github/workflows/ci.yml) automatically:

  • Installs dependencies with cached pnpm.
  • Generates Prisma client types.
  • Runs type-checking across the monorepo.
  • Executes linting.
  • Builds production Docker images on push to main.

Commit Conventions

We use @commitlint/config-conventional with relaxed rules for subjects:

  • Type: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert.
  • Scope: Required (e.g., feat(api): ...).
  • Subject: Automated case validation is disabled to support acronyms and technical terms. Max length increased to 200 characters.

πŸ”„ WebSocket Events

Event Direction Description
task.created Server β†’ Client Task created
task.updated Server β†’ Client Task updated
task.deleted Server β†’ Client Task deleted
user.online Server β†’ Client User came online
user.offline Server β†’ Client User went offline
presence.list Server β†’ Client Online users list

πŸ”§ Environment Variables

See .env.example for all variables. Key ones:

DATABASE_URL=postgresql://postgres:postgres@localhost:5432/myorg
REDIS_URL=redis://localhost:6379
JWT_SECRET=your-secret-key-min-32-chars

πŸƒ Alternative Runtimes

See README_BUN_DENO.md for Bun and Deno support.

# Bun
bun run --filter @myorg/api dev:bun

# Deno
deno run --allow-all apps/api/src/index.deno.ts

πŸ“ˆ Best Practices

Cache Invalidation

  • Task cache invalidated on create/update/delete
  • User cache invalidated on update/delete
  • Pattern-based invalidation for lists

WebSocket Scaling

  • Redis pub/sub for multi-server deployments
  • Heartbeat for connection health
  • Automatic reconnection on client

Security

  • βœ… JWT with configurable expiry
  • βœ… Password hashing with bcrypt
  • βœ… Role-based access control
  • βœ… Rate limiting per IP/user
  • βœ… Token blacklist for logout
  • βœ… CORS configuration
  • βœ… Helmet-like security headers

πŸ“ License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages