How We're Building an Open-Source Google Photos Alternative with React Nativeby@ehsan6sha
1,846 reads
1,846 reads

How We're Building an Open-Source Google Photos Alternative with React Native

by FunctionlandJune 18th, 2021
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

React Native is an open-source version of React Native that uses React Native and IPFS. It is designed to decentralize file and data storage with p2p connection. It uses IPFS and IPLD, Interplanetary Linked Data, to store files in a decentralized database. The project is based on a framework that combines easy-to-use backend APIs, easy enough for an average front-end developer, and a pre-setup hardware, plug and play for a non-technical person, can fill this gap.

Companies Mentioned

Mention Thumbnail
Mention Thumbnail

Coins Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - How We're Building an Open-Source Google Photos Alternative with React Native
Functionland HackerNoon profile picture

Most of us are using Google Photos to store our valuable memories and screenshots of documents we frequently need like identification cards. This was a win-win for us as well as Google.

We could use free storage and a good application interface to access our photos at the expense of our privacy, and Google could improve its Artificial Intelligence algorithms with the feed from our photos at the expense of a free storage offer.

However, it all changed in June, when Google stopped its free service. Now it has become a loss for us, loss of privacy, loss of money and most importantly, loss of confidence in what else Google might change in future.

That was the time my friend published our draft of work for building an open-source Google Photos alternative with React Native, but it was not when we started the project.

How did it start?

It was two years ago when cryptocurrencies and blockchain were the news page highlight, yet again. Everyone was excited about the potential of blockchain for decentralizing traditional central banks, however, the news didn’t have many headlines about the work that was being done to decentralize the whole web.

At that time my friend, an AI geek, and I, a full-stack developer,  discussed this and started to search on the internet. We came across several promising projects aimed to decentralize the web and finally, after analysing many of them, IPFS and IPLD, both open-source, caught our eyes.

They seemed promising to us, since they had a mature structure and a big community of open-source developers contributing to them.

So we thought, this was great, why were people not using them instead of central storage servers? And the answer was not hard.

As we spoke to our developer and non-developer friends, it became apparent that even many developers were not aware of these projects and many non-developers did not have the technical knowledge to set them up on their computers, even though it was just a few lines of command.

Besides, there were not many applications that could connect to them or their UX were not as appealing as those developed by big-tech.

We thought a framework that combines easy-to-use backend APIs, easy enough for an average front-end developer, and a pre-setup hardware, plug and play for a non-technical person, can fill this gap and bring decentralized web to everyone’s home.

I need to mention that NAS, such as synology, although powerful,  is not what we wanted to achieve. We wanted a full application node, in other words a decentralized server, not just a file disk.

Some Background:

We joined the IPFS and IPLD community to learn more about it. After a few months we came to realize its huge potential to deliver on the promise of the decentralized web. If you don’t know what IPFS is, it stands for “Interplanetary File System”.

As the name suggests it is a file system, designed to decentralize file and data storage with p2p connection, a replacement for http protocol.

It uses libp2p toolset, implementing the same protocol that empowers Ethereum network p2p connection. IPFS also uses IPLD, Interplanetary Linked Data. If you are familiar with JSON-LD, it has the same grounds but is much more powerful, because it can link any data types with each other.

In simple words, IPFS hashes the data content and gives this hash to the user. Hash is unique per file content, meaning two files with the exact same content have the exact same hash, so it has de-duplication built-in, no “disk clean-up” needed!

Anyone who has the file hash, can find where the file is located using a decentralized hash table and connect directly to the host using “libp2p” and fetch the content. You can even create a cluster for keeping a set of nodes synchronized with each other, so that if one goes down another one can serve the file.

You can define which files your node should serve (and keep a local copy) and which ones it should not. You do not need to have a static IP or domain name to serve a file to others, which is an advantage compared to cloud services or NAS.

How did it go?

We started to use IPFS to store files in a decentralized way and IPLD as the base of our database engine. There was one shortcoming though. IPFS data can be accessed by anyone who has the hash to it.

That is not so private, right? Although IPFS has a private mode, at that time (and currently), it does not work well over the internet and is more suited for private networks. But there was another technology to cover this hole, called proxy re-encryption. This means you encrypt your data locally using your private key.

When you want to share the file with someone, you use proxy re-encryption to re-encrypt the file using the other person's public key, and announce the address of the new file on the internet.

They retrieve the encrypted file, and can decrypt it using their own private key! So you can share an encrypted file without sharing your private key.

