DevNTell - SurfDB

Developer DAO · 23 Sept 2022 · 27:43

Aditya Parmar presents SurfDB, a database built for dApps on top of Ceramic with a Redis cache for fast responses. He explains why existing decentralised storage options struggle as app databases, covering cost, speed and data silos, then shows smart contract access control, real-time updates, encrypted data and forkable nodes. A demo deploys an instance, creates data and uploads files through a dedicated IPFS gateway, and scaffolds a Next.js app, before closing with a call for developer feedback.

Speakers

Topics

From Developer DAO; community: Developer DAO.

Transcript

welcome to what's going to be another great Devon tell so if you didn't know Devon tell is a 30 minute window for members of the doubt to Showcase something they are passionate about or been working on it's gonna be an awesome project we've been working on demonstrating your testing best practices automation goodies smart contracts how to structure a project Etc basically if you got a passion for something this is your opportunity to share with the community and today I am happy to introduce to you Lydia who will be demoing uh the particle project take away it is here hi hi everyone uh I'm auditor and uh yeah I'm going to be showing something uh I've been working on the past three weeks so uh this is like a project I I started with the eth online hackathon

and yeah I'm pretty excited to show you all so uh I'll share my screen please let me know if it's visible yep I can see it okay yeah so uh yeah actually my project is actually served DB uh not uh particle I mean it was called particles before but then I had to Pivot yeah it's called it's called server DB now and uh server TV is basically a database made for tabs so so the problems which we are trying to solve is like uh apparently the

decentralized databases like ceramic ipfs RV even filecoin Etc like they cannot be used as a database for dapps so as a database I I mean like as a to store app data like we do in usually in mongodb and SQL so that's why like developers usually uh are using uh like web2 databases like mongodb and SQL which is not really website native and we can't have you know web3 features and another problem is that if we are using these web 2 databases we can't really store files on them so usually we uh you know use ipss to store files and ipfs again then uh

there's this problem of which provider to you so like in fura it charges like 60 400 GB and free Solutions like web free storage uh by ipfs only it's uh extremely slow because uh it's like there are a lot of people using the same API same Gateway which is like which makes it extremely slow and another issue is that some of these databases they don't have Smart contract Access Control conditions so what I mean by this is that uh ability to have read write access condition based on some on-chain uh sort of condition so like for example uh an on-champ condition could be like a agnosis a safe

owner so something like that and uh some of these databases like tableland and RV we have to pay for actually transactions so which is if you want to write some data you need to pay which is not really ideal your user experience and uh decentralized databases the other performance is obviously you have to sacrifice on performance to get the decentralization and uh yeah that's also one issue next is that since like if apps are using uh decentralized databases then it creates the silos where like you like so I can explain this picture here so uh in the example of Dow tools so

uh each doubt tool will be using their own sort of centralized database and that was using multiple Dow tools now have like separate data on these Java tools and there's no way to Port data from this to that because it's it's the sort of the app owns the data since it's centralized so this is one I wanted to solve with serve DB so it's basically a decentralized database build on top of ceramic and cache using redis for like Fast Response times you can have a contract Access Control condition so as I said like you can have a condition such that only the owners of hypnosis safe can write and update data or owners of an nft can write an update

data or even just your address it this also can be decentralized by hosting multiple loans you can you you can get real-time updates so on uh if if you are creating data or updating data you can subscribe to an event and you can get the updates and uh you can even have your own dedicated ipfs and ceramic node and use that for file uploads instead of relying on other ipfs providers you can have private like private and encrypted data since it's uh since it's stored on ceramic which is a decentralized database so it's open like the data is open anyone can read it so uh to write that you can even encrypt it so it's like no no one can know then uh the main thing is that you can

eliminate like the data Islands which we which we saw here these data Islands by uh instead of creating your own like data from scratch you can Fork an existing node so uh what I mean by this is that if let's say there's an existing app using surf DB and it has some some data regarding whatever it's doing let's say a Bitcoin Bitcoin using serve DB and it has these grants data and you want to build your own grants app what you can do is you can Fork the git coins node and you can easily just create your own front end on their sort of data and the good part is that any new data being created on this on the original load the

Bitcoin node it will automatically be synced to the every other node so and like vice versa so even the gitcoin app would benefit if other nodes are getting you know new users so yeah this was the background let me show you a demo so this is sort of like the uh dashboard page where you can create your instance served instance so this is uh like the instance is sort of deployed on digitalocean so for that uh like before this you sort of need to add your digital ocean access API Keys uh I have already added so I'm not showing

but yeah once your digital version access keys are added uh don't get your instance of detail you can select the regions so these are all the regions which are offered by digital ocean so uh select Bangalore since I'm from Bangalore then you can select the size medium and what you can do now is uh you can either create a Just Surf DB instance or you can create it with the ceramic and ipfs node so like you'll get your dedicated sort of ipfs and the ceramic node so I'll do this so yeah this process takes a while like

