中文 English

Engineering Portfolio

Published: 2026-11-25 · Views --
Backend Architecture Distributed Systems AI Engineering Open Source

Backend Architecture · Distributed Systems · Cloud Platform · AI Engineering

14+ Years of Engineering · Ex-Huawei · HUST Software Engineering · ACM/ICPC Regional Silver Medalist

JavaGoSpring BootgRPCKafkaRedisMySQLMQTTKubernetesDockerDistributed SystemsAI Native

Software engineer and platform architect with 14+ years of experience (formerly at Huawei), specializing in distributed systems, backend platform architecture, core service development, and production reliability engineering.

This page documents my engineering practice, open-source work, and technical explorations across robotics cloud platforms, OpenAPI platforms, distributed task scheduling, AI-native software delivery, and independent product building.

Beyond architectural design alone, I focus on turning ideas into reliable, observable, maintainable software systems that deliver continuously.

Production-related content covers only systems I directly owned, fully sanitized. Open-source and experimental projects are documented strictly according to real repositories, automated tests, and release records — never conflating lab setups with production scale.

Links: GitHub (@margrop) · GitHub (@XingP14) · X (@MargropMe) · Smart Wrong Notebook · AI Video Studio · Coding Plan Dashboard · Margrop Labs

Production Engineering · Backend & Robotics Cloud Platform

Long-term owner of core backend services and platform architecture for a production robotics cloud platform (primary stack: Java / Go, alongside Spring Boot, gRPC, Kafka, Redis, MySQL, MQTT, and Kubernetes), covering device connectivity, OpenAPI governance, distributed task scheduling, and production stability.

Tens of thousandsConnected robot fleet scale
50+Core OpenAPI endpoints
Hundreds of thousandsDaily scheduled & executed tasks
99.99%Task report upload success rate
01 · OPENAPI PLATFORMOpenAPI PlatformUnified access layer for internal business units and ecosystem partners, covering multi-tenant authentication, API contract and version governance, schema validation, tiered rate limiting, and write idempotency across 50+ core APIs.
02 · DISTRIBUTED SCHEDULINGDistributed Task SchedulingHigh-concurrency device job scheduling and async orchestration built on explicit task state machines, worker leases with timeout takeover, fencing tokens against split-brain execution, idempotency keys, and the outbox pattern.
03 · DEVICE & MESSAGINGDevice Communication & MessagingManaging persistent MQTT / WebSocket / gRPC device connections and Kafka / Redis event streams — handling unstable-network reconnections, out-of-order and duplicate deliveries, command ACKs, and reliable report uploads at 99.99% success.
04 · OBSERVABILITY & SREObservability & ReliabilityEnd-to-end causality via Prometheus, Loki / ELK, and unified trace IDs; capacity baselining, circuit breaking, and postmortems targeting P95/P99 tail latency, retry storms, MySQL slow queries / online DDL, and JVM off-heap / thread-pool saturation.

Sanitized architecture & backend deep dives: Production Reference Architecture → · Worker Crashes & Idempotency → · Lock-Free MySQL Online DDL → · Spring Boot JNI Library Loading →

Smart Wrong Notebook · Flagship Open Source Project

Smart Wrong Notebook is an AI-powered, self-hosted learning and mistake-management platform that connects photo/PDF question capture, step-by-step explanations, curriculum knowledge tagging, variation practice, spaced-repetition scheduling, and printable A/B exam generation into one closed loop.

680+ Stars684 GitHub Stars · 145 Forks
10+ ProvidersUnified Abstraction · Fallback · OAuth
355 Test Files247 Unit · 62 Integration · 46 E2E Specs
7 TargetsDocker · npm · Desktop · Android · NAS

Origin & Contribution Scope: Forked from wttwins/wrong-notebook, with extensive architectural refactoring and ongoing maintenance for real-world family learning and self-hosting — including multi-provider AI routing and zero-API-key OAuth access, whole-PDF scanned batch import with cross-page merging, interactive SVG animations with cloud TTS, the 247+62+46 automated test suite, full multi-platform packaging (including a standalone Android APK bundling Node.js + SQLite and native NAS packages), and continuous community issue resolution.

