Slide 1

Slide 1 text

Copyright © 2020 Present ANDPAD Inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 rails stats で紐解く ANDPAD のイマを支える技術たち 株式会社 アンドパッド 開発本部 執行役員 佐藤竜之介

Slide 2

Slide 2 text

tricknotes アンドパッドでは事業成長を推進するための開発組織づくりや技術基盤整 備を進めています。 既存製品の開発全般 + プラットフォームを管掌。 好きな仕事は課題解決。趣味でOSSを少しやっています 自己紹介 Confidential Copyright © 2020 Present ANDPAD Inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. 無断転載・無断複製の禁止 佐藤 竜之介 Ryunosuke Sato 
 
 株式会社アンドパッド 開発本部 執行役員

Slide 3

Slide 3 text

現場の効率化から経営改善まで一元管理できる 建設DX プロジェクト管理サービス

Slide 4

Slide 4 text

Copyright © 2020 Present ANDPAD Inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. 無断転載・無断複製の禁止 Confidential 事業概要 4 サービス概要

Slide 5

Slide 5 text

Copyright © 2020 Present ANDPAD inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. 無断転載・無断複製の禁止 アンドパッドのプロダクト開発の背景 ● アンドパッドではマルチプロダクトでプロダクト開発を行っています ○ 多くのプロダクトが相乗りするモノリス (Rails) ○ 個別のプロダクトごとのリポジトリ (Rails / Go) ○ プロダクトごとの Web フロント・アプリのリポジトリ ● 各プロダクト開発チームごとの意思決定を行っています ● 横断施策を実施するチームもあります

Slide 6

Slide 6 text

Copyright © 2020 Present ANDPAD inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. 無断転載・無断複製の禁止 アンドパッドのプロダクト開発の背景 ● アンドパッドではマルチプロダクトでプロダクト開発を行っています ○ 多くのプロダクトが相乗りするモノリス (Rails) ← 今日はここの話 ○ 個別のプロダクトごとのリポジトリ (Rails / Go) ○ プロダクトごとの Web フロント・アプリのリポジトリ ● 各プロダクト開発チームごとの意思決定を行っています ● 横断施策を実施するチームもあります 本日はモノリスの話を扱います。 「モノリス上で各チームが独立した意思決定を行っている」という背景を 踏まえてお話します。

Slide 7

Slide 7 text

Copyright © 2020 Present ANDPAD inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. 無断転載・無断複製の禁止 01 $ rails stats 本日の話 イマを支える技術要素 02 03 今後の展望

Slide 8

Slide 8 text

$ rails stats

Slide 9

Slide 9 text

Code LOC : 38万 Code to Test Ratio: 1:2.7 => 小さくはないが、もっと大規模なアプリケーションは世の中にまだまだある => (頑張れば)全体感を掌握できる規模

Slide 10

Slide 10 text

今日の主役たち

Slide 11

Slide 11 text

Copyright © 2020 Present ANDPAD inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. 無断転載・無断複製の禁止 (余談) ※見慣れないコンポーネントが表示されているかと思いますが、  rails stats はカスタマイズ可能です

Slide 12

Slide 12 text

イマを支える技術要素 MVC

Slide 13

Slide 13 text

Copyright © 2020 Present ANDPAD inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. 無断転載・無断複製の禁止 MVC ● models ○ AR, module, Utility などを app/models に保存している ○ クラス数よりは、テーブル数は少ない ● controllers ○ 各プロダクト毎の独自領域、かつ API の提供先毎にコントロー ラーを作成しているので比率が高い(Code LOC 比率 = 1:0.69) ● services ○ 各プロダクトがそれぞれの判断で利用しているので、中身は多種 多様 イマを支える技術要素

Slide 14

Slide 14 text

イマを支える技術要素 有名どころのgem

Slide 15

Slide 15 text

Copyright © 2020 Present ANDPAD inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. 無断転載・無断複製の禁止 イマを支える技術要素 有名どころのgem ● ActiveDecorator ● Sidekiq ● CarrierWave そこそこ込み入った活用をしている部分がありますが、本日は割愛します

Slide 16

Slide 16 text

Copyright © 2020 Present ANDPAD inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. 無断転載・無断複製の禁止 イマを支える技術要素 アンドパッド独自の仕組み

Slide 17

Slide 17 text

Copyright © 2020 Present ANDPAD inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. 無断転載・無断複製の禁止 イマを支える技術要素 アンドパッド独自の仕組み ● Rubocop ○ コーディング規約、セキュリティ観点など、モノリス横断でルー ルを強制したい場合に利用 ○ 歴史ある部分の近代化改修にも用いられる ○ 該当コード全てを auto correct し、以降の導入を禁止するという 用途 ● Rack Middlewares ● Monkey Patches ● RPCs

Slide 18

Slide 18 text

