(This is all theoretical and meant to serve as a reference point) Say that I were to create a full stack application on ICP that utilized a react frontend, internet identity for authentication, and a number of motoko based backend canisters. For simplicity lets just say the app is a notepad where people can create, edit, and delete different txt documents and even add in pictures if they would like. Users can also create public profiles and share their notes with friends. I am curious to how an experienced ICP Motoko developer would approach a problem like this/what default set ups people typically implement. More specifically:
- Setting up a Canister to function as a SQL like Database
If I want a canister to serve as like a Table in a SQL database are stable data structures the only ones I am able to use? Because stable data structures are the only ones that persist across upgrades? If so is Trie basically the only structure from Mo:Base library I can use?
Additionally, what if I need to set up a database structure where one Principal ID could correspond to many documents (one to many relationship). A Trie would no longer work with Principal ID as key because that is just a one to one relationship. What should I do then?
-
User Public Profile Management
What Motoko based data structure is most commonly used to keep track of user information? In this case, the user information would be a users public profile. Would creating a Trie<Text,Profile> where the key is a Text variable of the user’s Principal ID converted to a string and Profile is an object with profile attributes be a good set up for storing public user data? Is it common practice to query users by Principal ID on ICP? Would all of the user data just be managed by one Canister that stores this Trie? -
Keeping Track of User Notes
We would need a canister that is responsible for managing creation, updates and deletion of note documents. Lets say these documents could be extremely large in terms of file size (store a lot of text and a lot of images/videos). How would we set up Canisters to host these documents? I would assume we can not just have one canister manage all of the user documents. Do we need to set up some kind of master canister that can create canisters for users, and track which users own which canisters? Does each user get their own canister or does that run too high risk of quickly running out of space? If it does run a risk does each document get its own canister? -
Private user data
Lets say users were storing sensitive data in these documents. What is the best practice for storing sensitive data on chain where everyone can see everything? Is encryption the only option? If so what encryption method is most recommended? If not is there some kind fo ICP functionality that allows for private data?
Sorry I know this is a lot. Im just trying to get an idea of how to best set up a medium scale full stack application. I am used to using existing web 2 tech stacks with databases like MongoDB that do a lot of the heavy lifting for you when it comes to data management. Any help would be greatly appreciated, and if anyone is available to do a live call please let me know.