Create Splitwise App in Go

Ekta Garg
3 min readDec 30, 2022

--

Image Credits: https://www.livemint.com/

Splitwise is a financial management app that helps people easily split expenses with friends and family. With Splitwise, users can create expenses for things like rent, groceries, or a night out, and then specify which friends or family members are involved in the expense. The app then calculates how much each person owes and keeps track of who has paid their share.

Splitwise also has features for settling debts between users, generating reports, and integrating with payment systems such as PayPal or Venmo. This makes it easier for people to track shared expenses and ensure that everyone is paid back fairly.

To create a Splitwise app in Go (also known as Golang), you’ll need to have a basic understanding of the Go programming language, Here’s a high-level overview of the steps you might take:

  1. Design your app’s architecture. This will involve deciding how to structure your code, what packages and dependencies you’ll need, and how you’ll handle things like data storage and user authentication.
  2. Implement the app’s core functionality. This will include writing code to handle things like creating and managing expenses, splitting costs between users, and generating reports.
  3. Create a user interface for your app. This will involve writing HTML, CSS, and JavaScript code to create a web-based interface that users can interact with.
  4. Test your app thoroughly. This will involve writing unit tests and integration tests to ensure that your app is reliable and performs as expected.

Keep in mind that this is just a high-level overview, and there will be many details and challenges to address as you work on your Splitwise app. It’s a good idea to start small and gradually add features as you become more comfortable with Go and web development.

Backend of splitwise app :

The back-end of a Splitwise app is responsible for handling the business logic and data storage for the app. This might include handling user authentication, creating and managing expenses, calculating splits, and generating reports. We are going to write basic code for splitting the money but in actual implementation, you’ll have to use a database to store data such as user accounts, expenses, and payment information.

package main

import "fmt"

// User represents a user in the app.
type User struct {
ID int
Name string
}

// Expense represents an expense in the app.
type Expense struct {
ID int
Description string
Amount float64
Payers []User
Split float64
}

func splitMoney(expense Expense) []float64 {
splitAmounts := make([]float64, len(expense.Payers))
for i, payer := range expense.Payers {
splitAmounts[i] = expense.Amount / float64(len(expense.Payers))
}
return splitAmounts
}

func main() {
// Create some users.
alice := User{ID: 1, Name: "Alice"}
bob := User{ID: 2, Name: "Bob"}
charlie := User{ID: 3, Name: "Charlie"}

// Create an expense and split it evenly between the users.
expense := Expense{
ID: 1,
Description: "Dinner at restaurant",
Amount: 100,
Payers: []User{alice, bob, charlie},
}

splitAmounts := splitMoney(expense)
for i, payer := range expense.Payers {
fmt.Printf("%s owes $%.2f\n", payer.Name, splitAmounts[i])
}
}

This is just a high-level overview of the main components and technologies that might be involved in building a Splitwise app. There are many other details and considerations that would need to be addressed as part of the app’s architecture, such as security, scalability, and performance.

--

--

Ekta Garg

I love what I do! I am a software engineer from India. Working towards building women tech community. Strongly believe in women equality and empowerment. <3