The Story Behind FamPay's Tech Stack๐
It would be an understatement to say that your tech stack makes or breaks the project. Not only does a tech stack determine the kind of app that the team will be able to build in the end, but it also directly impacts the efficiency with which the developers build it. Thus, it was imperative for the core team at FamPay to curate an effective yet dynamic tech stack.
Hello there, I am Pratik, a Backend Engineer at FamPay. I, along with the tech team, work on building the FamPay App for Gen Zs, such that they have a smooth, safe and spectacular experience. At the end of the day, we are problem solvers bringing forth the best solutions. And this, the Tech Stack, is at the foundation of all these solutions.
When the Founding team started working on building FamPay, the core team had experience in building backend with Django and Android app. We choose what weโre most comfortable with and knew itโs a scalable framework as it was used by Instagram (till ~2005), Pinterest, Disqus, Creative Commons.
Languages
Python - Most of the backend code is in python, Python's design philosophy emphasizes code readability with its notable use of significant indentation. Additionally, we use static code checking tools like flake8, black, isort to have consistent patterns. Now you can even code in notepad and still, that wonโt break PEP8 guidelines xD.
Java - Mostly used by Android App, Java is a High Level, class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible.
Kotlin - Kotlin is a cross-platform, statically typed, general-purpose programming language with type inference.
Swift - Swift is a general-purpose, multi-paradigm, compiled programming language developed by Apple Inc. and the open-source community.
JavaScript - JavaScript (JS) is a lightweight, interpreted, or just-in-time compiled programming language with first-class functions. While it is most well-known as the scripting language for Web pages, many non-browser environments also use it, such as Node.js and Apache Couch DB. JavaScript is a prototype-based, multi-paradigm, single-threaded, dynamic language, supporting object-oriented, imperative, and declarative (e.g. functional programming) styles
GoLang - Go is an open source programming language that makes it easy to build simple, reliable, and efficient software. We use gokit here as Go kit fills in the gaps left by the standard library, and makes Go a first-class language for writing micro-services in any organization. To avoid writing lots of boilerplate code we use truss to make life a bit easier.
Frontend
โก๏ธ Website
We are using Next.js deployed on EC2 (pm2 and Nginx) to power our frontend. You don't need to take care of bundling and get server-side rendering for free with code splitting and other features free. We're using PM2 as a process management tool. It automatically restarts services if they fail.
๐ค Android
The FamPay android app is a native application built using Java/Kotlin and modern android frameworks. We use Retrofit + RxJava as our network framework. Since the app is ever growing and we need to test various new features rapidly, we have implemented some good solutions like changing servers on the fly within the app itself, or having a live log of all api calls using Chucker. With more than 2 million downloads, we had to make the app air tight in terms of payment security and also think of redundancies if something goes wrong.
๐ iOS
iOS app is built on Swift/SwiftUI/Combine. We have ported some views from UIKit to SwiftUI. Since the app is ever growing and we need to test various new features rapidly, we have implemented some good solutions like changing servers on the fly within the app itself.
๐งถ Web Apps / PWA
PWA is the primary web view build using HTML, CSS, JS with React JS Library which has multiple routes pointing multiple sections in the app like QNA, Rewards, Merchandise Checkout, IPL, etc. Build for rapid development and deployment on the fly, using the flexibility to run on both Android and iOS as a web view inside and the ability to update like a website, it greatly increases gamification speed of Fampay.
Backend
Frameworks
๐ฟ Django + Django Rest Framework
All backend parts are written in Python using Django and DRF. Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design. It takes care of much of the hassle of Web development, so you can focus on writing your app without needing to reinvent the wheel. To create REST APIs for the frontend we use DRF which makes it easy to create complex JSON objects.
๐ Celery
Celery is a simple, flexible, and reliable distributed system to process vast amounts of messages while providing operations with the tools required to maintain such a system. Itโs a task queue with a focus on real-time processing, while also supporting task scheduling. Celery workers get spawned via supervisord and they are using the eventlet worker pool for better concurrency.
Databases
๐ฆฃ PostgreSQL
We have highly relational data so choosing RDBMS was an obvious choice, Django has really good ORM support for Postgres as well. We heavily rely on its transactional properties. We are using PostgreSQL to store most of the data. It's deployed via AWS RDS - Postgres managed service.
๐ซ Redis
You may have heard of it as the key-value in-memory database but itโs the Swiss Army Knife of NoSQL databases. Redis provides data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs, geospatial indexes, and streams. Redis has built-in replication, Lua scripting, LRU eviction, transactions, and different levels of on-disk persistence, and provides high availability via Redis Sentinel and automatic partitioning with Redis Cluster. We use AWS ElastiCache to run Redis in cluster mode.
๐ MySQL
Many Open Source services we use requires MySQL as the database engine. This is also deployed using AWS RDS.
Analytics
๐ค Segment
Segment collects events from your web & mobile apps and provides a complete data toolkit to every team in our company. It's the single source of truth for all app events.
๐ฅท Metabase
Metabase is the fastest, easiest way to share data and analytics inside your company. We can connect many DB sources and it creates beautiful graphs for us. It makes it easy for a non-technical persona to ask questions about data. Using its alert feature we get notified if something is wrong with the data or application. Like successful transactions rate or any failure with external services.
๐ค MixPanel
MixPanel is a great product analytics tool to understand user behaviors, segment integration with mixpanel pushes data there.
๐ PostHog
PostHog provides analytics with auto-capture, session recordings, feature flags, heatmaps, and more. In a single product, you can host yourself (open source).
๐ฆ Retool
Retool is another great alternative to Metabase, We use this for specific features that are not available in metabase. We can set up a webhook here which helps in automation.
Automation
๐งต WebEngage
WebEngage helps us craft contextual and personalized campaigns to engage our users through Push Notifications, In-app Messages, SMS, Web Push, Emails, WhatsApp, Facebook.
๐ค N8N
n8n is a fair-code licensed extendable workflow automation tool, you can automate all kinds of the mundane processes using this as we live in API world you can connect pretty much anything. For example checking the CoWin website if a vaccine slot is available and if it is then notify you via slack, email, SMS, etc.
Observability
๐ฉ Sentry
Sentry can help you fix that nasty bug that comes once in blue moon. Its application monitoring platform helps every developer diagnose, fix, and optimise the performance of their code. We are using self-hosted sentry on a large EC2 instance but you can check out their SAAS version as well.
๐ Elastic Search
ElasticSearch is a distributed, free and open search and analytics engine for all types of data, including textual, numerical, geospatial, structured, and unstructured. We push our Nginx and some external API call logs here. This is also self-hosted on EC2 by one of our interns. Yes, you read that correctly.
๐ฅถ Kibana
Kibana is a data visualization and management tool for Elasticsearch that provides real-time histograms, line graphs, pie charts, and maps. This goes hand in hand with elastic search ๐คท .
๐ป Fluentd
Fluentd is an open-source data collector for a unified logging layer. Fluentd allows you to unify data collection and consumption for better use and understanding of data. Instead of using Logstash, we opted for this as fluentd provides a better queuing mechanism and lower memory footprint other than that there are more plugins available for fluend.
๐ฝ NewRelic
NewRelic provides detailed insights on how your application running in production. You can visualize, analyze, and optimize our entire software stack from One place,
Dev Ops
๐๐ผโโ๏ธ GitLab CI
GitLab CI helps us integrating static code analysis tools and the Django test suite. We use black, isort, flack8 for static code analysis, so we don't need to comment about line limits, import order, or code formatting. Anyone can use any editor and in the end, everyone's code will look the same. Same for the GoLang microservice.
๐ณ Docker
Docker takes away repetitive, mundane configuration tasks and is used throughout the development lifecycle for fast, easy, and portable application development. Most of codebase is containerised so it can run anywhere.
๐ AWS ECR
Amazon Elastic Container Registry (ECR) is a fully managed container registry that makes it easy to store, manage, share, and deploy our container images and artifacts anywhere. As we're using docker we needed a place to store private images so what could be better than ECR which tightly integrates with other AWS services.
๐ช Amazon Elastic Beanstalk
AWS Elastic Beanstalk is an easy-to-use service for deploying and scaling web applications and services developed with Java, .NET, PHP, Node.js, Python, Ruby, Go, and Docker on familiar servers such as Apache, Nginx, Passenger, and IIS. All of our core services are containerised and deployed using Beanstalk.
๐ฆ Nginx
Nginx is a high-performance web server that can also be used as a reverse proxy, load balancer, mail proxy, and HTTP cache. We mainly use it as a reverse proxy in front of open source projects, next server, python WSGI server. It handles SSL and sending responses to the clients.
๐ช Gunicorn
Gunicorn 'Green Unicorn' is a Python WSGI HTTP Server for UNIX. It's a pre-fork worker model. We observed that most of our traffic is IO bound so we changed its worker pool to gevent and monkey patched psycopg.
๐ง Traefik
Traefik is a leading modern reverse proxy and load balancer that makes deploying micro-services easy. This helps us in setting up development environment. We follow git flow model so each feature branch should be tested independently by dev and QA team. It routes to different django servers based on CNAME.
๐ Pulumi
Pulumi helps adopt infrastructure as code automation, combined with tried and true software engineering practices. One of the projects we are working on is to create a data pipeline and data warehouse. We are leveraging this to create and destroy AWS infrastructure. We recommend using TypeScript even though it supports Python and GoLang.
๐ Hey
Hey is a tiny program that sends some load to a web application. Gives a nice latency distribution summary.
Infrastructure
As you might have expected we are full-on AWS shop. Everything is deployed on AWS.
- EC2 - The basic building block of cloud computing.
- S3 - All of the assets required for the app to function.
- RDS - All of the user data. We have postgres, mysql instances with read-replica in private VPC.
- ElastiCache - Redis cluster with read-replicas for DB cache and rate-limiting.
- Lambda - External services integration.
- CloudFront - CDN for Application assets
- SNS - As part of service where Lambda (Producer) โ SQS โ SNS โ Lambda (Consumer)
- SES - Simple Email Service used in Listmonk, Metabase, etc.. wherever we needed SMTP creds.
- API Gateway - Managing REST endpoints for external services
- SQS - Bridge between multiple services like Lambda functions.
- Route53 - Domain management and DNS based load balancing for db replica group.
- Athena - To query over Nginx logs
- CloudWatch - For monitoring all the infrastructure and alerts
- Firebase Remote config - Dynamically changing user flow and some dynamic values.
- Firebase Realtime Database - For Dynamic information where realtime sync is required.
- Firebase Dynamic Links - URL shortening.
- AWS Beanstalk - Deploying and scaling containerised apps.
- Chatbot - To receive infra alerts from cloudwatch on slack.
- IAM - To manage access policies.
Deployment
As we use beanstalk to deploy a new version of the app all we need to do is create an image, push it to ECR, and refresh the beanstalk stack. We have developed shell scripts to do this in one go. Some independent application where we don't need auto-scaling, It's just simply doing ssh and doing your thing. There is the scope of lots of improvement like using terraform + terragrunt or pulumi to manage the infra and granular IAM policies.
OSS
๐ป Ghost
Ghost is designed for ambitious, professional publishers who want to actively build a business around their content. We use it for publishing blogs and sending newsletters to subscribers. There are built-in XML sitemaps, Google AMP pages, canonical tags, optimised URLs, Facebook Open Graph tags, support for Twitter cards and clean semantic markup for better SEO. Ghost is really fast, you can get >95% score on google page speed easily. We have self-hosted this on EC2.
๐ฎ MailCow
Mailcow is a free, open source software project. A Mailcow server is a collection of Docker containers running different mail server applications This is the internal mail server for specific needs.
๐ ListMonk
ListMonk is a self-hosted newsletter & mailing list manager. We use this for marketing and informational purposes.
๐พ OAuth2-Proxy
A reverse proxy and static file server that provides authentication using Providers (Google, GitHub, and others) to validate accounts by email, domain, or group. OAuth2 proxy adds an authentication layer in between for projects like ListMonk and N8N
Conclusion
There are some key takeaways that the core team has realized through the journey:
- Choose a tech stack that you are most comfortable with.
- Picking the right tool for the right job is equally important.
- If you are facing a problem there is a good chance that an open-source solution exists for it.
- Go with the solution that works now and easily modifiable when required. We like to keep things simple.
- Automate business processes and repeating workflows.
- Consult with an expert when in doubt.
Keeping these things in mind will help you lay a solid and thoughtful foundation when you begin developing a project. It only makes things easier if critical thinking and decision-making have been done beforehand when choosing from the plethora of options available. However, in the end, experimentation and dynamism is key to arranging your tech stack.
Found this article interesting and want to share your insights? Drop in an email at pratik@fampay.in!