partIntoday’sworldchattingoverthemessagingplatformsareaofanindividual’slifestyle.Themostofthe communicationwhetheritisaconfidentialchatornormal chataremostlyhappensoverinsocialmediaplatform.Aswe all know that most of the traditional chat application are workingonacentralizedserveri.e.,alltheuserdataisstored onacentralserver.So,themajorproblemofthisserverisif thecentralserverfailsthenthewholedatacollapses(break down)orevencanleaktheuserinformationstoredonthe server. This is the major drawback of this system, but in today’s world privacy makes a very important role in everyone’s life and specially for those organizations that works on confidential tasks like for example the military purpose, they need a very secured privacy to handle their communication from the one end to the other end. So, to achieve this system our project had made the use of decentralized backend server, as the name suggests decentralizedserveritdoesnothaveanycentralserver.Itis peer to peer network i.e., all the computers are linked together with equal permissions for processing data. To achievethisdecentralizedbackendserver,weusedalibrary calledasGun.js,adecentralizedgraphdatabase.Inthis,for front end UI of our chat application, we used Svelte a JavaScript library. Decentralized application consists of multiple nodes connected to each other in a mesh type of topologynetwork.It’sjustlikeapeer to peernetworkthat data isstoredinsucha waythatitisalmostimpossibleto viewbyananonymoususer
Key Words: Gun.js, Radisk, webRTC, Svelte, Decentralized server,UserInterface,Peertopeernetwork.
1. INTRODUCTION
2. PROBLEM STATEMENT A. Dataisstoredincentralizedserver.
Uma Thakur1 , Abhishek Chichmalkar2 Aditya Sambhare3 Aman Chaturvedi4 , Chinmay Khuspare5, Nikhil Tembhe6 Department of Computer Science and Engineering, Priyadarshini College of Engineering, Nagpur, Maharashtra, India ***
Astostoringtheuserdata,ithasbeenstoredinbigserversas italsotakesanampleamountofspace.Ithasbeensaidthatif anyoneoftheserversfails,thewholenetworkcollapsedue tothatlossofdata,whichisdangerousfortheuserasiftheir data has been lost. Due to that, you cannot retrieve your informationbacktoovercomethisissue.
AsB.connection.Lackofloyaltyintoday'sfast
,
Abstract Whenwewantedtobuyaproductlikeawatch on the internet, then suddenly we see ads related to the productonFacebook,Instagram,Google,etcthismeansthey areaccessingoureveryinformationeventhemessageswe sendtopeopleontheInternet.Thereisagrowingsuspicion that the web is betraying and spying on us. As communication is an important part of an individual’s lifestyle, as each person communicates globally with the means of the internet every day and as in today’s world, different chat systems are almost working on centralized systemsi.e.,allthedataisinacentralizedserver.Therefore, amajorproblemisifthecentralserverfailsthenthewhole networkfails,andduetothismajordrawbackisthatthere canbealossofuser’sdata,information,andresourceswhich is stored on the centralized server or even there can be a leakofuser’schatinformationthatisstoredontheserver. Decentralized is the way to resolve this problem, it’s an internethostedviaapeer to peernetwork.Theinformation willbedistributedandstoredaroundtheworldonmultiple deviceslikephones,laptops,andevensmartappliances.To achieve this, we are using Gun.js, a decentralized graph database that is real time has Low latency, and also has security,encryption,andauthorizationforthedata.
International Research Journal of Engineering and Technology (IRJET) e ISSN: 2395 0056 Volume: 09 Issue: 02 | Feb 2022 www.irjet.net p-ISSN: 2395-0072 © 2022, IRJET | Impact Factor value: 7.529 | ISO 9001:2008 Certified Journal | Page249
growing world, whenever we search for someproductinasearchengineafterawhile,weseeapop up coming out of know ware showing the exact related productthatyousearchedawhileago.Guesshowtheycame toknowthatyouwerelookingforthisproduct.Thismaylead someone is monetizing your activity that your data is not secure, which means your data has been shared with a differentcompanythatyouarenotawareof,whichmeans youhavenolongercontroloveryourdatawhereasinour projectthedataisstoredinasubsetofdatabasedonactual data.Whichismuchmoresecurethanthecentralizedserver.
Soherecomesourprojectinthepicture,whereasthehigh tech company stores their user in the server. At the same time,thereisnoguaranteethatyourdatawillbesafe.Where dataisstoredinaharddisksomewhereinthecloud,which has been shared across multiple machines, whereas our projectstoresasmallsubsetofdataoneachuserbasedon the actual data that they consume via a peer to peer
#
,
DECENTRALISED CHAT APPLICATION

