Slide 1

Slide 1 text

© 2023 Reiwa Travel, Inc.
 Evolving NEWT’s TypeScript Backend for the AI-Driven Era

Slide 2

Slide 2 text

© 2023 Reiwa Travel, Inc.
 Profile ● Nationality: Argentinian ● Language: Spanish, English, Japanese ● Full Stack Developer (+15y) Career ● 󰎆 2006~: Freelance ● 󰎆 2008~: PowerSite ( CTO/CEO ) ○ Email Marketing SaaS ● 󰏦 2015~: Travelience ( CTO ) ○ Tour Guide Marketplace ● 󰏦 2021~: ReiwaTravel ( Senior Engineer ) Senior Engineer / Product-Dev Rodrigo Ramirez

Slide 3

Slide 3 text

© 2023 Reiwa Travel, Inc.
 Evolving NEWT’s TypeScript Backend for the AI-Driven Era

Slide 4

Slide 4 text

NEWT Tech stack

Slide 5

Slide 5 text

NEWT Tech stack

Slide 6

Slide 6 text

Backend Stack 📆 Tech choices made in 2021 ● Language: TypeScript: ( Full-Stack team ) ● Framework: None ( Build on top of Apollo Server and Express ) ● Architecture: Modular Monolith ● Infrastructure: GCP ├ 📁modules │ ├ 📁module-A │ ├ 📁module-B │ └ 📁… └ 📄server.ts

Slide 7

Slide 7 text

We scaled from one product to multiple products Business Evolution

Slide 8

Slide 8 text

We scaled from one backend team to multiple backend teams per product Team Evolution

Slide 9

Slide 9 text

● We started with a simple modular monolithic architecture. ● Our goal was speed — deliver features fast. ● Engineers had freedom to code in their own style, following only a few basic rules. ● Now, in the AI era, about 50%+ of our code is AI-generated. How Our Backend Journey Began

Slide 10

Slide 10 text

© 2023 Reiwa Travel, Inc.
 How can we move even faster and still keep quality?

Slide 11

Slide 11 text

● AI writes code faster than we can review it. ● Manual review does not scale. ● We need rules and validation built in. ● Goal: trust AI code without checking every line. Challenge

Slide 12

Slide 12 text

© 2023 Reiwa Travel, Inc.
 Why TypeScript?

Slide 13

Slide 13 text

● Static typing → finds errors early and keeps the code safe. ● Simple, clear syntax → AI models understand and generate it easily. ● AI-friendly language → most code-generation models are heavily trained on TypeScript/JavaScript. ● Rich ecosystem → strong tools for linting, testing, type-checking, scaffolding, and automation. ● AI integrations → many frameworks and AI-agent tools are built with TypeScript. ● One language for everything → backend, frontend, mobile apps, and AI agents. ● Full-stack by default → engineers and AI can share patterns and reuse knowledge. Why TypeScript?

Slide 14

Slide 14 text

© 2023 Reiwa Travel, Inc.
 From Monolith to Monorepo

Slide 15

Slide 15 text

From Modular Monolith to Monorepo Challenges ● We used a modular monolithic architecture — good at the start, but hard to scale. ● All products lived inside one system, with no real separation. ● Modules communicate freely, without clear rules or limits. ● One single deployment — couldn’t scale or release parts independently. ● As we added more features, coupling and side effects increased. ● AI tools learned from this unclear structure, generating similar problems faster.

Slide 16

Slide 16 text

Solution ● We moved from a modular monolith to a TypeScript monorepo. ● Each product became its own application inside the monorepo. ● Shared logic lives in /packages — reusable and easy to maintain. ● /apps folder → every deployable product or service. ● Clear import rules control how apps and packages connect. ● Independent builds and deployments for each app. ● AI now understands: ○ the boundaries between products ○ where to place new code ○ and how to follow our architecture rules From Modular Monolith to Monorepo ├ 📁apps │ ├ 📁app-A │ └ 📁app-B └ 📁packages ├ 📁package-A ├ 📁package-B └ 📁core

