NEWT Architecture Evolution

tags
backend
advent calendar
author
category
backend
mainImage
KV_20241209 (1).png
publishedAt
Dec 9, 2024
published
published
slug
Advent-Calendar-20241209
authorDisplayName
Rodrigo Ramirez
notion image
 
💡
この記事は、「NEWT Product Advent Calendar 2024」Day6の記事となります。
 
こんにちは!「NEWT Product Advent Calendar 2024」6日目は、Senior EngineerのRodrigoが、エンジニアリングオフィスからバトンをもらい「NEWTのアーキテクチャの進化」について紹介します。ぜひ最後までご覧ください!
※ この記事は英語にて執筆いたします。
 

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.
 
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 (まず動かす)
  1. Pre-Release (リリースに備える)
  1. Post-Release (良くする)
  1. Current (チーム・サービスをスケールする)
  1. 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
 
notion image
 

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 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 adding DataLoaders
  • Added DB Read replicas to distribute the load
 
 
🎉 As result we safely released NEWT on 2022年4月
notion image
 

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.
 
  • NEWT.net → Main website, focus on Tour Packages
  • NEWT Hotel → Focus on Hotel Bookings
    • Web + Mobile App
 
notion image
 
 

🤖 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
 
notion image
 

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
  1. 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
notion image
 
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.
 
notion image
(*) current infra simplified
 
notion image
(*) current NEWT tech stack
 

⑤ Future (進化し続ける)


  • Phase: Next = Future Challenges
  • Goal: Prepare System to support NEWT evolution
  • Challenges:
      1. Team/Code Isolation
      1. Smarter Solutions using AI/LMM
      1. 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 lack proper isolation. This means each team needs to understand other modules to make changes, which significantly increases cognitive load.
 
 
We are considering transitioning from a traditional monolith (tightly coupled) to a modular monolith with well-isolated modules.
 
notion image
steps
  1. isolate code
  1. isolate data when needed
  1. 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 (まず動かす)
  1. Pre-Release (リリースに備える)
  1. Post-Release (良くする)
  1. Current (チーム・サービスをスケールする)
  1. Future (進化し続ける)
 
 
 
 

「NEWT Tech Talk」のお知らせ

令和トラベルでは、技術的な知識や知見・成果を共有するLT会を毎月実施しています。発表テーマや令和トラベルに興味をお持ちいただいた方は、誰でも気軽に参加いただけます。

【特別編】After Startup CTO of the year 2024 開催決定🎊

この度、「Startup CTO of the year 2024」にて弊社VPoE麻柄が栄えある最優秀賞を受賞しました。6分間のピッチ『事業成長を導く技術戦略』では語り尽くせなかった、プロダクト開発や組織づくりの裏側について、EMのmiisan・Senior Engineerの飯沼を交えて、パネルディスカッション形式でさらに深ぼっていきます!
 
今後も定期的に、令和トラベルの技術や組織に関する情報を発信するイベントを開催予定です。connpass のメンバー登録をしていただき、最新情報をお見逃しなく!
 

令和トラベルでは一緒に働く仲間を募集しています

この記事を読んで会社やプロダクトについて興味をお持ちいただけましたら、ご連絡お待ちしています!フランクに話だけでも聞きたいという方は、カジュアル面談も実施できますので、お気軽にお声がけください。
 

今年最後の特大セールも開催中!

NEWTでは、12/26 お昼11:59まで、2024年最後のおトクなセールを開催中です!
 

📣宣伝

次回の「NEWT Product Advent Calendar 2024」Day7は、エンジニアリングオフィスが担当します。11月に開催した「Startup CTO of the year 2024」最優秀賞受賞の裏側について、当日の様子やそこに至るまでの話などを紹介します!次回もお楽しみに!
 

# backend

# advent calendar