3. COMPONENTS
A gun.js is a decentralized graph database, a normal databasethatstoresallthedatainaharddisksomewhere intheclouditmaybesharedacrossmultiplemachines,
Fig. 2:UserFlowDiagram
PROJECT DESCRIPTION
Svelte: Svelte it's a JavaScript tool for building UI components, whereassvelteisacompileritconvertsthedeclarativecode thatwritesasadeveloperintoimperativecodethatworks with native browser APIs. As a result, to get highly performantcodeinatinypackage,butmostimportantly,it's theonlyJavaScriptframeworkthat'sactuallyusedtocreate componentsindotspeltfileswhichcontainthreemainparts ascriptforyourJavaScriptcodewhichcanalsobetypescript astyletagforyourCSSwhichcanalsouseapreprocessor likeasandthemaintemplaterepresentedasHTML 4.
Certified Journal | Page250
International Research Journal of Engineering and Technology (IRJET) e ISSN: 2395 0056 Volume: 09 Issue: 02 | Feb 2022 www.irjet.net p-ISSN: 2395-0072 © 2022, IRJET | Impact Factor value: 7.529 | ISO 9001:2008
We made a chat web app where the data and infrastructurearenotcontrolledbyabigtechcompany instead it is decentralized across the entire user base usingwebtechnologies.Webuiltthisdecentralizedchat applicationusingalibrarycalledgun.jsandforthefront endUI,wehaveusedSvelteaJavaScriptlibrary(anopen sourcefront endcompiler).
Fig.1: DiagramofDecentralizedweb Gun.js: Gun.js decentralized graph database is a centralized databasethatwhich onaserverhostedbybigtechdatain thegunisdistributedacrossmultiplepeersorusersthrough theuse ofwebRTCandend userlikeuserrequiresaspecific graphicdatatouseyourappwhileanotheruserrequiresan entirely different one with a few shared data points in between each peer can store the data it needs in the browserslocalstoragethensyncchangeswithotherpeersin thenetworkapeermightbeoneofyourend usersorarelay serverthatyoudeploytomakethesystemmorereliablethat meanstheentiredatabaseistheunionofallgraphsonthe network,andnoonemachinecontrolstheentiresystema decentralized fire stored where you get real time updates offlinemodeandtheillusionofwhatlatencythedataitselfis managedthroughaminimalgraphAPIwhereeachrecordis anodethatcontainsauniqueIDandanyothercustomdata forthatentityinplainJavaScriptanynodeonthegraphcan reference another node allowing you to create an infinite chain of circular dependencies. an individual node never contains a duplicate of another node just a reference to it allowing you to model complex relationships without the needforaschema. Radisk: TheRadiskStorageEngine(RAD)isanin memory,aswellas on diskradixtreethatsavestheGUNdatabasegraphforfast and performant look ups. Radix trees have a constant lookup time. webRTC: webRTCexchangereal timeaudiovideostreamswithyour friends entirely in the browser to capitalize on the work fromhomeboomthenwebRTCistheAPIbecauseitallows youtoestablishapeer to peerconnectionbetweentwoor morebrowserswheretheycanexchangeaudiovideomedia directlywithouttheneedforathird partyserverornative appwebRTCwillmakeaseriesofrequeststoastunserver.



