Grata

Winter/Spring 2023 Industry Project

CodeLab UC Davis
5 min readJul 9, 2023

Introduction

This term, our team had the exciting opportunity to work on an iOS property management application for Grata, an innovative technology startup that is improving the renting experience for both tenants and building managers through smart home integrations, improved communication tools, and digital spaces that help tenants form their own communities.

The Team

George Berdovskiy — Project Manager

Avnoor Sidhu — Developer

Calvin Chen — Developer

Divya Raj — Developer

Ehong Kuo — Developer

Jeanine Lianne Palicte — Developer

Timeframe

February through June 2023

Tools

  • Development
    — Swift / SwiftUI
    — Alfred iOS SDK
  • Project Maintenance
    — SwiftLint
    — Git / GitHub

The Project

Our team built an iOS native version of an already existing Grata property management application on Android devices. This tool helps building managers easily pair locks to tenant units, lock and unlock units, change lock PINs, and unpair locks (as well as other minor features like unit search and basic account management).

Design

Grata generously provided us with access to their completed high fidelity designs so we had no need to create any ourselves. Below is an example of their design system, including relevant colors, fonts, and UI elements.

Development

SwiftUI and Xcode

Our application uses SwiftUI, a declarative UI framework developed by Apple for iOS, macOS, and tvOS applications. The framework uses Swift, a powerful language many developers use for software, CLIs, and servers running on Apple devices. We built the application in an IDE for Apple development called Xcode.

Architecture

Our tool uses a simple architecture, communicating with Alfred smart locks via Bluetooth and accessing Grata’s API through HTTP requests. Bluetooth commands and HTTP requests are frequently chained together to accomplish certain tasks such as setting lock PINs or unpairing the device from its assigned unit.

Project Structure

In SwiftUI projects, all files are accessible everywhere without imports, which means project structure if flexible. We chose the organization shown below. For example, we stored all of our UI components in the “Components” folder, pages in the “Pages” folder, and other elements such as classes and models in the “Helpers” folder.

Interface

SwiftUI provides many types of views that you can combine to create beautiful and responsive layouts. Several that we used most often include…

  • HStack, VStack, and ZStack (plus Spacer)
  • Text, Button, TextField, and SecureField
  • Circle, Rectangle, and Color

Navigation

We took advantage of SwiftUI’s NavigationView to implement smooth, intuitive, and performant navigation between pages. However, we replaced Apple’s standard iOS navigation bar with our own. There are three variants — large, small, and transparent navigation bars.

struct HomeView: View {
...

var body: some View {
NavigationView {
GeometryReader { geo in
VStack() {
NavigationBar()

VStack {
...
}
}
}
}
}
}

Communication With API

We created an observable object called Network to handle API calls. Observable objects are a type of SwiftUI class that notify views of data changes. This allows views to update the user interface with whatever data has been provided. Observable objects passed as environment objects to subviews are shared, so changes in one area of the application will propagate throughout every page without any additional logic.

Every view that fetches data from or sends data to the Grata API has access to this object. Network includes several variables for authentication (such as the access token) and methods for different API calls (such as retrieving units or registering locks).

class Network: ObservableObject {
// Published properties
@Published var token: Token?

// POST - Login
func login(...) {
...
}
// GET - Fetch all units
func fetchAllUnits(...) {
...
}
// POST - Change Lock PIN
func changePIN(...) {
...
}

...
}

Authentication

When the user enters their email and password, the login function is called and our application sends a POST request to the Grata API.

If the credentials are valid, we receive an access token that can be used for protected API routes. This token is stored in the Network object.

Each API call uses a completion handler to let the view know when the request is complete. In case of success, they are redirected to either the onboarding or home page.

Takeaways

Mentors Are There to Help

Weekly meetings with our mentors at Grata helped us clear blockers and avoid wasted time!

Communication Is Key

Due to the ambitous scope of the project, we had to communicate requirements, progress, and issues to each other quickly and effectively.

Follow Consistent Source Control Practices

Thankfully, we avoided many headaches involving versions and incompatible code by establishing a clear set of source control practices including consistent branch naming, informative PR descriptions following a standard template, and thorough code reviews for every pull request.

Always Code Clean and Stay Organized

When working on a large codebase with many teammates, proper organization and clean code are crucial to project success.

Challenges

Limited SwiftUI Experience

Although some of our team was somewhat familiar with SwiftUI, we relied on bootcamps, online tutorials, each other, and our mentors at Grata to learn the ropes.

Architecture Compatability

Unfortunately we had minor issues with one of the core libraries for lock control, which prevented us from using SwiftUI previews or simulator builds due to architecture incompatibility. We worked around this problem by building our interfaces in a separate project without that library and by simply building onto our devices every time interface changes were made.

Final Thoughts

We are incredibly grateful to Grata for providing us with the opportunity to collaborate with them! Moreover, we would like to give special thanks to Arjun, Harley, Matthew, Diego, and Troy. Their support and patience have been invaluable, and we couldn’t have done it without their guidance.

--

--

CodeLab UC Davis

CodeLab is a student-run software development and UX design agency at UC Davis.