it can take two three minutes because uh the first we need to sort of create uh in this solution they call it droplet which is like a VM like a bare minimum VM so yeah so right now it's basically we aren't creating droplet stage where digital ocean uh instantiates a VM and then once that VM is instantiated we have to set up the surf client and all the other ipfs node and ceramic node while this is loading uh we can see what's actually happening in the background so how it works is so this thing is also using servdb as

its database this app so uh what I did was like yeah encrypting the digital ocean keys and storing it on surf DB then when we create an instant we decrypt a key and then call the resolution API to create a droplet and a space so space is basically like the S3 storage stuff and when the when the droplet is ready we call an API to the surf controller which installs the serve client and sets up the ipfs node and the databases on the droplet once that is done we can query the surf client on the IP on the IPS yeah so the IP is assigned so on this IP and Port 3000

so uh once we get the IP this means that the droplet is ready but now we are initializing the server on the droplet this will take a couple of minutes till then I can use this it's since I created earlier and demonstrate like the capabilities so using Postman uh I can just ping it check yeah it's running so first basic thing we need to see is the authentication so the surf DB we always need to authenticate before we can do anything just slightly different from your traditional databases uh we need to authenticate the sign in with ethereum sort of format so basically we need to sign a message and send that signature so that we can

verify that we we own this address like this is my address so without signing in without authenticating served we can't do any creation or to we can read but we can't create an update because every create an update is at if that address is allowed to do it every operation is and based on your wallet's address this is where this on chain sort of conditions can come into play I've already logged in I've just copied like the signature from the client and since you can't use both swin to sign messages so I'll just copy this and logged in so what we can do is yeah let's see how we can create some data so if you see the API here it's a 3000

slash data slash page page is this is like the schema name so you can uh create whatever schema name you want so in this case I have page key my name and then here uh in the data you can give any Json data and entity address is basically address has the access to this data so right now I'm just getting my own address so only my address can update this data after it's created and so in this address you can give contract addresses nft token addresses anything so here like like just some random data and I can in the request

yeah uh it has created it and uh you can see like we get this theme ID which is sort of the the ceramic stream ID and uh if we get call on this we'll get all the rows created on the schema so yeah these were the rows which I created earlier this was the row which we just created and this is all like some of it is stored on cash so we get it like very quickly just in 180 milliseconds we got like you know all the rows and the next thing of the file upload so you see here I'll upload a files so if we do a post call to the 3000 and

slash file that we it's like you know uploaded instantly almost if you'd use like public ipfs providers it will take at least like a couple of seconds so we get we got this hash we can copy it and see so the the ipfs Gateway will basically be your lip it will be on Port 8080. so we'll go there I press t80 like instantly we got the image and using like battery storage and software it sometimes even takes like a you know

few seconds to load the image itself since you have your own dedicated gateway ipfs gateway it will load instantly how this instance I was let's see yeah so it's active now so this basically you have deployed it but you can even uh create locally so I have in go for that we have created these docs where you can sort of set it up locally and it's very easy so first you just need to install the binary and I've already installed so I won't go through that and the next is uh you can we have created this package called create next surf app which is basically it will uh scaffold like a next year's

app with a rainbow kit and serve TV uh you know already set up so I'll do this here I can do npx creator call it this one yeah this will as I said I create the next CS app and it would already have all the necessary configurations required to interact with surf so it's like just one command you have it ready like once your

where's my once your instance is ready what you need to do is just copy this IP and uh excited because of is in the in this app which we are creating so I'll just yeah wait for this to create and sorry this is creating a uh a front-end scaffold for you to be able to connect to a front-end to Surf DB it's an XCS app gotcha so it's uh let's go so yeah here if you see the first thing

we need to do is go to like the this files of client and here we can add that IP which was deployed and uh yeah let's run it yeah it's sort of like you know the default page and it started by connecting a wallet this this authentication it's all like this soft play so authentication using rainbow uh it's not that we are authenticating just like the front end

it's actually being authenticated to the surf now we can we can we can create or get data so I'll just meet the console for that so let's click on create data we've got this we just created some random data like hard-coded so we can even like see stream ID on set scan this is like the test scan for ceramic so I may have missed it but uh how how

do you well actually no uh continue I'll let you finish and then we'll see the questions at the end right here yeah this was a steam which was created and like you can even get data you know instantly we get a Rose uh so this this is like whenever UK data gets cached on that is so you get it like instantly so uh let's see what is in the board here what it comes with is the the API setup so auth apis already set up which is sort of integrated with rainbow kit then the data API so using this like you can

uh you have this SDK our soft client uh sort of JavaScript SDK which you can use to do all the operations create update read so this is what is set up in this app and uh so like after this like after you solve this so you can go through the docs and cons all the operations are listed here create read update real time even like the next CS example go yeah it was yeah this was the demo yeah this is awesome man

this is uh yeah this is an area I've been uh dabbling in as well um as there's like nothing really built on top of the uh existing decentralized Storage Solutions we have now but uh this is fantastic um the so the question I had was um when you were doing the create uh post uh you were creating data it looked like but what's the process to create your actual schema definition so it's uh right now there's no like so it's no no SQL so there's no schema as such doesn't matter what the data is in this Json