Volume: 09 Issue: 02 | Feb 2022 www.irjet.net p-ISSN: 2395-0072 © 2022, IRJET | Impact Factor value: 7.529 | ISO 9001:2008
5 PROJECT IMPLEMENTATION
Insveltewecanimplementtwo waydatabindingwitha variable by creating a form input and then stating bind value to that variable which means anytime user types into the form, the value of the variable will change. We have created separate form inputs for username and password,andwewillsharethemforboththeloginand
Thefirstthingwewillfocusonisuserauthenticationand to do that we created a file called user.js, at the file we imported gun.js, and below that we imported two supportinglibrariesthefirstoneSEA(SecurityEncryption andAuthorization)whichisthemodulethatenablesuser authentication and we use AXE (Advanced Exchange Equation) it is an alternative way to connect peers togetherandtendstobemoreperformantforachatapp. WecreatedavariablecalledDBtoinitializethedatabase thenusedittorefertothecurrentlyauthenticateduser, wealsochangedtheoptionofrecalltosessionstorage,so theuserstaysloggedinbetweenbrowsersessions.
Whenausermakesaqueryforsomedataitwillsearch acrossthenetworkfortheotherusersthathavethatdata and sync up using webRTC which is a web real time communication, so it is like an entire database as the unionofallpeersonthenetwork.It’slikeapeer to peer networkthatdataisstoredinsuchawaythatitisalmost impossibletoviewasaverysecureencryptionfunctionis used,thisideaisverysimilartoablockchainledgerwhere noindividual hascontrol of the entire network butitis notablockchaintechnologywhichtendstobetooslow.
International Research Journal of Engineering and Technology (IRJET) e ISSN: 2395 0056
To manage the user in the app, we need to know if the userisloggedinandwealsowanttheirusernamesowe can show it in the UI (User Interface). We get the usernamebymakingareferencetotheuserthencalling git alias which will be the value of whatever username userschooseandwhentheysignup,wethengoingtouse thisvaluefrequentlythroughouttheapplication.
Tohandlethatwe'lllistentotheauthorizationeventson thedatabaseanddothesamethingwherewefetchthe aliasandthensetthatasthevalueonthestore.
So,forthat,weimportedwritablefromtheSveltestoreto makeitreactive.Astoreislikeanobservablevaluethat willre rendertheUIwheneverit’schangedanditcanbe sharedacrossmultiplecomponentssowheneverthealias forthecurrentuserupdates,wewillsetthevalueofthe storetothatvaluebutwealsowanttolistentochangesto theauthorizationstatewhentheusersignsinsign out.
Nowontothelogincomponentwhichwillallowtheuser tosigninorsignupwiththeirusernameandpassword, wewillimporttheuserobjectandthensetupthelocal statefortheusernameandpassword.
Certified Journal | Page251
but for all intents a purpose we can imagine our entire datasetonasinglediskwhereasgun.jsalsostoresasmall subsetofdataoneachuserbasedontheactualdatathey consumeintheapplication.
For user authentication when we create a new user account this will generate secure key pair cryptographicallyandthekeyisassociatedwiththepublic keysothepastmessagecanbefoundandthepasswordis proofofworkseedtoproveandtodecryptaccesstoan account'sprivatekeys.
WehaveusedaSvelteappwithtwomainfeaturesemail passworduserauthenticationandthenamassivegroup chatroomthatanybodycanjointheonlydependencyin thisprojectisgun.jswhichweinstalledwithnpm.
In Svelte we have the Header it's component where it willshowthetitleoftheappwhenyou'renotloggedin butifyouareloggedinit'llshowyourusernameaswellas youravatar. Now to implement sign out we imported the username storeandthegunuserobjectthenwecreatedafunction calledsignoutthatcallswillleaveontheuserandsetthe usernamestoretoanemptystring.TheninourHTMLfile, wehaveabuttonthatwhenclickedwe'llcallthesignouta functionbutweonlywanttoshowthatbuttoniftheuser issignedinandthewaywecantellifauserissignedinis iftheirusernameispresentinsvelte,wedothatwitha store in any component by adding an if statement followed by a '$' dollar sign and then the name of the store.Thedollarsignwillsubscribetothestoreandreact toanychangesthathappentoitiftheusernamedoesexist then we will go ahead and show the username by subscribingtothestoreonceagain,wealsodidthesame thingtoshowanavatarwiththeuser’sinitialsbyusing DiceBearAPIwhichwillmakeauniqueavatarbasedon theusernameastherandomseed,thenwehaveabutton thathasthesignoutfunctionwhenclickedandweaddan elseblocktoshowsomethingelseiftheuserisnotlogged in,thisisabouttheheadercomponentandwedeclaredit intheappcomponentalso.
For the data to be persisted if a user just clears the browsercachedata,inthebrowser'sthelocalstorageis limitedto5megabytesandifauserclearsoutthedatain local storage it could potentially be lost if it's not somewhereelseonthenetworkprobablynotacceptable butforthis,wedeployarelayserverthatusesadifferent storagemechanismcalledRadiskthatcanstorealotmore dataonthediskofanactualserverandwhichwillmake thenetworkmorerobustbecauseifaqueryfallsbacktoa relayifit'snotavailablefromanotherpeerbycreatinga nodeinthedatabasewhichwillbeavailabletotheentire decentralizednetwork.