Copyright © 2020 Present ANDPAD inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. 無断転載・無断複製の禁止 イマを支える技術要素 Rubocop 例

Slide 19

Slide 19 text

Copyright © 2020 Present ANDPAD inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. 無断転載・無断複製の禁止 イマを支える技術要素 Rubocop 例

Slide 20

Slide 20 text

Copyright © 2020 Present ANDPAD inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. 無断転載・無断複製の禁止 イマを支える技術要素

Slide 21

Slide 21 text

Copyright © 2020 Present ANDPAD inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. 無断転載・無断複製の禁止 イマを支える技術要素 アンドパッド独自の仕組み ● Rubocop ● Rack Middlewares ○ モノリス横断でのセキュリティ対策、リクエスト全てを対象にし たログ出力で利用 ○ Array#each の中など、あるリクエストに対して複数のログが出 力される場合の省エネ処理 ● Monkey Patches ● RPCs

Slide 22

Slide 22 text

Copyright © 2020 Present ANDPAD inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. 無断転載・無断複製の禁止 イマを支える技術要素

Slide 23

Slide 23 text

Copyright © 2020 Present ANDPAD inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. 無断転載・無断複製の禁止 イマを支える技術要素 アンドパッド独自の仕組み ● Rubocop ● Rack Middlewares ● Monkey Patches ○ やむをえない事情による gem の拡張置き場 ○ 歴史的なもの、先のバージョンの変更を取り込んだもの、仕方が ないもの、本当に仕方がないもの、etc ● RPCs

Slide 24

Slide 24 text

Copyright © 2020 Present ANDPAD inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. 無断転載・無断複製の禁止 イマを支える技術要素

Slide 25

Slide 25 text

Copyright © 2020 Present ANDPAD inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. 無断転載・無断複製の禁止 イマを支える技術要素 アンドパッド独自の仕組み ● Rubocop ● Rack Middlewares ● Monkey Patches ● RPCs ○ 別プロダクトからモノリスのデータを取得するための gPRC サー バ ○ モデルをアプリケーションと共有し、モノリスから他のプロダク トに対してのデータを公開している。絶賛開発中 ○ 社内名称「Tsugite」(つぎて)

Slide 26

Slide 26 text

Copyright © 2020 Present ANDPAD inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. 無断転載・無断複製の禁止 イマを支える技術要素

Slide 27

Slide 27 text

Copyright © 2020 Present ANDPAD inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. 無断転載・無断複製の禁止 イマを支える技術要素 テスト ● RSpec / FactoryBot を利用 ○ データ構造が複雑なため、factory に名前を付けて生成データを 管理している ● Code to Test Ratio: 1 : 2.7 ○ 手に乗るくらいのアプリだと、1 : 0.5 前後(※) ○ 業務アプリ、かつ規模が大きいと 1 : 3 前後(※) ※ 話者の主観です

Slide 28

Slide 28 text

$ rails stats (Assets)

Slide 29

Slide 29 text

Copyright © 2020 Present ANDPAD inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. 無断転載・無断複製の禁止 イマを支える技術要素 Assets ● 主に創成期に書かれた Sprockets 管理の JS / CSS が中心 ● ゆるやかにエンハンスを行っているが、各プロダクトでの共通部分が 多いためなかなか整理が進められてこなかった JavaScript ● https://github.com/sergii/vite_rails でビルドしているファイル群 ● Webpacker からの移行先として選定

Slide 30

Slide 30 text

Copyright © 2020 Present ANDPAD inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. 無断転載・無断複製の禁止 ここまでのまとめ ● プロダクト開発チームそれぞれで意思決定できる部分ほど、いろいろ なコンテキストが入り整合性を取るのが難しくなる(Service, Assets, etc) ● 「横断的に導入した部分」 = 「プロダクト開発チームの技術判断と直 行する部分」は枠組みとして機能しやすい => プロダクト開発チームでの技術的意思決定の裁量を増やすため、構造 的な整理を進めていく価値が大きい

Slide 31

Slide 31 text

今後の展望 ● 共通部分の分割し、プロダクト開発チームの責任範囲に揃える ○ アプリケーションプロセスの分割まで踏み切るかの意思決定は遅 延させる ○ まずはプログラムの構造としての分割 ■ モジュラモノリスの導入 (packwerk 検討中) ■ assets の分割 ● 別プロダクトとの I/F の強化 ○ モノリスであるよさを元に、プロダクト間連携に秩序を導入する 歴史ある部分と改善の進んでいる部分、どちらもひっくるめて ANDPAD を育てていきます。 今後の rails stats の変化にご期待ください。 一緒に取り組んでくれる方、募集中!

Slide 32

Slide 32 text

Copyright © 2024 ANDPAD Inc. All Rights Reserved. We are hiring! 32 https://engineer.andpad.co.jp/ 技術スタックや募集ポジションを 掲載してます!