🔥

NEWT Architecture Evolution

2024/12/09に公開

Introduction

Hello! My name is Rodrigo Ramirez; A Senior Engineer at ReiwaTravel. I was in charge of selecting tech-stack & building NEWT Backend & Web from zero.

https://note.com/reiwatravel/n/n392a916c400a

In this Blog, I will share how NEWT scaled and improved the architecture over time.

NEWT Architecture Phases

I can define a total of five phases for the NEWT architecture. In each phase, we made different decisions based on the situation to achieve our goals.

Steps

  1. Prototyping (まず動かす)
  2. Pre-Release (リリースに備える)
  3. Post-Release (良くする)
  4. Current (チーム・サービスをスケールする)
  5. Future (進化し続ける)

① Prototyping (まず動かす)

  • Phase: 0~1
  • Goal: Create NEWT MVP
  • Priority: Initial Development Speed

🧐 Understanding what has to be created

Before building anything, we first needed to understand what needed to be created. We collaborated with team members who had domain knowledge about tour packages and, together, defined the initial scope that NEWT needed to support.

🚀 Focus on initial development speed

We prioritized the initial development speed for building the prototyping of NEWT, to achieve this we took the following decisions:

Infrastructure

We wanted to focus to build the initial MVP of our product, Production Environment was not needed yet, so we utilized Vercel as our Hosting for the API and Admin UI

Our DB was hosted on GCP, just because at that time Vercel didn’t offer an option for that.

Decisions

  • Self Managed infra
  • Vercel to Host our API and Admin UI
  • Only Staging Env.
  • DB hosted on GCP (Vercel didn’t offer that solution)

Development

We had limited resources, so we started as a monolithic app for our API, and our Backend members should be full-stack to create the API (public & private) + Admin UI.

  • Monolithic API
  • Full-Stack Developers = Unified Programming Language
    • Backend: TypeScript / GraphQL
    • Frontend: Next.JS / TypeScript / React / GraphQL

Scope

NEWT's goal was to digitalize most processes to fully automate travel agency operations. However, in the early stages, this was hard to achieve. For example, how could we get flight and hotel inventories (stock and price)? How could we automate flight and hotel bookings? We had to start by handling some tasks manually, even though we knew this wouldn’t scale in the future.

  • Reduce initial features scope
  • Make things that do not scale

Pre-Release (リリースに備える)

  • Phase: Pre-Release
  • Timeline: ~2022年4月
  • Goal: Production Ready
  • Priority:
    • Production Environment
    • Performance
    • Security

The NEWT system began development during COVID. Since the country's borders were closed, we had to wait for the right time to launch our service.

We had a release plan ready for that moment. Once the release date was set, we began preparing both the business and the system for the production launch.

🖥️ Creation of the production environment

  • We stop using Vercel for our Backend API and Admin UI, and moved it complete to GCP using terraform (IaC).
  • Build our infra in GCP Terraform
  • Prepared Github Actions to run migrations & deploy our code

🔒 Security Checks & Improvements

  • Adding Logs & Monitoring of services
  • Ordered to an external company to run a security check
  • API:
    • We ensure that no sensitive data was exposed to the client
    • We applied best practices for GraphQL security

⚡️ Performance optimizations

We conducted performance tests, the results of which revealed the following actions we needed to take:

  • Optimized Queries, added indexes
  • Fixed GraphQL N+1 issues by adding DataLoaders
  • Added DB Read replicas to distribute the load

🎉 As result, we safely released NEWT on 2022年4月

Post-Release (良くする)

  • Phase: Post-Release (First Year)
  • Timeline: 2022年4月~
  • Goal: Improve our Service/Operations
  • Priority:
    • Improve NEWT functionality
    • Expand our service
    • Process Automation

Over the following year, we focused on developing all the essential features and optimizing travel-related business operations. Here are the most notable achievements:

🧩 Improve NEWT Functionalities

  • Feedback from Customers → Improve current features
  • Develop missing core features (NEWT Point, Travel Link, …)

🌎 Expand Our Service

We released 3 websites using a micro-frontend architecture.

https://engineering.reiwatravel.co.jp/blog/newt-frontend-stack

🤖 Process Automation

Previously, our inventories were updated manually. This time, we integrated with external services to automatically fetch flight and hotel room inventories, including availability and prices. Additionally, we automated the booking process.

This required us to implement efficient fetching strategies to handle third-party API constraints, such as rate limits and other limitations.

  • Connect with external providers (Hotel & Flight APIs)
    • Inventory daily updates
    • Booking Arrangement Automations