signupprocesswhichitselfjustconsistsoftwodifferent buttonsthatwilleithercalltheloginfunctionorthesign upfunction.
Volume: 09 Issue: 02 | Feb 2022 www.irjet.net p-ISSN: 2395-0072 © 2022, IRJET | Impact Factor value: 7.529 | ISO 9001:2008
To user log in, we used the user auth method which consists of three arguments, takes the username and passwordasfirstandsecondargumentsandinthethird argument,wedefinedacallback,inthiscasethecallback isthevalueofthestorethatwesetupearlierwhichwill updateautomatically.
1.Who Itistheuserthatsentthemessageandwe canfigureoutwhosentitbytakingthatdataofthe rawmessageandusingittogetthealias, 2.What Itistheactualtextoftheuser’smessage, 3. When It is the property to get an accurate timestamp across all of our users, we're using Gun state as the final source of truth with the raw data, this gives us all the data we need for the User Interface.
2. Users don’t have to put trust in any Central authority.a.You don’t need to trust any other chat applicationthatisworkingonacentralized serverorfollowedbythethirdpartiesthat useorsellyourdata,information,photos toanyadmanwhofollowsyouaroundthe internet. As this decentralized chat applicationwillbeusefulforsecuringyour data you should be able to reduce or eliminatethetrustthatyou’rerequiredto putintothirdparties.
Thechatcomponenthastwopiecesofstate,astringfora newmessagethattheuserwilltypeintoforminputand anarrayofmessageswhichwillcontainthemessagetext alongwiththeuserwhosentitandatimestamp.
8. REFERENCES [1] Sourabh, Deepanker Rawat,Karan Kapkoti,Sourabh Aggarwal,AnshulKhanna,"bChat:ADecentralizedChat Application",Inderprastha Engineering College, Uttar Pradesh,India,(IRJET).
1. ForGovernment/Militaryofficials: Itwillbevery usefulforgovernmentsecurityofficialswhenthey need to send their confidential messages or information regarding any work or to send their data to their intenders for some official reasons withoutanythird partyinvolvement.Astheydon’t needtotrustanyotherapplication.
Decentralized applications tend to form the interaction betweentwopeoplemoreefficientandsimpler.Thechatting process nowadays features a mediating node, while our softwaredoesn'thaveanymediatingdevice/nodei.e.Every person is connected by a peer to peer network. A Decentralized network can be a key technology that can solveprivacyandconfidentiality relatedissuesthatexistin theTraditionalorexistingmessagingsystem.
Certified Journal | Page252
Thenwetakeeachmessageandaddittoanarraythatwe canthenloopoveritintheUI(UserInterface)withSvelte. Weloopoverranarrayofitemsinsveltewitheachthiswill renderthechatmessagecomponentforeachmessageinthe arrayandbyaddingparentheseswithmessage When,which willprovidesveltewithauniquekeytosortallthemessages efficientlybywhichwereadmessagesinthechat
International Research Journal of Engineering and Technology (IRJET) e ISSN: 2395 0056
Now if the data is defined, we format a message more suitablefortheUserInterfacewiththepropertiesofwho, what,andwhen.
Nowatthispoint,wehaveaworkinguserauthentication Forsystem.themainchatcomponentwhichiswherewequery itemsfromthedatabaseandwhichalsogivestheuserthe abilitytosendamessage.
Nowtosignupanewuserisverysimilartotheprevious butinsteadofcallingauthwecallthatcreatemethodon theuserandiftheusercreationissuccessfulthenwewill logthatuserinautomatically.
WemadeaformtosubmitthemintheUI(UserInterface),in the form on the submit event will call the send message function. Inside that function, we use SEA to encrypt the actualmessagetextandthekeyisthesameastheonewe usedearliertodecryptthemessages.Nowwecanassociate themessagetothecurrentuserusingtheencryptedmessage asthevaluethenwecreatedadatetoserveastheindexfor themessagesoitcanbesortedproperlyatwhichpoint,we canreferencethechatcollectioncreateanewnodebasedon thatindexandstorethemessagevalue.
6. ADVANTAGES
Toquerymessages,wesetuptheonMountlifecyclehook thatwillrunwheneverthecomponentisfirstinitialized, insideit,weusedthedatabasetomakeareferencetothe chatnodeasforcreatingsuperchatwejustgiveitaname of Thenchat.wejustcallmaptoloopovereverysinglemessagein the chat and then call once to only read each message once,inthiscaseeachmessageisimmutablesowedon't needtolistentochangesinreal time,thenwedefineda call backthatwillbecalledoneachnewmessagethatwill giveusaccesstothedataandtheidofthatnode.
7. CONCLUSION