Engineering Area Implementation & Delivery Highlights
AI Engineering Unified BaseAIProvider abstraction supporting 10+ global and domestic providers (OpenAI Chat & Responses API, Anthropic, Google Gemini, Azure, MiniMax with OAuth login, DeepSeek, Kimi, Qwen, Zhipu GLM, StepFun, Doubao, SiliconFlow, and local Ollama); role-based routing for vision vs. text, automatic primary/fallback switching, and short-transaction atomic daily quota reservation
AI Application Loop Photo, clipboard, and whole-PDF scanned import (with cross-page question merging and answer-page extraction), handwriting cleanup and figure region re-rendering (with XML validation and side-by-side verification), LaTeX repair, step-by-step SVG blackboard animations synchronized with cloud/local TTS, curriculum knowledge trees, 1/2/4/7/15/30-day Ebbinghaus review scheduling, variation grading, parallel A/B exam generation with adaptive spacing and DOCX export, and an MCP Server
Software Engineering Next.js 16 + React 19 + TypeScript (strict) + Prisma 5 + SQLite (WAL); backed by 247 unit test files, 62 integration test files, and 46 Playwright E2E spec files (with deterministic mock-AI pipelines), vitest --coverage thresholds, zero-warning ESLint enforcement, and versioned JSON backup format (v15) round-trip tests
Security Governance Automated PR and weekly CodeQL scanning across javascript-typescript, java-kotlin, and actions; Zod schema validation, Prisma parameterized queries, server-only runtime boundaries, withUser / withAdmin real-time auth wrappers, sanitized production logging, and pre-push history leak checks (check-public-history.py)
DevOps & CI/CD Full GitHub Actions pipeline (ci.yml, packages.yml, build-docker.yml, release.yml) covering multi-arch Linux amd64/arm64 container builds, Windows SignPath signature validation, and automated changelog/release publishing
Product Delivery Frictionless multi-platform distribution: Docker / GHCR images, global npm CLI, Electron desktop apps (Windows / macOS / Linux), a standalone offline Android APK bundling Node.js + SQLite, and native NAS packages with embedded images for fnOS (FPK), Synology (SPK), and QNAP (QPKG)
Open Source Ops High-cadence releases driven by parents, teachers, and developers (v2026.11.11 → v2026.11.15 → v2026.11.19), traceably linked via GitHub issues (Refs: #issue) alongside synchronized bilingual README and Wiki documentation

Project links: GitHub Repository · Website · Live Demo · From Hack to 500+ Stars · Family Learning Loop

AI-Native Engineering · AI Coding Delivery Workflow

I treat AI coding not as one-shot code generation, but as an engineering delivery pipeline governed by explicit contracts, scoped context, and automated acceptance gates. Engineers own problem framing, architectural constraints, task decomposition, and final verification; coding agents accelerate implementation and test coverage inside those guardrails.

Delivery Stage Engineering Practices & Quality Gates
Requirements Clarify user pain points, backward-compatibility constraints, explicit non-goals, and testable acceptance criteria before coding
Technical Design Define schemas, API contracts, task state machines, data-preserving migrations (PRESERVE_EXISTING_DATA), and backup-format sync points up front
Context Management Encode architecture rules, module boundaries, i18n parity, and import/export checklists in repository-level AGENTS.md to curb agent drift
Task Decomposition Split work into atomic, verifiable increments across data contract → provider/business logic → UI → automated tests → docs
AI Coding Pair Claude Code and Codex by module responsibility while strictly enforcing server-only boundaries and repository conventions
Quality Control Human architecture & edge-case review + zero-warning lint + unit / integration / Playwright E2E suites + coverage gates — never weakening assertions
Security Control Least-privilege design, pre-push secret/internal-host leak checks (check-public-history.py), CodeQL analysis, and lockfile registry audits
Product Delivery Automated multi-platform packaging and multi-arch container builds, paired with synchronized bilingual docs, Wiki, and changelogs

Case Study: Whole-File Scanned PDF Import & Cross-Page Merging

In v2026.11.19 of wrong-notebook, a flagship feature — importing an entire scanned PDF as a single recognition batch, merging split questions across pages, and extracting answer-key pages automatically (38 files changed in one coordinated delivery) — went end-to-end through this workflow:

  1. Requirements & Guardrails: Eliminated manual page-by-page screenshotting for full exam PDFs, while enforcing an explicit constraint that AI outputs enter a batch review queue before database persistence and never break single-image uploads.
  2. Contracts & Context: Guided by AGENTS.md (BaseAIProvider contract, withUser auth guards, bilingual i18n parity), defined ImportBatch versioned server-side drafts (conditional draft -> started transition against duplicate runs), cross-page question-stitching rules, and answer-key mapping schemas first.
  3. Decomposition & Implementation: Split into PDF page-stream and region-cropping logic (scanned-pdf-flow.ts, batch-crop.ts), provider question-split extensions (question-split.ts), the batch review workspace (import-batches/[id]/page.tsx), and bilingual UI strings.
  4. Verification & Release: Shipped alongside 4 Vitest unit test suites (base-provider.test.ts, question-split.test.ts, scanned-pdf-flow.test.ts, file-import-scanned-pdf.test.tsx), API integration tests (import-batches.test.ts), and mock-AI Playwright E2E specs (file-import-pdf.spec.ts), then released across Docker, desktop, and NAS packages after human review and green CI.

Related reading: Why Accepting AI-Generated Code Matters 10x More Than Picking a Model →

Open Source & AI Infrastructure

01 · AI Video Studio (Provider-Neutral Content Pipeline)

A modular AI content pipeline (Markdown / Topic → Story Plan → Shot Manifest → TTS & Subtitles → FFmpeg Render → Social Drafts) engineered around backend reliability boundaries:

  • Task Reliability: Explicit idempotency keys, worker leases with crash recovery, and shot-manifest fingerprinting so retries reuse completed shots without duplicate spend.
  • Pluggable Storage & Queues: Runs on local file queues, Redis multi-process queues, or PostgreSQL row-locked job queues, with artifact persistence to local storage or S3-compatible object stores.
  • Security & Release Gates: Server-side API key auth and rate limiting, allowlisted source_url fetching, dry-run default with human approval publishing gates, and MCP tool exposure.

GitHub Source & CI →

02 · AI Gateway Architecture & Governance

Separated from quota monitoring as a dedicated model-routing control plane built around self-hosted NewAPI hubs and deterministic fault-injection labs:

  • Three-Stage Routing: Hard filtering first by capability (tool calling, JSON schema, context length), region, data classification, and budget; then weighted selection by health, latency, and cost.
  • Error Taxonomy & Bounded Circuit Breaking: Bounded backoff fallback and circuit breaking apply only to transient 429 rate limits and brief 5xx outages; 401, 403, quota exhaustion, and compliance denials stop immediately to surface root causes and prevent retry storms or triple billing.
  • Context Compression: Integrates Headroom as an upstream proxy sidecar ahead of NewAPI to compress verbose agent logs and tool outputs without altering downstream contracts.

Gateway Routing & Circuit Breakers → · Self-Hosted NewAPI Model Hub → · Headroom + NewAPI Token Compression →

03 · Coding Plan Dashboard (Quota & Cost Observability)

A self-hosted single-pane quota and cost tracker across 7 AI coding plans (Codex, Volcengine, Kimi, MiniMax, LongCat, Qianwen, Google AI) built with Python, a zero-build single-file UI, and Docker:

  • Security Boundaries: Parses imported curl commands server-side and replays requests via standard HTTPS libraries (zero shell execution), enforces a strict host allowlist against SSRF, and stores local snapshots under chmod 700 host directories.
  • Provider Integration: Supports Volcengine HMAC-SHA256 V4 signing, Kimi OAuth RefreshToken rotation with persistence, NewAPI Codex channel merging, and non-destructive error notices preserving the last valid snapshot.

GitHub Source → · Architecture Walkthrough →

04 · Margrop Labs (Reproducible Engineering Labs)

Turns incident diagnosis, observability, and AI infrastructure patterns into interactive, reproducible web labs (Astro + TypeScript + Preact Islands / Cloudflare Workers) built around deterministic cores, synthetic-first demos, and bounded AI spend.

GitHub Source → · Live Labs (lab.margrop.net) →

05 · Self-Hosted & Infrastructure Tooling

Observability & Reliability · Production Recovery

Production systems earn trust not on happy-path demos, but when dependencies degrade, queues redeliver, and latency spikes:

  • Four-Signal Evidence Chain: Correlating business state (MySQL), time-series metrics (Prometheus), structured logs (Loki / ELK), and unified trace_ids — exposed to agents strictly via read-only MCP bridges for triage without write escalation.
  • Truthful Release Gates: Separating COMPLETED, DENIED (correct policy block), WAITING_APPROVAL, and FAILED outcomes so raw success-rate percentages never mask security bypasses or silent retries.
  • Backend Troubleshooting: P95/P99 latency analysis, retry storms, message backlogs, worker crash idempotency (leases, fencing tokens, outbox), lock-free MySQL online DDL, and JVM off-heap memory profiling with gperftools.

Related practice: MySQL, Prometheus, Loki & Grafana with Agents → · ELK + MCP Automated Triage → · AI Platform Release Gates → · Java Off-Heap Memory with gperftools →

Multi-Agent Shared Memory · State Hub

WoClaw provides a shared state and collaboration hub across heterogeneous coding agents (OpenClaw, Codex, Claude, Gemini):

  • Layered State & Routing: Separates real-time coordination (Topics with @agent directed routing), durable facts (Memory), and auditability (History / Search / Versions) behind unified WebSocket, HTTP, and database boundaries.
  • Lifecycle Gates: Enforces deterministic checks for scope, source trust, version supersession, and TTL expiration so stale facts cannot silently corrupt downstream actions.

Related writing: WoClaw Multi-Agent Shared Memory → · Structured Memory Lifecycle →

Engineering Labs & Writing

Long-form engineering notes and reproducible troubleshooting logs across five core themes:

Engineering Principles

  • Reliability First: Define identity, permissions, timeout budgets, idempotency keys, circuit breakers, and rollback paths before scaling features.
  • Security & Least Privilege: Keep secrets out of repositories and logs, validate schemas strictly, default to read-only access, and bind high-risk approvals to canonical parameters.
  • Maintainability & Explicit Contracts: Prefer explicit state machines, versioned APIs, structured logs, and repository guardrails (AGENTS.md) over implicit conventions.
  • Evidence-based Engineering: Prove correctness — whether human-written or AI-assisted — with reproducible tests, coverage gates, observability signals, and postmortems rather than plausible output.

Last updated: November 25, 2026 · Personal engineering portfolio, representing individual technical work only.

Views --