In this episode, we continue exploring the development of a Rust-powered web application, focusing on the initial implementation of organization management functionality. We examine how organization-related features can be introduced into a web application, exploring the foundational design decisions, application structure, and implementation approaches required to support organizational data and management workflows. The session provides practical insights into developing backend functionality with Rust, structuring application components, and laying the groundwork for applications that support multiple organizations. For developers interested in SaaS architecture, multi-tenant applications, and modern backend engineering, this episode offers a useful look at the early stages of implementing organization management in a real-world project. What you'll learn:
Understanding the first phase of feature implementation.
Exploring backend architecture and application logic.
Understanding the foundations of multi-organization applications.
Applying practical software development techniques.
Audio and video play straight from the show's own hosting. PodSubs stores and serves no media.
Transcript
From the show. Tap a time to play from there.
Speaker 1Sorry, I had to restart here because I did a mistake before. So let's see if this one is going to work. I'm going to try. Okay, so I have to.
Speaker 1Okay. Hello, so I see one user. I'm sorry about that. I made my OBS didn't restart and I had something on the screen that I don't want there. There's no big deal, but I prefer to be clean. So hopefully there's one user here. And today we're going to talk about the Rust web app. So I'm sorry for anybody that is watching that out of life because you might want to forward a little bit. until we start the
Speaker 1session because I had to restart the video here. So I want to make sure that the viewers are here. And there's one more update I want to give. Feel
Speaker 1free to tell me if you see myself here to say hi. I want to make sure that I have users before we start.
Speaker 2Okay.
Speaker 1Hey, David, I'm sorry about this. I had the wrong screen here. So I'm trying to put at least two users. Hopefully I didn't mess up everybody. And there's one more thing I want to do. I'm going to edit this. I need to update the thumbnail.
Speaker 2Okay.
Speaker 1So I think you have only you here. I might have messed up the stream here. So anyway, we're going to start working today on the Rust web app. And so as I was saying, feel free to ask me questions if you want me to do something else that I'm going to do. My plan today is to implement the multi-org in the Rust web app. So this is
Speaker 1where we have the SQL over there. And then I'm going to try to have the, put it, the multi-org the way that I like to have it. So that is a goal. So you might be the only one here at Divisor to be able to follow my link here. So hopefully I might do a catch-up session tomorrow. So the thing is, let me see if there's anything in there. No,
Speaker 1I think it's good. Just checking if... Today we're going to learn about the types... Sorry about that. Okay. So we'll see here. You are the only one, so it
Speaker 1might be a thing. Sorry, I hope I didn't mess up other people. So, anyway... So the goal here of today is going to be multi-org. So one of the things I'm doing, so hopefully it's not too small. This one might be a little bit too big for me. Let me know if it's too small. A question for later, currently the web app. This is actually a good question. A question, currently the web app use F64 as numeric
Speaker 1data type. which align with float in Postgres in contrast to numeric in Postgres. Floats appear and end up being precise. That's fair enough. And you come across this topic and things. So the F64, where do I use F64? So first of all, all the IDs are big int. So I make sure that I don't use F64. I mean, here
Speaker 1I am on the SQL here, but those guys are making sure that it's not F64. So either Bing it or, like right now, I don't even store numbers. And then F64. Generate token. I don't think we have that much F64 in the database. So I'm using the duration here in F64,
Speaker 1which is true for the duration. It allows me to have second and then millisecond. And then usually I try to have, I think here I run them into a three, dot three millisecond. So that is for the duration, but otherwise I don't have much F64. So typically I try to save in big int when it's possible, and then
Speaker 1other numbers when it's not. So that is my two things that I like to do. But I agree with you. If I need to store a number, usually it would be F64. I don't think I'm using F32.
Speaker 2And then....
Speaker 1Otherwise, typically is enough for me to store F64. I haven't run into that, but if you do, I think there's a solution like that. Ah, in ModQL. Yes, you're right. Yeah, well, in ModQL, I do need to support F64 because if the user wants to support F64, if there is another type which is better, more database-friendly, that might be a
Speaker 1good input to have it in ModQL. So that is a good one. That is good. Now, let me do this. And so what I want to do today is... do this multi-org, so we already created the database, it's already worked, so it works in the meaning that I create the org, but I don't have yet the, the org everywhere else. Now,
Speaker 1the way that I like to do org, except for users, is when I have a multi-tenant, everything is going to be scoped by the org ID. That is a way. Today, I'm using... this kind of ID, which is a big int, there will be kind of an argument to say, hey, you know, we could use UUIDs. And in this case, we will need to use UUID v7. The trick is,
Speaker 1I think that Postgres doesn't support natively yet UUID v7. So you need to install another extension or something like that. So that add a little bit of complexity. And then you can do it on the Rust side. But then after I kind of change a little bit the things, because every time you want to create something, you either need to pre-generate the UUID v7, or you need to
Speaker 1generate it from Rust, which then it's kind of create his own problem. So that is a trick. So the thing here is that What we're going to do is we're going to add the org, and the thing that I want is to add it everywhere in all of the tables here. So agent will have org ID, and everybody will have org ID, except sometimes the money-to-money, I don't have it, but conversation will have org ID, and
Speaker 1then all of these guys will have org ID also. Conversation user, so that is one thing, when it's a money-to-money, sometimes I don't put org ID there. because anyway i don't return the money to money typically and then the message in this case i will return the that to the user so i will have uh even if could be seen as a money to money i will have the thing here this one is not yeah so that
Speaker 1is is the thing so we're going to add org id to all of that. And the reason why I'm doing that in production is that I'm trying to have this org that is another layer of security, such as when you ask data, you always ask it for an org. So I'm trying to limit as much possible the API that are cross orgs. And so all of the APIs and typically the cross orgs APIs will have even another
Speaker 1RPC endpoint because I want to segregate it. And it's the thing I don't want to have too much of them. And then most of the API to create conversation, to add a thing is always coped to an org. And sometime I even put the org as the URL parameter. And so in a parameter, sorry, not in the parameter, in the path. So I have API slash, orgid slash RPC and that's it. And if I do a V1,
Speaker 1I put it after API perhaps or something like that. So this way I scope everything by org and then my API, my ACS later, which is going to be today, we don't have that yet, but that will be the access control system. It will have another layer of security, which is when for all of the API, all the model calls that are pair org, it will have the org in the CTX. And then, so in the CTX we'll have org, and then it will only allow data
Speaker 1to come back if the org of the CTX match the org of the item. And if you do that, it looks to be an extra layer. And again, this is not the full authorization. It's more kind of an extra validation to make sure that an API to a NOR cannot get data from another org. So this is super important when you do enterprise application because the last thing you want to do, because that could be almost a game over, the last thing that you want to do is to have an API that return the data
Speaker 1from our org of another org. Because that is like, you know, good luck to recover that from the clients. You can, but it's super tricky. So that is one thing that we want to build in into our API. And if you have that, it's very nice because Only these things get 99% if it's not all of them. So it's an extra layer. So that is the reason why I like to put org ID everywhere. And in fact, even in the S3, when I'm structuring my things in S3,
Speaker 1I also structure in a way that is going to be, everything is by org. So org will have a UUID. And that, if it's an org UUID that is used not for indexing, How can you use UUID v4? It's when you're indexing, you want v7 because you index better. v4 is kind of bad at indexing, but it's good at entropy, so it's very unique in a way. So
Speaker 1the UUID v4 can be used in the S3 path, such as you all have your data always per org. So this is what you always want. You don't want to have flat data. and then all the org messed up. So that is very important for enterprise application. So the org, when you need to have a multi-tonnet, architecture is very critical to your things. So with that, we're going to
Speaker 1set up our system. So here I'm going to go to the readme. So the way I will do it, it's like that. I'm going to run my database. in docker so i think i don't know if i have docker yet okay my docker started and i think i can do a terminal let me do this one it's
Speaker 1a better terminal here And then I'm going to copy paste this one. So that start the database on the side. So usually I put that and I put it there and I forget about it. Then if I wanted to check my database, I will do that, but I don't really at this point. And then I will start the server like that. I'm going to start like that, my cargo watch. Sometimes I can use bacon. I still use either bacon or cargo watch and I go back and forth.
Speaker 1So now I have this kind of server working and it means that it created the database. So if I go back there and I'm going to save. So the way that I like to do things is to make sure that I can save. So if I go to my services, web server, I think I can go anywhere, press save, it's going to restart the server. So everything is going to be created here in the database. So
Speaker 1now what I can do is if I break it, so sometimes I like to break things. So if I break it, I always do that by the way. So that should break it. So I press save and that will break, which is good. So again, sometimes I'm wasting time because I'm trying to debug something. And in fact, it was not taking this file for whatever reason. So here I know that this file is taken. So I save it, come back here, press save, and then boom, it runs it. So now I'm happy. So what I'm going to do here is I have this org ID
Speaker 1business and I want to add the org ID to all of my entities. So usually, typically what I do is I always start with a database. What I don't like to do is use. What I don't like to do is use ORM to create my database and everything. So typically what I have is, I have this one for the dev initial, and then
Speaker 1somewhere I will have the upgrade. And that is where I have what people call the migration. And then inside upgrade, I will have drop. So I like to work on drop. So a drop is something that I deploy, basically. So drop 12. Okay, zero zero is for the patch. eventually patch, usually I don't have patches. And then I will have something like 01 and add, you know, I don't know,
Speaker 1level to model. That doesn't mean anything, but whatever. So I will do the alter table in this kind of file, and that will be my migration. And so in development, what I do is I run those files one by one when I do the drop 12, and then I can erase it for the next drop because I don't need them anymore because what I do in production is I capture the schema of the production. So that model
Speaker 1works well when you know that you have a class application. And therefore there is only one source of truth, which is what is in production. Everything else is either past or future, but it's not truth. So the trick is the way that I do it is production is drop zero 11, for example. And so now I have all the 12 guys here, and then after I have a script, and I have a pod actually that updated database, does a snapshot of the database, put it in an S3 production,
Speaker 1do the migration of the database, do another snapshot of the database, put it in the production S3, and then does a schema capture of the database and put it in the dev S3. Such as when dev goes, resort to run those files, I will run the, the script will download the schema base from the Dev S3. And
Speaker 1so like that, I'm always working from a Delta out of production. That is the only thing that matters. And there's one thing in all my production coding here that I've done for, 10 years. The most important thing is every time you design something, migration, deployment, Kubernetes, anything is, how can I maximize the proximity between your production environment and your development environment? If you have all of the
Speaker 1migration files since the beginning of time that you run in your dev, but you obviously don't run in production because you only run the last guys, well, That's not very, the proximity is not low or high. I don't know how we call it, but it's not very close. So the trick here is to say, well, how can I have my dev environment as close as my prod? And the way you do that is you capture the prod schema and that is your starting point of your N
Speaker 1plus one on your dev. So that is basically the process that I have. So I hope this makes sense. And so we're not going to do the migration right now, but what I want to do is add the big int, bigness in the table. Right now I'm going to add it in a way because I don't want to break everything because our seed is not done yet, but I'm going to add it as possible of new, I'm sorry,
Speaker 1that it can be new. Now, One thing I'm going to build this sample app is, and you have two ways of building your app, is a user can belong only to one tenant, to one organization, or a user can belong to multiple tenants. In this one, I'm going to do the second one. So a user can belong to multiple tenants. So that will be the goal. The
Speaker 1thing is, if you go to user here, and so I'm not going to touch a user right now because I will add a table later and I don't have to do everything. And here I'll just do that because I was lazy, long ID, and probably I need to normalize all of that upper case. So, and the strategy here is upper case when it doesn't belong to me and lower case when it's belong to me kind of. And so I had that on the agent I want
Speaker 1that in conversation. It's not really a foreign key per se, and eventually it will be not new again, but the thing conversation user, I think I will have, I don't have that for now. So I'm going to add a note, note for now, no org added needed. Because money to money.
Speaker 1And the reason why I add a note here is because if I go down to my conversation message, I'm going to put it there. And then this one looks like a money to money, but it's not. Because it's really the message that happened to belong to a conversation. And so that is So I haven't found a solution yet.
Speaker 1Sometimes the underscore means it's a link between the two guys. And then sometime the underscore means it's just an object of a certain type. So that is a conversation message. I think what I'm going to do later, not today, but I will... Change the thing like this, that any user relationship to something, we start with a user first as a name. And I think that will make the things much more readable, I think. But I don't have to change it now. I don't want to break things now.
Speaker 1So org ID over there. So that's conversation message. And then that's it. Now, what we're going to do, and I'm going to work a lot here. So it's very cool here. And I'm sorry here, I don't know who is a second viewer here. I'm sorry, I had to change the stream today. But the thing I'm going to work a lot here this year on this Rust web app, because we're actually helping a client to use this blueprint
Speaker 1to build something. And then I also want to use that blueprint to build my briseno.com application that will allow my clients to see the architectures that I did for them and to even ask questions with LLM, with AI to the knowledge that I will have uploaded. So it's going to be pretty cool. So I really want, I'm going to grow these apps because now it's 2025 is going to be the year where I'm going to put that in production. And so there's going to be a
Speaker 1lot of things because everything is going to become Kubernetes driven with a whole multi-service architecture. So I need to make sure here, I don't know why I have that so big. Sorry, guys. Actually, I can do that. So like this, we can see the chart and everything. So we have that. And so I'm going to press save. And now I go back to my source over there,
Speaker 1whatever source, it doesn't matter. I press save. The only thing I'm looking here is that it doesn't kaboom. And it doesn't kaboom. So that's good. So now I have that. I'm pretty happy with that. And I'm going to start writing the seed over there. And what I'm going to do is I'm going to insert into org. And I
Speaker 1think in org we have nothing. We just have a name. name i'm not sure i should put interesting I'm going
Speaker 1to explain why. So I'm going to explain the thing here that's going on. So the trick here is, so first of all, in all of the tables, I like to have this. So creator ID, ctime, modifier ID, mtime. That is not for history, because obviously you don't store history,
Speaker 1it's just a creation and the last modification time and user. But that adds a lot of value without having the whole history for every table, which is often not really needed anyway. So that is a good default to have for every table. Now, that means that the CID is not null. That is a way that I like to have. Sometimes it's not possible. And in this case, you say, well, it's a system that created it. Basically, it's new. The
Speaker 1strategies that I have done in this current code base, and that can change over time. So for example, for some of the clients, sometimes the people that create an entity is not a user, is an API. So we could abstract it there, or we can have it new. So it depends on other things. But the point is that right now, I have this root user, the sys system user, which is the ID0. So this is why I have this ID0 kind of business because it's a
Speaker 1special one. Typically, when I create some things in the database for demo, I start at 100. So sometime when I create the tables over there, I don't know. Yeah, I start. Okay, I'm sorry. So here's a little trick. This is a production trick. I'm not saying this is like game changer stuff. But for all of my tables,
Speaker 1I create the ID. It's a big N generated by default as identity. Apparently that is a new thing in PostgreSQL. But then I do a start with 1,000. So the reason why I do that, and this is optional, I'm just explaining, is because now I know in the database that everything which is above 1,000 has been created the normal way, in a way, okay? It's not a test user. It's not a demo. It's not one of the things that I've been doing. It's something that went through the
Speaker 1API in a way. So in the API, I never put the ID. There's no way to put ID on insert. Now, when I do the seed, this is where I have control of the ID business. So I told myself, I say, for now, the user zero is the system admin user, and that will be created all the time. And then I have the demo one here, the org one, which is going to be the demo one org. And that
Speaker 1allows me to grow up to a thousand, I could limit to a hundred, it doesn't really matter. But that is my way of doing things. And so that is the same thing here, I'm going to insert here user, and in fact here, you see, I've inserted the user, but to be honest, I should do, one zero okay so now in my head from a production condition point i'm saying hey when it's zero or below 10 or
Speaker 1whatever it's it's a special guys you know and that would be for example that could be the system org and you might want to have that that could be okay or you can say well i have this one here is 100 and i'm going to say demo org 100 so i'm going to make a stuff or demo org one okay and then we have the demo one
Speaker 1user and so we can org demo one users and then this one is you know whatever Nemo one agent. So it's kind of a little bit boring, but that allows me to kind of see what I have. And now it's consistent. When it starts at 100, it's my own home cooking stuff. And then anything that starts at 1,000 is going to be things that go through the API.
Speaker 1That is the way I like it, usually. It's completely optional here. This is very worth splitting here. So back here, press save to make sure everything works well. It does not. and DebDB unwrap. So there's two problems here on this one. One is something is weird that I don't even know. And two, the error message here is I'm not happy
Speaker 1with this error message because it doesn't show at least the entity or something like that. So if I go back here, it's a demo one. first by username. Oh yeah, fair enough. Demo1 user, so this one is easy. So
Speaker 1why you are so cryptic? So I'm going to explain a little bit what goes through my head. Couple of things is, And that is just me, you know, for production staff. Sometime when I do a first by username, it might come from the UI. And sometime, at least I've done that, I put password, I mess up, in the username. So I don't want to capture, I don't,
Speaker 1and the errors that is sent by the nature of the system will always probably capture the error in the log line because we want to be able to debug it. Here was a print. So this is why often I don't print for username and password, obviously, the error to say, hey, this was a wrong password or wrong username because it's a sensitive data. Now, what I should be doing is
Speaker 1at least saying that it's for users. Because right now, the error is so cryptic. Of unknown. Do I have unwrap? That would be interesting. I hate unwrap. Oh, wow. Oh, I have unwrap. Okay. Okay, okay, okay. So that might not be as bad. I have the unwrap because... This
Speaker 1is a dev DB. So I don't really care that much because I know that I will debug it. This is a reason why. Now, we're going to keep this guy like that. And I'm going to go like that. Does that compile? No, it doesn't compile anymore. What is the error over there? I might have to do two like this.
Speaker 2No.
Speaker 1I might do a map so if i do this so i'm going to do that's the cool thing so i'm doing this option of user okay okay okay that's fine and then i do okay or I'm going to be user demo one, not found. Okay, so I'm going
Speaker 1to explain here. So there's quite a bit of information actually in this session. I'm never sure if I should do live coding or more like something more scripted, but I think this live coding is pretty cool because I'm going to explain you. First is my strategy is when I have a first by username, When I have the first one, it will return an option. So it's written a result of an option because if something is wrong somewhere,
Speaker 1the database is not there or whatever, but the return value is an option. If I had, and I don't have it, but if I had a get by username, I don't think I have this guy, but if I had a get by username, my convention is to say that now if it's not found, it will return item not found. In this API, I wanted to have a first by username because it's not really an error because you are just doing a, it's kind of a list which could be empty. So this is why I have that.
Speaker 1And so that is why I couldn't do the two question mark over there because the result is an option. So now I need to do, to turn it into an exception. I mean, an error. And because it's boxed in over there, I can return just a static string and that's fine. So that is a way that that works. And that is the reason thing. So now if I do this, I should be something a little bit better. User demo one, not found. Okay, so my error system
Speaker 1kind of works relatively well. And then I'm going to fix it like that.
Speaker 2Okay.
Speaker 1So now that is pretty good. So we have that and we created the, and we update the password. The reason why we update the password over there and we don't put it in the seed is because if we were going to put in the seed, we would put kind of a hard coded value because it has to be computed on the Rust side. So in a way
Speaker 1I say, since I have David, the DB anyway and all these utilities, I'm going to update the user like that. So that works pretty well. So now that we have that, we have our org everywhere, but we didn't add the org, okay? And so now we're going to do org ID. That will be the 100. And then we're going to do
Speaker 1the org-id as well over there. And that will be the 100. And then we'll do our org ID over there. Sorry, that's silly. And that, I'm sorry. This is annoying when people see the mistakes on the live and I do silly stuff. Okay, so now if I do that, this
Speaker 1should be okay. And then I'm going to press save on whatever. That will restart it. And everything is okay. So I created a database here and everything, but obviously I don't have the conversation, I don't have all these kind of things. So now the next step here, and if you have a question, feel free to ask. So now the next step is I'm going to check if
Speaker 1my APIs still work. Today, the way that I do it, and it's going to change over time, is I have my quick dev, which is kind of, and it's a bad practice. I'm not saying we should do that. But right now, this is where I have my, all of the things here. So I have the... I have the login that tests actually that the login works. And then with the CTX, I keep the cookie here and then
Speaker 1I do the pause here to create an agent. I get the agent, I create a conversation and I create a conversation message and then I log off. So this one is kind of quick dev, but it's kind of a quick test in a way or a sanity check and check that the whole flow works. So I like these things because it allows me to to do quite a bit of work like that. And then eventually I need to put that in integration test somewhere. And then on the integration test for me, it's okay to have
Speaker 1the server working on local host 8080. There's different strategy, but for me it will be okay. And then when I am on Kubernetes, all of this will always work in a Kubernetes environment, meaning in a pod, meaning in a Docker or container image. So that will be the strategy. Right now, I'm running with cargo. And so this is a reason why, for example, here we are using this trick here, which is a cargo,. cargo, and config2ml. And
Speaker 1so cargo has pretty cool stuff. When you run cargo run, I mean cargo run, which is a cargo run, then it will load this config2ml. And inside this config2ml, you can have this here, your environment variable. This is like super cool. And in fact, all of these guys will be moved to Kubernetes secret slash config map. So that will be the goal. So right now I'm using the container,
Speaker 1which is cargo, to kind of set the environment variable. And then later, Kubernetes will be my container. I typically do not do live. env. And so, and I'm not sure if That is part of the pattern of dot. But there's something I don't really like is, and I think it's an anti-pattern, is you load a file and you set your environment variable. I think you don't want to do that. It's created a lot of side effects
Speaker 1and everything. Might be sometime, might be needed. I might do it one day just to kind of work around something. But typically I like to have the container setting up these environment variables. And then when I run my, binary you just get it and assume it's there and if it's not then you handle it so that is the thing that doesn't mean that all configuration come from an environment variable yeah there might be an environment variable to say hey go and get your configuration by your configuration
Speaker 1your deep configuration from a file or from an s3 or it's already on disk is here it's fine that is okay but from environment variable which is usually this kind of things i think is a good idea to to have them set by the container. So that is a strategy. So now the thing that we have is we have this guy and I'm going to do, so I have it on readme. I'm going to do this.
Speaker 1So in Windows, in one of my tutorial, I think it was the Axiom one that I need to redo. I was doing a cargo watch and it was a test. The problem on Windows is when you do a test and a run, somehow you kind of deadlock each other. When it's example, it works. So, and anyway, in this case, it's more kind of an example than something else. So I'm going to run it like that. And then if I have, this doesn't look good. That doesn't look good
Speaker 1at all. Okay. That is a little bit unfortunate. Oh, hey, hey, actually works pretty well. The reason is, this works actually
Speaker 1very well. All right, being slow here, navigating my stuff. Quick dev, and the reason is because of wrong username. Demo one, user, press save. And then I need, yeah, press save in the example. So the way I have the cargo watch is if you press save on the example, just run the example, press save on the server, reload the server. So if you change the server, you need to press save on the server, a file on the server, and save on the example. And now I have everything
Speaker 1that works very well. And if I go there, sorry. Now I get everything. So I get my successful. I create my agents and everything. Now you see that in the agent. So here, what do we get? We get the agent, I think. Okay, so in my post here. Yeah, okay. This is tricky, but. So in this one here, I
Speaker 1returned the agent here and we see that there is no org ID. That will be my second staff here to make sure that we get the org ID from the database. Makes sense? We have no org ID every time we add staff. We have no org ID, which is normal because where that come from is, and I think we can go to agent here over there, and then we can do the agent. So the way that... Yeah,
Speaker 1I'm going to just put it like that.
Speaker 2Six of four and that.
Speaker 1And we're going to, oops, sorry. We're going to put option of things. Because right now it can be neural and might be neural when we create it. Because we didn't put it. So we're going to make option first and then after we'll do the stuff. So we press save on this one. That should restart the server. And then we go back to our example. We don't need that. We don't need that. And then we go back to our quick dev. Press save on this guy. And then
Speaker 1that is orgid cool, orgid new. Yes, because in this case, I think we created the agent. So we are just returning the agent that we created. So the orgid is new. Okay, so that is thing and that's not the agent. So
Speaker 1this one was the agent. And then this one was not the agent. There's something in my ggpc here is when I log, I don't log what I sent. So I need to make sure, I need to find a way here to post something but have the RPC methods name because here we don't know what I'm sending. So this is a little bit tricky. Okay, so now this
Speaker 1is working pretty nice. And sometime for some objects, the agent ones, we have the org ID. And this one, this one, we have the org ID here. This one, the first one after the login, now the second one and the first one okay so we do the login oh we create our agent and we get the agent we created yeah if we were going to list the
Speaker 1agents then we'll get the agent with the thing. So we could add that. But for now, we're going to do like that. So now the good question of that is to say, well, how do I get the... How do I get the org ID? And so we have two different choices here where, again, we can do it. And that is a way. One is we can do
Speaker 1it at the path level where we can do it like this. We do a.
Speaker 2V1.
Speaker 1Sorry, we do.
Speaker 2A.
Speaker 1Not login. It's not confused. We're going to say right now, the user has access to any org. So we do the org like this and we're going to say API RPC and we're going to have org and then the ID. one so in our case it will be 100. so we can do like this or we can do like that yeah it doesn't matter or like that and then we pass it and then we'll take it and we can do a v1 here if we want okay so
Speaker 1the nice things about this approach again and it looks a little bit off i understand some people it doesn't look conventional but the amazing thing about this approach is that when you get this url you know that you will get only object back that is 100 because you have this two level of security that we have. So one is get the access control. We'll talk about that with the permission and everything. And then there's going to
Speaker 1be another check, which is going to list all of the object that is returned. And we say, what is your org idea and stuff? And if it's not 100, kaboom. So this way here, it's much more, robust the trick of that is that we need to change the way we handle the request that goes in because now we need to basically have a star here and so we need to take that passes and then if stuff and in fact i'm sorry i'm going to do like something
Speaker 1like this is going to be org 100 so we'll do the star here so like this it would be cleaner to to do the um the routing will fit better. So we'll do things like this where we'll say org slash 100 and stuff. And then if we want to have multi-orgs, things sometimes is useful. You have a user come in and you want to say, hey, do I have any work or any to-dos in other orgs? So
Speaker 1you want to have this little drop down somewhere and things. Usually the way I like to do that for enterprise application is this API won't give any personal information or any org information per se. It's more like, hey, you have five items there or something like low information, but useful information. So low information density, but high information value, if that makes sense. such as you know that you have a message to be checked over there. And then
Speaker 1you change your org, and then when you change your org, then you see everything, obviously, because then you will be on this stuff. So you will have an RPC like that, orgs, and then an RPC like that with the org. So that is what we need to do. Now, the trick in my head is to say, well, you know, it's annoying because now I have to change a beast the way I'm doing things. And the cheap way could be something like that. Org ID. And that would be a
Speaker 1cheap way. Okay, and then I will have the 100. And in this case, I don't need that. The problem is now I'm polluting all of the data. Because Okay, I'm going to explain something. Because I don't want my data, my agent and everything to take the org ID like that. This is a bad thing is when I call the org ID 100, then it will decide that is org
Speaker 1ID 100. It's not the API that say, oh, my data, because agent has org ID, let me set the org ID. You can do that, will work, yeah? If I change the for create and stuff, that will work, but I don't want it to work because that is not secure because now I can talk to any org and set value on any orgs. So good luck, yeah, on the bug side. So the thing I prefer to do is something like that where, I would say, well, and this is the reason why I had the data here, because
Speaker 1at the root here, I can have what I call the meta. And I could say, well, that is a meta value for now that I could add to the beast, such as I know which org to add. And then the system is going to take that value and set it to the data. Now, honestly, the thing I prefer is to do it this way. Okay, and then this way,
Speaker 1when we create the CTX, we'll extract the 100, and then we'll put that in the CTX. So we're not going to do it in this session. What I'm going to do is, because I messed up today, it's on me with my little thing here, I'm going to create a new session tomorrow at noon Pacific time as well. The same things, and we are going to continue that. So this week we'll have two. So in a way, it's a win-win for everybody. So we'll do that tomorrow. I will schedule something at noon. I think I have
Speaker 1time at noon Pacific for one hour, one hour and one hour and a half. And then we will update the API to look something like that. Okay, so that is going to be the plan. If you have any questions, feel free to ask right now. This is a good time. Anything you want to talk or if you don't want to talk about that tomorrow or any feedback by the way about this live stream, what can be better, what can be better said, feel free to send me either
Speaker 1a message in the comment or if you want at jamie.shawn at gmail.com, more than happy, you know, send me and say, hey, you know, this was good, but that could be better. always happy to get feedback. So that is the thing that we're going to do, I'm going to leave it like that. Because right now I don't want to break thing. And making sure that that works well. And then I'm
Speaker 1going to go there. and check that everything works nicely. So everything works nicely right now. Okay, so this is what I want to do. So I'm going to do this, and I'm going to check the quick dev that is not haywire, makes sense. The SQL schema checking this stuff and say, okay, that's good. The dev seed is good. The DB, this guy, and then this guy here, which
Speaker 1is a first pass. So what I'm going to do now is git log, stuff. And I have two ways of doing it is either I create a branch, which I think I'm going to do it. So I'm going to do a JIT. I have a switch create. I always have aliases. And I'm going to do create nx because I like to say next and org. Good enough.
Speaker 2Okay.
Speaker 1And git c which is git commit dash a dash m. And I'm going to do a dot. And now I'm going to do a tilde, because tilde in my world, it means work in progress kind of things. And I say model, they first pass at org. And one of the things that I might do, so I'm not going
Speaker 1to push it right now to the repo. Tomorrow, I'm going to do the follow-up of that, such as we can do the next step. And then eventually, perhaps the things would get squashed. So I'm trying to have the commits that goes to the main branch. Or sometimes we have main, which is gold, which is what goes to production, which has been published to production. And dev is an
Speaker 1n plus one or the n plus n or n plus m or whatever we want to call it. And so, but this one, I'm going to merge it to main right now. And that will go to main tomorrow when I'm going to add and then we scratch kind of tickets together. So that is a trick. So a good question here is, thanks, Roberto. I'm sorry about today. I messed up. I'm going to delete the first stream. I share. I mean, it was no big deal because there were no lag. Critical information. But I shared something I didn't
Speaker 1want to share. And then since I want this live stream to be archived for all of you guys, I didn't want to have a bad screen over there. So that's why I had to change last minute. So the good news is tomorrow I take it on me. We have the follow-up session here on this one at noon. You can watch it live or it will be archived as well. And also I'm starting to do... So I think I'm going to do this strategy here. And again, send me feedback or whatever. Always welcome. I'm doing this kind of scheduled live stream with you guys. I poll
Speaker 1you to know what topic you want to talk about. And we talk about this and stuff. So these sessions are really custom for the live stream members. And it's more about what you want to talk about more than what I want to talk about. Then I also started to do live streams and you can see them. I put them in a playlist. There's a playlist of live stream things that I can put somewhere. But you see them right now. They're unlisted. but you should see them in the playlist of live stream members. And those will
Speaker 1become live stream only. So I put them unlisted or public for a little while, and then they become for you guys only. So that's my strategy, schedule, high, highly targeted to what you need, Those will be live stream only to members only, start to beginning. And then the things that I need to do, like yesterday, I did a couple of things, which is pretty cool. I did one live session about adding DeepSeq on Ollama for Gen AI.
Speaker 1And then I did another one about Rust and SQLite. So it's a video I'm planning. And so I said, well, I'm going to do the live anyway. I do the live, it's open to everybody. And then it's unlisted, or it might be public for everybody for a little while, and then it will be archived only for you guys. So Roberto and David, I really, really appreciate you being here. You are really the first guys here that, and there's
Speaker 1few users here that are members of the live stream, really appreciate. So I want to really tailor this kind of live stream to you guys. Question here that you had. A quick question. How do you build tables from file metadata?
Speaker 2Okay.
Speaker 1That I don't understand, David. I'm not building tables from file metadata. That is not a thing for me. For me, the schema is always something that I own there. The difference between dev, early dev and not early dev, is that in early dev, The schema is a throwaway. So I iterate very fast. So I don't have migration at the beginning. I don't need it because every time I scratch it. Now, as soon as the things kind of
Speaker 1hit something where I need to upgrade the data, where people for demo reason, because you are closing around or you want something to start having people using it, even if it's behind the scene or whatever, then you need to update the database. And then you move to the author stage which is not dev initial but it's more dev normal and that is you capture the schemas that you have in production and every migration is a drop
Speaker 1SQL numbered that you apply for this specific drop. And every time you update production, you take a new snapshot, you delete the old drops because they're on Git anyway, so they're not lost, but you delete them. They don't need to be replayed because the base is always what has been deployed in production. So that is a way. And so for me, and there's many ways to skin the cat, but for me, schema is a thing that I want full control off and I don't want a
Speaker 1tool to manage it for me. I am the one doing the create update, the alter tables and everything. And it's something I take time and it's fine to be slow when I do that because I really want to think it through. So for example, if I didn't have org, usually I always have org ID. I will do another file here. So I will have my base files I will do a drop SQL, I will do it like this first, which is not new, then after I will add new, and then I have one file at the
Speaker 1end that I commit, that will get deployed, and that is what will get run against the database. So I own my schema, I don't derive the schema from my objects. And so that's why my approach is not to be ORM, it's a lax C query, cQuery, which is more a SQL builder. It's a little bit overtype sometimes for my taste, but it's good for now. And for me, an object
Speaker 1in Rust is not the exhaustive representation of the table in the database. And I think that is the thing, is if you want to have a no-RM only kind of approach, then you have to have new data object in your language of choice, could be JavaScript, could be TypeScript, could be Java, could be Rust, could be Go or whatever. But you have to have this object now being the holistic view of this table. And like for my experience,
Speaker 1that doesn't work because sometimes you have data that is not even the matter of the UI, of the object. It's maybe bookkeeping stuff, database stuff, or things that get deprecated that you still want there because you don't want to remove the data, but you don't need to access it anymore. So you're like deprecating the column. Sometimes when we deprecate column, we actually write, if we were going to deprecate a model, for example, we write it like this, we say deprecated. Once all the code has been changed
Speaker 1and is not anymore in our rust and nobody's asking for it, we actually don't remove it sometime. We just put deprecated below. And that stays in the database for a while, for a year. And then once we don't need it, we fully delete it. But in a way, we still have data such as I hate to lose data. So that is a little bit my approach in production. I'm very, I'm over paranoid with database. Database is gold. Everything is transient in a way. I don't want to be, and that's probably because of my Oracle days. I don't know,
Speaker 1but that is the way I see stuff. So anyway, we'll do a new one tomorrow. Feedback, more than welcome. I see that there's a third user, might be Roberto. And thanks a lot for coming. Sorry for today, for the mishap. And then we'll do another one tomorrow to compensate today. So until next one. Happy coding. And I'm probably going to do more live today. Perhaps, I don't know,
Speaker 1because I do some live about Rust and SQLite and all these kind of things and so on. So with that, until next one, happy coding.
Building production-ready web applications requires efficient database interaction, flexible query construction, and well-structured data access layers. We examine how these technologies work together to simplify...
In this episode, we continue our exploration of nine essential Rust programming best practices, focusing on utilities, practical examples, and software testing. Building reliable Rust applications requires more than...
In this comprehensive tutorial, we explore how to build database-driven applications using Rust and SQLite, covering essential database concepts and practical implementation techniques. We take a hands-on approach to...
Join Jeremy Chone for a live-stream session dedicated to Rust programming, software development, and practical engineering discussions. This session provides an opportunity to explore Rust development through a live...