[6] “AWebRTCVideoChatImplementationWithinthe YioopSearchEngine”(2019).ByHo,Yangcha,Master’s projects.726.DOI:https://doi.org/10.31979/etd.dtz2 hstt. [7] “AsecureChatApplicationBasedonPeer to Peer Architecture”,MohamadAfendeeMohamed,Abdullah Muhammed,andMustafaManon28 05 2015in JournalofComputerScience. [8] SecurePeer to Peercommunicationbasedon BlockchainKahinaKhacef,GuyPujolle. [9] https://gun.eco/docs/Radisk [10] https://gun.eco/docs/API [11] https://webrtc.org/getting started/peer connections [12] https://svelte.dev/docs [13] https://relay.dev/docs/
[3] SumanKumarDas,Zenlabs,ZensarTechnologies,Pune, India,"Secure Messaging Platform Using Blockchain Technology”, (IJRES), ISSN (Online): 2320 9364, ISSN (Print):2320 9356.
[2] Peter Menegay, Jason Salyers,Griffin College,"Secure CommunicationsUsingBlockchainTechnology",Milcom 2018Track3 CyberSecurityandTrustedComputing.
International Research Journal of Engineering and Technology (IRJET) e ISSN: 2395 0056 Volume: 09 Issue: 02 | Feb 2022 www.irjet.net p-ISSN: 2395-0072 © 2022, IRJET | Impact Factor value: 7.529 | ISO 9001:2008
Certified Journal | Page253
[4] Abhishek P. Takale,Chaitanya V. Vaidya,Suresh S. Kolekar,"Decentralized Chat Application using Blockchain Technology",Rajendra Mane College Of EngineeringAndTechnology,Ambav,India.(IJREAM).
[5] MuhammedKuliya,HassanAbubakar,"SecuredChatting System Using Cryptography", Lovely Professional University,PunjabIndia,(IJCRT).
