Skip to content
All projects
Backend & APIOpen source

MangaSokağı: Type-Safe NestJS & Prisma Backend Architecture

A modular NestJS REST API engineered on strict dependency injection (DI) and end-to-end type safety, serving as the core transaction engine for the MangaSokağı e-commerce platform.

Tech stack

Languages
Frameworks & libraries

Performance & metrics

  • Optimized memory allocation achieved by leveraging NestJS's Dependency Injection (DI) to manage service instances as Singletons
  • Advanced database connection pooling and query batching managed directly by the Rust-based Prisma Query Engine
  • High-throughput network I/O sustained by offloading heavy business logic into isolated, asynchronous Service layers

Why I built it

Standard Node.js/Express backends inherently lack architectural discipline and are highly prone to spaghetti code in complex e-commerce domains due to loose typing. To handle MangaSokağı's transaction volume and data integrity, I needed to establish an enterprise-grade API layer that strictly decouples controllers from business logic while enforcing rigorous compile-time type checking.

Architecture & decisions

The system is built upon NestJS's modular architecture, distinctly isolating domains (admin, auth, category, manga, user). The security layer is enforced via auth.guard.ts, a JWT-driven Role-Based Access Control (RBAC) mechanism that intercepts requests at the lifecycle's edge. Database connectivity is managed exclusively through a globally injected prisma.service.ts. By leveraging Prisma's auto-generated client (generated/prisma), the architecture guarantees absolute end-to-end type safety from the database schema up to the HTTP response payload. The entire runtime is encapsulated using Docker for deterministic deployment isolation.

Key features

  1. 01Strict architectural decoupling of Controller and Business Logic layers (Separation of Concerns)
  2. 02Endpoint-level JWT authorization enforced by custom execution context interceptors (auth.guard.ts)
  3. 03Compile-time error catching and memory-safe database queries via Prisma ORM's auto-generated client
  4. 04Deterministic database seeding module for automated environment initialization and CI/CD pipelines
  5. 05Optimized Docker containerization for highly portable and scalable microservice deployments

Technical review

This project demonstrates an enterprise-grade backend architecture tailored for robust e-commerce platforms. Security countermeasures like the AuthGuard act as low-level interceptors, aggressively dropping unauthorized payloads before they consume controller-level memory allocation. Furthermore, the Prisma-generated client entirely eliminates human error in Data Transfer Objects (DTOs), functioning as an immutable contract that prevents backend schema refactors from silently breaking frontend components.