Current (チーム・サービスをスケールする)


  • Phase: Current
  • Goal: Scale our service and product team organization
  • Priority:
    • Team Structure
    • Traffic Spike Support

During 2024 we started to face new challenges apart of regular feature development.

  1. Product Development Evolution for Organizational Scaling
  2. Data & Traffic Increase

🧩 Product Development Evolution for Organizational Scaling

Until now, we primarily operated as a single, large team with weekly release cycles. However, to further boost productivity, we aimed to divide responsibilities and enable teams to work independently on different parts of our system.

We transition from 1 team to multiple vertical teams

  • Parallel Development → Multiple Dev Environments
  • Increase Releases → Git Branch Strategy

These introduced some technical challenges to our current process:

① Test environments

Previously, we worked with only Production and Staging environments. Once the code was ready, we deployed the changes to the Staging environment, where we performed QA before releasing to Production.

However, this approach did not scale well with multiple teams. To enable parallel development for each team, we needed to provide dedicated development environments. This was essential to avoid blocking the progress or releases of other teams and to support scaling out development by dividing responsibilities across teams.

② Release Cycles

We wanted to release features as soon as they were ready, without the need to coordinate with other teams.

Action:

To address these two points, we introduced multiple development environments that teams could use freely and adjusted our branch strategy to align more closely with the trunk branch.

🎉 As a result, the backend team changed from weekly releases to multiple releases per day and successfully provided smaller and faster improvements.

😱 Data & Traffic Increase

NEWT's tour coverage was expanding steadily every month, which required us to optimize our database structure and queries to maintain the best user experience for our customer

In addition to the normal growth in customers visiting and using our service, we also experienced significant traffic spikes driven by campaigns and TV announcements.

Our system was designed to handle up to a 10x increase in traffic, but TV announcements triggered a sudden 100x increase in traffic, overwhelming our infrastructure and causing service outages.

Actions:

The main bottleneck was the performance of our tour search, which directly impacted our database. To support a 100x spike in traffic, we:

① Query Optimizations

We optimized resource-intensive queries, including tour price calculations and similar operations.

② Move Tour Search from RDB (MySQL) to Elasticsearch

We introduced Elasticsearch to deliver faster and more accurate search results, which also helped reduce the load on our database.

③ Web Caching

We implemented caching strategies for various pages, prioritizing those that don’t require real-time data or only need updates when changes are made through our Admin UI.


(*) current infra simplified


(*) current NEWT tech stack

⑤ Future (進化し続ける)

  • Phase: Next = Future Challenges
  • Goal: Prepare System to support NEWT evolution
  • Challenges:
    1. Team/Code Isolation
    2. Smarter Solutions using AI/LMM
    3. Global Expansion

📁 Team/Code Isolation

  • Reduce Code Conflicts
  • Reduce Cognitive Load
  • Isolate Data & Deployments

Currently, multiple teams are working on the same monolithic app, but the code and module structures need proper isolation. This means each team needs to understand other modules to make changes, significantly increasing cognitive load.

We are considering transitioning from a traditional monolith (tightly coupled) to a modular monolith with well-isolated modules.

steps

  1. isolate code
  2. isolate data when needed
  3. isolate deployment

🤖  Smarter Solutions using AI/LMM

Incorporate more AI/LLM into NEWT service to:

  • Deliver Better and Smarter Features to Customers
  • Optimize Internal processes

🌐 Global Expansion

With a global expansion plan for NEWT, we need to support the following functions:

  • Multi-Language
  • Multi-Currency
  • Timezone Support

🧑‍🎓 Summary

In this blog, we introduced the NEWT Architecture evolution phases:

  1. Prototyping (まず動かす)
  2. Pre-Release (リリースに備える)
  3. Post-Release (良くする)
  4. Current (チーム・サービスをスケールする)
  5. Future (進化し続ける)

https://speakerdeck.com/reiwatravel_0405/newt-architecture-evolution

We are hiring!

これからのChallengeを一緒にやりたい仲間を探していますので!
興味があればカジュア面談からでも話しましょう!

https://www.reiwatravel.co.jp/engineers

NEWT Tech Talk」のお知らせ

At Reiwa Travel, we hold monthly LT (Lightning Talk) sessions to share technical knowledge, insights, and achievements. Anyone interested in the presentation topics or Reiwa Travel can join and participate.

Next: 【Special Edition】After Startup CTO of the Year 2024 🎊
グランプリを受賞したピッチ「事業成長を導く技術戦略」の裏側を大公開します!!
https://reiwatravel.connpass.com/event/338364/

令和トラベル Tech Blog

Discussion