We had all the pieces figured out, and to put them together, we needed simple hardware with all the requirements pre-installed. Then it becomes a plug-and-play node that can be used as an application server. 

  • It uses an open-source package allowing anyone to use it freely and contribute
  • It does not require any technical setup
  • It can be accessed over the internet using libp2p without any domain or static IP.
  • It can serve both files and data (database)
  • It encrypts and protects user’s data

It is modular, meaning hardware modules(towers) can be added as needed. For example, a hardware module(tower) for mining crypto, and one for additional storage can be added to the base.

The software provides easy-to-use APIs for front-end developers to build applications without having to deal with backend code

Here is what we came up with in terms of hardware design and called it “box” (initially “Black Box”, but we changed it so that it won’t be confused with an airplane appliance!) : 

Although “box” is the hardware designed to give a pre-setup option to non-tech-savvy people, anyone can install box’s server software ( a package of IPFS+IPLD+proxy re-encryption back end) on any computer, even a raspberry pi, and turn it into a “box”. 

Availability of data was also important. What if the user’s box is destroyed as a result of a flood? We thought a user should be able to own more than one “box” or share it with a family member or friend (being allowed to only access their part of files) and synchronize the content to have more than one copy of their files, in case a flood destroyed one of the boxes!

It should also be connectable to the filecoin network, a decentralized file storage network built on top of IPFS to securely store files in a network of decentralized nodes at a reduced cost, to give more safety to more cautious people.

We then thought of finding a way to enable front-end developers to jump aboard quickly and easily. Speaking of quick and easy in “programming languages” terms, Javascript was the apparent winner. A powerful and widely used language!

So we thought of Node.js as a good choice for the backend to provide APIs that can be used by front-end developers in any application, including react and react native applications. 

It was around the time Google announced it was going to charge us for Photos, and we thought it could be a good contribution as well as a showcase for this open source platform.

And to show how easy it was to develop on this backend and how useful it would be for end users, we started developing an open-source react native Google Photos alternative using react native.

It is still in active development and initial release will be in July, but we were so excited to share it as soon as we reached a working version. You can see the github here:

Where are we now?

The Photos application is the first front-end app, as an open-source replacement for Google Photos, which can connect to any backend (AWS, GCloud, Azure, other hosts, box, IPFS network called filecoin) to store and fetch photos. We made it using react-native and typescript, and minimized using react states in it to minimize re-renders and make it as smooth as, and smoother than, Google Photos.

“box-server” is the open-source back-end that is used to store the data, synchronize data between boxes and re-encrypt and share the files with others.

It provides a javascript library to be imported in the react native application, and enables the application to directly connect to the user's box using libp2p.

“Graph” is the open-source library that allows front-end developers to interface with the “box”, using a familiar package.

The code for all these are packaged in the “box” monorepo:

We plan to release the MVP working demo of “box” and Photos app, in July. By that time users should be able to try it out to store their photos and access them with the same experience they gain now from Google Photos, and get a taste of decentralized web and really owning their data.

It also allows front-end developers to see the APIs and start developing their own applications if they find it useful. If you want to read more about the idea of box, take a look at our website:

The Potential?

“box” idea can be a step forward to bring decentralized web to everyone’s home, and at least partially, replaces traditional big-tech services with their corresponding decentralized version. Web3.0 frees the internet from the control of a few corporations and gives the control of data back to users. 

“box” can turn into your “Loyal Agent”. If Netflix wants to suggest movies to you, they do not get your information. You store your information on your own box and install the movie suggestion application provided by the community (it can even be Netflix itself). Netflix connects to your box and sends a list of movies it has. “box” processes Netflix data, cross checking it with your data and suggests the movies to you. No data goes out of your box to Netflix, but it still allows you to get personalized movie suggestions or to share whatever you want with whoever you want in an encrypted and safe way.

But if it is FREE, how is it sustained? Developers who jump aboard need to eat too!

Like current web experience, there would exist many free applications, and paid ones too. Users can choose to install a mining module(tower) on their box, so that it mines crypto and keeps it for them.

Then,if the developer of an application sets a price for the application they develop, box pays the price with the mined currency, instead of paying Google, or any corporation, with our private data and attention for ads.

Moreover, it allows the developers to customize applications for their own box and share this customized(and probably feature-rich) version of the application with friends and family.

In this path, we would love to have the developers’ community support. You can check out our GitHub repository to let us know your comments.

Eagerly looking forward to hearing your comments! Please do not hesitate to leave constructive feedback or bash the whole idea to the ground! Only in common wisdom shall we thrive, no one soul knows all, most definitely not the noobs who started this :) -- Love and peace, Functionland