Bakchich
Case study of leading a full architectural migration from legacy PHP to a modern Next.js Nx monorepo with NixOS, Docker, and Azure CI/CD at Bakchich.
Company Context & Mandate
Bakchich is a creator monetization platform designed for creators, digital artists, and influencers to monetize premium content, sell digital products, and accept tips and memberships from their audience.
I joined Bakchich as a Full-Stack Software Developer when the company faced significant engineering debt. The platform was running on an aging, monolithic PHP backend coupled with server-rendered templates that struggled with high latency, poor SEO indexation, slow development cycles, and environment inconsistencies across developer machines.
My mandate was to lead a complete architectural overhaul: modernizing the codebase to a high-performance Next.js frontend, establishing a scalable Nx monorepo, and building reproducible development and CI/CD pipelines using NixOS, Docker, and Azure.
What I Built
1. PHP to Next.js Migration (Strangler-Fig Pattern)
Instead of attempting a risky "big-bang" rewrite on a live platform handling active payment transactions, I executed a Strangler-Fig migration strategy:
- Incremental Routing: Placed a modern edge proxy layer in front of the application to route traffic incrementally from legacy PHP endpoints to newly built Next.js pages.
- Core Application Modernization: Rebuilt high-traffic creator storefronts, checkout flows, and user dashboards into server-side rendered (SSR) Next.js routes.
- State & Data Parity: Introduced Prisma ORM over the existing MySQL database schema, abstracting database operations into type-safe queries shared across legacy and modern components without breaking live tables.
[ Incoming User Traffic ] ──> ( Edge Proxy Router )
│
┌────────────────────────┴────────────────────────┐
▼ ▼
[ Legacy PHP Monolith ] [ Modern Next.js SSR App ]
(Phased out incrementally) (Prisma ORM + MySQL)2. Nx Monorepo Architecture
Organized the entire frontend and API abstraction layer into a unified Nx monorepo:
- Shared UI Libraries: Abstracted design system components into a shared UI package using Tailwind CSS, ensuring consistent design across the creator storefront and internal admin panels.
- Shared Config & Utils: Centralized i18n translation strings, type definitions, and API client wrappers to maintain end-to-end type safety.
3. Reproducible Dev Environments & CI/CD
- NixOS & nix-shell: Solved the classic "works on my machine" problem by authoring declarative
shell.nixconfigurations. Developers could spin up identical Node.js, PHP, and database runtimes with a single terminal command. - Docker & Azure Pipelines: Built automated GitHub Actions workflows that ran linting, type-checking, and tests before building containerized Docker images deployed to Azure App Services.
Scope & Responsibilities
-
Architectural Leadership
Selected, configured, and maintained the Nx monorepo structure, Prisma data models, and deployment pipelines.
-
Full-Stack Development
Authored clean TypeScript code across Next.js pages, API routes, and database abstraction modules.
-
Internationalization (i18n)
Implemented multi-language and localized content routing (Arabic/French/English) to support cross-regional creator audiences.
-
Developer Experience & Mentorship
Onboarded team members to the new Next.js and Nx architecture through code reviews, documentation, and tooling walkthroughs.
Impact & Results
Reduced initial page-load latencies dramatically while unlocking full SSR capabilities, leading to measurable search indexation improvements for creator profiles.
Accelerated feature build cycles and cut dev onboarding time from days to minutes using declarative nix-shell environments.
Leveraged Nx smart caching in CI/CD pipelines to skip rebuilding unchanged packages, slashing overall deployment build times.
Tech Stack Deep Dive
- Next.js & React
- Primary stack for server-side rendering, dynamic route handling, and reactive user interfaces.
- Nx
- Monorepo management tooling providing smart caching, dependency graph generation, and modular code separation.
- Prisma & MySQL
- Type-safe database ORM managing relational schemas and database migrations.
- NixOS & Docker
- Declarative environment isolation and containerization tools for development and production.
- Azure & GitHub Actions
- Cloud infrastructure hosting and automated CI/CD pipeline execution.
Links & Resources
Lessons Learned
- 01
Strangler-Fig Over Big-Bang Rewrites
Incremental migration guarantees zero business downtime and allows continuous verification of user data parity during architectural overhauls.
- 02
Declarative Environments Pay Off Immediately
Investing time in declarative tooling like NixOS eliminates hours of lost developer time spent debugging local environment differences.
- 03
What I'd Do Differently
I would introduce automated end-to-end regression testing (using Playwright) even earlier in the migration to catch subtle edge-case visual bugs across legacy and modern routes.