[GENERAL DISCUSSION] What is the general architecture/structure of the Lemmy code base?
The idea here is that this is a general discussion mega thread style post. Feel free to come in and ask questions, answer questions, and generally discuss.
This can go on as long as we want, and stay pinned if that works. We can simply using sorting to see the latest or "biggest" comments in here.
The worst bit about digging into a codebase, IMO, is orientating yourself and working out what does what!
The backend codebase can be found here: https://github.com/LemmyNet/lemmy
The "Contributing" section of the documentation (see here) lists how the other components of the platform interact with each other and the backend. But I don't think there's any outline of how the pieces of the backend work.
Perhaps another relevant codebase is the activity pub framework made along with lemmy: https://github.com/LemmyNet/activitypub-federation-rust.
2 replies
Hi, thanks for setting up this community. I'm not a Lemmy source contributer but I like to read open sources. Here is a very simplified web application (including Lemmy) architecture overview and I hope this text helps for some newbies:
To find an controller from a path in the router, just grep (or a similar search function you use) the Lemmy source. For example, if I want to know how
GET /user/export_settingsworks, I'll run these commands:So we got the relevant route and the controller definitions very quickly. Settings to be exported are defined as a struct
UserSettingsBackup. The controller is defined aspub async fn export_settingsand it converts the struct to a JSON.Rust might not be a easy programming language but the official text (calld The Book is very friendly for newbies, so don't hesitate to read and to write a simple program like guessing game.
Fantastic!