Dr.Coco

Apr 2026

E-commerce platform + admin dashboard ~5 months Shipping
Next.js 15 React TypeScript Tailwind CSS shadcn/ui Framer Motion Prisma ORM PostgreSQL NextAuth.js Stripe Apaczka wFirma + KSeF 2.0 Cloudinary Resend Vercel Cron

Overview

End-to-end e-commerce replatform for Dr.Coco — a Polish brand importing natural coconut water from Vietnam. The client wanted to leave WordPress behind for something fast, modern, and fully automated, without losing the original spirit of the store or the SEO equity built up on the old domain. The result is a custom Next.js storefront and admin panel where every paid order is automatically handed off to Apaczka for courier pickup, invoiced through wFirma under the new 2026 Polish KSeF 2.0 regulations, and kept in sync via scheduled cron jobs — so the owner runs the business from one dashboard instead of five browser tabs.

Key features

Full WordPress → Next.js Replatform

Rebuilt on the Next.js App Router with a refreshed design that keeps the original brand spirit — faster, responsive, and free of plugin sprawl.

Automated Apaczka Shipping

Every paid order is sent to Apaczka automatically — pickup requested, waybill generated, tracking URL saved to the order.

KSeF 2.0 Invoicing via wFirma

Invoices are issued automatically through wFirma and stay compliant with Poland's 2026 KSeF 2.0 rules.

Stripe Payments + Bank Transfer + COD

Stripe Checkout handles card payments through a webhook-driven fulfillment flow.

Multi-Tier Account System with Custom Pricing

Multiple account types each get their own product visibility, pricing rules, and payment methods.

Custom Admin Panel

Products, orders, clients, discount codes, and blog are all managed from one panel built for this business.

Apaczka Status Sync Cron

A daily Vercel cron job pulls the latest Apaczka status for every in-flight order and updates the local record.

The Problem

Dr.Coco was running on WordPress — the usual story. Plugin dependencies, slow page loads, a dated look, and every operational task (shipping labels, invoices, status updates) happening manually in separate tools.

The client wanted out of WordPress entirely. He needed a store that was fast, responsive, refreshed visually but still felt like Dr.Coco, and — most importantly — fully automated. Paid order in, packed box out, with no human in the loop.

On top of that, Poland’s new KSeF 2.0 e-invoicing regulations come into force in 2026, which meant the invoicing pipeline had to be rebuilt around a compliant provider rather than bolted on as an afterthought.

Design

I refreshed the whole look of the site while keeping the elements that defined the original brand — the colour direction, the product presentation, the friendly Polish copy. The goal was “this is clearly still Dr.Coco, just in 2026.” Designed up front, approved before any code was written, then built mobile-first on Tailwind and shadcn/ui with Framer Motion for the lighter interactions.

Approach

Next.js App Router, end to end. Server components for product and checkout pages, server actions for every mutation (products, clients, orders, blog), typed Zod-validated inputs returning structured FormState objects. Prices are stored in integer cents to avoid rounding games. Prisma + PostgreSQL for the data layer, NextAuth with dual credential providers (admin via env, customers via DB + bcrypt).

Stripe as the fulfillment trigger. The Stripe webhook is the source of truth. On checkout.session.completed the order flips to PAID, the Payment row is created, the Apaczka booking fires, the wFirma invoice is issued, and the confirmation email goes out. Each side effect is independent — a wobble in one service doesn’t poison the order record.

Apaczka integration from scratch. Paid order → API call to Apaczka with the shipping address, package dimensions, weight, and selected service → waybill number + tracking URL saved back to the order → courier pickup scheduled. For point-based delivery (InPost-style paczkomaty), the customer picks a point during checkout and the ID flows through to the booking.

wFirma + KSeF 2.0. Each paid order automatically generates an invoice through the wFirma API. Company data (company name, NIP) is optionally collected at checkout and attached to the invoice so B2B customers get a proper faktura VAT. Refunds trigger correction invoices, also through wFirma, with the correction number stored on the order.

Account types drive the whole experience. The AccountType enum (ADMIN / DETAL / DETAL_B2B / HURT) gates what products a user sees, what prices they get, and which payment methods they can use at checkout. A separate CustomPrice table lets the admin override any product’s price for a specific user — useful for negotiated wholesale deals without cloning the catalog.

Admin panel built for daily ops. Not a scaffolded CRUD — a real management tool: products with markdown content and Cloudinary image upload, orders with full lifecycle status, clients with per-user custom prices, discount codes with single-use and usage tracking, and a blog. Driven entirely by server actions so the whole thing is type-safe from form field to database column.

Scheduled cron jobs. A daily Vercel cron calls Apaczka, walks every in-flight order, and syncs the latest status (apaczkaStatus, plus the local OrderStatus) so the customer’s “my orders” page and the admin dashboard always reflect reality without anyone having to click anything.

SEO preservation on migration. Rolled out with a 301 redirect map from the old WordPress URLs to the new Next.js routes, carrying across titles, descriptions, and canonical tags so the domain’s existing ranking survived the replatform instead of being nuked by a fresh-start penalty.

Challenges

Apaczka’s API with thin documentation. The Polish shipping aggregator’s API docs were incomplete in places and, for some endpoints, didn’t match what the service actually accepted. Getting the order-confirmation payload and the status-sync flow right required reverse-engineering the expected shape from real responses, trial-and-erroring fields, and building a resilient client (apaczka.ts, apaczka-confirm.ts, apaczka-sync.ts) that handles the quirks instead of pretending they don’t exist.

wFirma + KSeF 2.0 under a moving regulation. The 2026 KSeF 2.0 rules were still being finalised during development, and wFirma’s API had its own gaps. The invoicing module had to satisfy the new compliance rules, handle optional B2B fields (company name, NIP), and support correction invoices for refunds — all via an API whose edge cases had to be probed rather than read.

WordPress → Next.js migration without losing SEO. The old store had years of indexed URLs and accumulated ranking. The cut-over included a URL map with 301 redirects for every legacy path, preserved meta titles and descriptions, and a new sitemap and robots.txt generated from the database so nothing important fell out of Google’s index on launch day.

Four account types, one checkout. Retail customers, retail B2B, and wholesale clients each see different products, different prices, and different payment methods. All of that had to be expressed without forking the codebase — so visibility flags live on the product, per-user overrides live in CustomPrice, and the checkout resolves the right price and the right allowed payment methods per session.

End-to-end automation with atomic failure handling. Stripe webhook, Apaczka booking, wFirma invoice, confirmation email — one paid order triggers a chain of external calls, and any of them can hiccup. The pipeline is built so each step is idempotent, failures don’t corrupt the order record, and anything that needs a retry can be re-run without creating duplicates.

Results

Migrated a live WordPress store to a custom Next.js stack without losing SEO — old URLs 301 to new ones and keep their metadata

Fully automated order lifecycle — paid → courier booked → invoice issued → tracking emailed, with zero manual steps

KSeF 2.0 compliant from day one under Poland's 2026 e-invoicing regime

Faster page loads, mobile-first responsive design, modern look that still feels like Dr.Coco

Owner runs products, orders, clients, pricing tiers, and blog from one admin panel

Need a site, a custom tool, or full e-commerce build?

Send scope, budget range, and timeline. I will reply with a realistic plan.

hello@fao.dev