Skip to content

lgdlong/dev-wiki

Repository files navigation

Dev Wiki Monorepo

A comprehensive developer knowledge-sharing platform built with TypeScript, featuring video tutorials, product reviews, and community discussions.

Architecture Overview

Dev Wiki is a modern TypeScript-first monorepo that enables developers to share knowledge through interactive tutorials, video content, and product reviews. Built with scalability and developer experience in mind.

Tech Stack

  • Frontend: Next.js 15 (React 19) + Tailwind CSS + Shadcn/ui
  • Backend: NestJS + TypeORM + PostgreSQL
  • Authentication: JWT + Google OAuth + Role-based Access Control (RBAC)
  • Monorepo: Turborepo + pnpm workspaces
  • Language: TypeScript (strict mode)
  • Code Quality: ESLint + Prettier + shared configurations

Project Structure

dev-wiki/
├── apps/
│   ├── web/                 # Next.js frontend (port 3000)
│   ├── api/                 # NestJS backend (port 8000)
│   └── db/                  # Database scripts & Docker setup
├── packages/
│   ├── eslint-config/       # Shared ESLint rules
│   ├── typescript-config/   # Shared TypeScript configs
│   └── ui/                  # Shared React components (@repo/ui)
└── docker-compose.yml       # PostgreSQL + development services

Quick Start

Prerequisites

  • Node.js 18+
  • pnpm 9.0.0+
  • Docker (for PostgreSQL)

Setup

  1. Clone and install dependencies:

    git clone <repository-url>
    cd dev-wiki
    pnpm install
  2. Start database:

    docker compose up -d
  3. Configure environment variables:

    # Copy environment files for each app
    cp apps/api/.env.example apps/api/.env
    cp apps/web/.env.example apps/web/.env
  4. Start development servers:

    pnpm dev

Access Points

Development Workflow

Essential Commands

# Install dependencies
pnpm install

# Development (all apps)
pnpm dev

# Individual apps
pnpm dev --filter=web    # Frontend only
pnpm dev --filter=api    # Backend only

# Build
pnpm build               # All apps
pnpm build --filter=api  # Backend only

# Testing
pnpm test               # All tests
pnpm test:e2e          # End-to-end tests
pnpm test:cov          # Coverage report

# Code quality
pnpm lint              # Lint all code
pnpm lint --fix        # Auto-fix issues
pnpm format            # Format code

Database Management

# Start PostgreSQL
docker compose up -d

# View logs
docker compose logs postgres

# Connect to database
docker exec -it dev-wiki-postgres psql -U devwiki -d devwiki

Database Setup

For detailed database connection information and configuration, see the Database README.

For step-by-step backup instructions with DBeaver, see Database Backup Guide.

Authentication & RBAC

  1. JWT Tokens: Stored in localStorage for API authentication
  2. Role Cookies: Set by backend, read by frontend middleware for RBAC
  3. Google OAuth: Integrated via Passport.js
  4. Roles: user, mod, admin with route-level protection

Development Guidelines

Code Standards

  • TypeScript strict mode - No any types
  • Shared configurations - ESLint/Prettier/TypeScript
  • Component patterns - Reusable UI components in @repo/ui
  • API patterns - DTOs, Guards, Services, Controllers

Best Practices

  1. Use pnpm for all package management
  2. Follow RBAC patterns - Backend sets cookies, frontend enforces
  3. Type-safe APIs - Share types between frontend/backend
  4. Test thoroughly - Unit tests, E2E tests, coverage reports
  5. Error handling - Structured errors with user-friendly messages

Project Conventions

  • File naming: kebab-case for files, PascalCase for components
  • Import order: External → Internal → Relative
  • Error handling: Try/catch with specific error types
  • Validation: DTOs (backend) + Zod schemas (frontend)

Documentation

Application READMEs

API Documentation

Troubleshooting

Common Issues

Database connection failed:

# Ensure PostgreSQL is running
docker compose up -d

TypeScript errors:

# Rebuild types
pnpm build

Port conflicts:

# Check running processes
lsof -i :3000  # Frontend
lsof -i :8000  # Backend
lsof -i :5432  # Database

Build failures:

# Clean and reinstall
rm -rf node_modules
pnpm install
pnpm build