okay I see and whatever it's stored directly on ceramic I mean unless in the future you could create like in ceramic there's this thing called schemas where could create streams out of a schema but right now it's all free form you can just create anything this schema name is basically to group to help in grouping it so like it's indexed is on the schema name like oh let's say all the pages if you want to get all the pages you can just simply get call on this that's why this key money is used but it doesn't mean anything there's no actual schema okay point I see so this is kind of like a grouping key of sorts gotcha gotcha

uh crowd any any questions from you this is so awesome I had just one question uh do you have any plans to move away from digitalocean I do like that it fits into like the surf DB theme but just curious uh so I started with digital ocean because it's uh I I first of all wanted to avoid AWS because I there I personally find it very complicated and also reading feedback from others it seems it's very difficult to maintain you know and sort of keep track of the bills and stuff and uh that's why I went to digitalocean it's like extremely simple even from

like a developer side just you just need to add your one API key and using that key uh you can just create a you know virtual machine very easily so that's why I started in resolution but yeah like if if I mean if developers want we can easily like support scale it to other providers like you know Google Cloud AWS but for now it's on digital ocean and um is it only deployed on one uh one node or is there um some fallbacks also that digitalocean provides uh dissolution does not provide any like a digital ocean is just providing a VM

everything else I'm doing like setting it up and uh you know adding like this nodes and stuff uh as I said like you can if you really want to decently you can host multiple loads you have to do it like it's gotcha I'm just the on the app you can create multiple nodes if you want and in each in each node in different regions and uh you you have to then decide like how to sort of direct the traffic between the nodes you can easily like create multiple nodes that you can just create a like a safety node and just not use it use it only if something happens to the main node the data will always like always be

in sync right cool cool uh any any other questions from the crowd if not I I do I do have a few more um I guess uh what what inspired you to uh create surf DB hey um so I'm I'm sort of also working on uh like this other project uh where we are being like a cow tool for uh you know Dao's like operation management and like task management so

this this also I've given a demo in the previous level but yeah so while building that uh we sort of internally had a discussion of how in decentralizer infrastructure because we were using uh mongodb and we just couldn't find a easy solution like yeah there was no way to use any of the you know these databases which I mentioned as as simple as how we are using the traditional web to databases so I I I'm sure all other like doubtus which want to decentralize them so they can't decentralize because there's no rule out there to even you know help them

so yeah that's why I felt like this is a this is like a missing point and and like not just that like surf DB you also have like very easy like deployment yes usually right now if you see I like ipfs nodes in ceramic node it would it would encourage more people to deploy their own ipfs nodes which help in the overall decentralization of ipfs and ceramic so there's like two benefits to it like you get your own node and you also contribute to the decentralization aspect Beauty right now I'm sure Sarah at least for ceramic only the the core team has notes I like apart from the core team I highly doubt anyone is you know

operating their own ceramic node because it's it's hard it's a bit complicated and uh what I want from some of DB is just one click deployment you know no difficulties and just straightforward Institution yeah yeah uh definitely we gotta definitely lower the technical barriers for people to start using this Tech more freely so this is wonderful and thank you for for building something like this um and on the topic of building do you uh is is this open source uh do you need any particular Helping Hands um from the Dow to to start to to continue building it out or

yeah it is open source I can like the the core point is not open source but all the other libraries and stuff help with the orchestration is open source yeah I like yeah definitely I could use some help there and yeah basically I think mostly I need help is in feedback I right now I'm assuming devs need this kind of solution but I don't know so I really want some you know developers to try it out and like our talks are very easy to get started with I will definitely share this and just uh please I try it out see like I really want to know what other you know teachers we

should have so like that feedback so would be really helpful and is there any process to sign up for like a a beta test or something or anybody can go use it today like this deployment is I have not uh it's not live yet and this this might this might take some time because this is uh it's slightly critical because we're handling the user keys and like deploying it in production like I need to do some more checking so so it might take some time but you can you can install it locally it's very easy to do it just need to install the binary and run it

so you will have all the features short excellent uh we only have a few minutes left are there any questions from the crowd going once going twice sold well all right uh thank you very much again DJ this was a fantastic demo and and something that I'm sure a lot of folks have been clamoring for but I haven't been able to find but this is fantastic that you've taken the initiative to build this up so fantastic work and uh yeah really looking forward

to see how this develops and uh really rooting for for Mass adoption for this so good on you man thank you thank you so much uh so where can I share like the relevant links the docs yeah uh so I was actually going to follow up with you after the fact um so you can send those to me and I'll be posting them in the blog um but or uh alternatively you can post them in this chat um for everybody else to have beforehand as well in the um developer voice chat I mean cool okay thank you thank you so much working uh with that I want to wish everybody a

fantastic uh Friday and weekend and uh yeah and we will see you back here next week and uh a reminder uh we have new uh Dow level roles um so if you want to get notified for things like Dev and tell workshops and whatnot uh you wanna head over to the uh Dow level channel right at the top of the of the server and click the corresponding rules thank you kimster uh click the corresponding role for notifications you're interested in and with that uh we will stop the recording

Related talks