ek.Elisey Kochura
Selected work

Case study 05 / Full-stack / Product

3D Printing Service MVP

A Next.js application connecting public service pages, content administration, PostgreSQL models and local image processing.

MY ROLE
Full-stack implementation & verification
CONTEXT
Full-source MVP · database-free local demo
FOCUS
Next.js / TypeScript / Prisma / PostgreSQL / Sharp

Overview

A full-stack website for a local 3D printing service: public service and portfolio pages, an administrator interface, validation, image processing and database models. The complete MVP source is public.

A database-free local demo and CI are verified. There is no verified public application deployment, and the project is not presented as production-ready.

Problem

Service information and portfolio content need to remain consistent between the public pages and the administrator workflow. Image uploads also cross validation, filesystem and database boundaries, where partial failure needs careful handling.

My Role

My work covers the application structure, public/admin pages, server-side validation, Prisma models, image processing and verification. I use AI-assisted development and review the resulting interfaces, failure cases and tests.

The recent review isolated an upload-path boundary bug, added regression tests and integrated compatible dependency updates with a repeatable CI workflow.

Architecture

Next.js pages and server actions share validated data boundaries. Prisma connects to PostgreSQL; Sharp converts accepted images into local WebP variants. Public pages read portfolio content and expose SEO metadata.

The diagram describes application responsibilities. It does not represent a deployed production topology or a transaction spanning database and image files.

Engineering decisions

Keep one application for public content and administration while enforcing validation on the server. Image type and size checks precede re-encoding, and stored paths are constrained to an explicit root.

Use the existing unit suite and a minimal CI workflow to make changes repeatable. The dependency gate blocks critical advisories while reporting the remaining high findings.

Problem
A file path sharing the upload directory name is not necessarily contained within it.
Decision
Resolve against the upload root and validate the relative path instead of a text prefix.
Reason
The boundary can reject parent and sibling escapes while preserving valid contained paths.
Trade-off
This is lexical containment; symlinks, authenticated upload integration and file/database recovery need further checks.

Engineering Challenges

A textual startsWith check accepted an absolute sibling directory sharing the upload root prefix. The correction uses path.relative and five focused regressions for valid and escaping paths.

Writing image files and inserting a database record are separate operations. Orphan cleanup and recovery after partial failure remain integration work; a passing fallback demo does not resolve that problem.

Implementation

Public/admin routes, Prisma schema, authentication/CSRF helpers, Zod validation and the Sharp pipeline are available in the repository. The code evidence below shows the actual published storage helper.

PR #2 adds lexical path containment and its tests. PR #3 updates compatible dependencies and adds clean install, generation, lint, typechecking, unit tests, build and a critical-advisory audit gate. Neither PR deploys the application.

Testing & Validation

Current main has 21 passing unit tests and successful GitHub Actions. The recent local acceptance includes five focused containment tests, lint, TypeScript, Prisma generation and production build.

Eight built fallback routes were checked at mobile and desktop widths, without page errors or horizontal overflow. PostgreSQL migration/seed, authenticated admin writes, image-upload integration and Docker build were not exercised.

The dependency audit recorded on 10 October 2026 reports eight high package entries and zero critical; omit-dev still reports three high. The documented tooling/config preconditions and remaining risk are not a clean security audit.

Results

A reproducible full-source MVP with current automated checks, an explicitly tested path boundary and clear integration limits. The code, tests, workflow and two accepted fixes can be independently reviewed.

Lessons Learned

Containment is a filesystem relationship, not a string prefix. Write negative tests that demonstrate the original failure before relying on the correction.

Build, unit, browser and security checks answer different questions. Keep their limits visible, especially around authentication, durable storage and uploads.

Code evidence

Containment uses a relative path

Resolve against the upload root, then reject parent escapes and paths on another root. A sibling sharing the same text prefix no longer passes.

typescript
export function safeUploadPath(relativePath: string) {
  const root = uploadRoot();
  const full = path.resolve(root, relativePath);
  const relative = path.relative(root, full);
  if (relative === ".." || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative)) {
    throw new Error("Invalid upload path");
  }
  return full;
}

Five focused containment regressions and the full 21-test suite pass. This is lexical containment; symlink policy and authenticated upload integration are not established by these unit tests.

View complete example on GitHub (opens in a new tab)
NEXT PROJECT

Interrogation Mode

Open source / Developer tooling