Slide 17

Slide 17 text

We changed the directory structure to a typical TypeScript monorepo ├ 📁modules │ ├ 📁module-A │ ├ 📁module-B │ └ 📁… └ 📄server.ts ├ 📁apps │ ├ 📁app-A │ └ 📁app-B └ 📁packages ├ 📁package-A ├ 📁package-B └ 📁core Before After From Modular Monolith to Monorepo

Slide 18

Slide 18 text

We changed the directory structure to a typical TypeScript monorepo From Modular Monolith to Monorepo

Slide 19

Slide 19 text

© 2023 Reiwa Travel, Inc.
 Clean Architecture

Slide 20

Slide 20 text

Clean Architecture ● We follow Clean Architecture — a simple and common approach. ● Four layers: ○ Domain → business rules and entities. ○ Application → use cases and workflows. ○ Infrastructure → database, APIs, and external services. ○ Presentation (/apps) → entry points, GraphQL, or HTTP APIs. ● Facades connect layers and control communication. ● The AI can now work layer by layer — from core logic to presentation. ● Using known patterns helps AI understand how to build each part safely.

Slide 21

Slide 21 text

© 2023 Reiwa Travel, Inc.
 Contracts as Code

Slide 22

Slide 22 text

● TypeScript Types → model our system; AI agents use them to generate code with the right inputs, outputs, and models. ● Facade Pattern → controls how modules and apps communicate; AI follows these boundaries and respects the rules. ● GraphQL Schemas → define our APIs; we write the schema, and AI generates resolvers that follow the contract. ○ Codegen creates typed clients so backend and frontend stay aligned. ● Prisma (Schema-based ORM) → defines data structure and auto-generates correct types. ● Zod (Validation) → describes and checks inputs simply, helping AI and humans keep data safe. Contracts as Code

Slide 23

Slide 23 text

Contracts as Code

Slide 24

Slide 24 text

Contracts as Code

Slide 25

Slide 25 text

The power of Contracts Contracts as code keep humans, AI, and systems perfectly aligned. If the contracts are respected, the code inside matters less — the rules ensure correctness. Contracts as Code

Slide 26

Slide 26 text

© 2023 Reiwa Travel, Inc.
 Validation & Testing

Slide 27

Slide 27 text

● Layer-based testing strategy → each layer has its own focus. ○ Domain → business rules and logic. ○ Application → use-case and integration behavior. ○ Presentation → end-to-end and GraphQL input/output flow. ● Mocks let us isolate layers that are not the current focus. ● AI code agents build layer by layer and create tests for each part. ● TypeScript ecosystem → linters, import-rule checks, and formatters (Prettier). ● Automated AI review (agent) validates architecture rules and verifies all tests pass. ● Humans review design and intent, not low-level details. Validation & Testing

Slide 28

Slide 28 text

© 2023 Reiwa Travel, Inc.
 Results & Impact

Slide 29

Slide 29 text

● We are in progress of adopting the new AI-driven strategy. ● TypeScript is our foundation — one language for backend, frontend, and AI agents. ● Parts of the system already follow Clean Architecture and contracts as code; others are being aligned gradually. ● The goal is to have one consistent structure across the full monorepo, so AI code agents can understand and generate code consistently. ● On average, around 50% of our code is AI-generated, with some teams reaching up to 90% assisted generation. ● The system design + contracts approach is already increasing quality and speed. Results & Impact

Slide 30

Slide 30 text

● Engineers are moving from writing code to defining architecture, rules, and requirements. ● TypeScript gives us the language to express those rules; contracts, types, and boundaries that AI can follow. ● When AI-generated code fails, we don’t fix the code; we improve the rules, types, or contracts, then generate again. ○ Each iteration makes the system smarter, faster, and more consistent. ○ Our goal: a self-improving development loop; where better rules produce better code. The Human Role in the AI Era

Slide 31

Slide 31 text

Thank you!
 © 2023 Reiwa Travel, Inc.
 @xpromx