Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Evolving NEWT’s TypeScript Backend for the AI-D...

Evolving NEWT’s TypeScript Backend for the AI-Driven Era

As NEWT grows, its TypeScript backend is evolving from a traditional monolith into a modular, clean, and AI-assisted architecture. This transformation aims to boost development speed, maintain quality, and enable teams to release more features in parallel—laying the foundation for a truly AI-Driven Development era

Avatar for Rodrigo Ramirez

Rodrigo Ramirez

November 17, 2025
Tweet

More Decks by Rodrigo Ramirez

Other Decks in Programming

Transcript

  1. © 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
  2. 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
  3. • 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
  4. • 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
  5. • 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?
  6. 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.
  7. 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
  8. 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
  9. 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.
  10. • 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
  11. 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
  12. • 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
  13. • 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
  14. • 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