How to implement inbox outbox in application

pretty new to AP in general, and currently trying to understand how to implement inbox and outbox to an application… here is my thought with some codes for illustration:

struct Account {
account_id: i64,
username: String,
inbox_url: String,
outbox_url: String,
}

What I’m still confused about is that where do I put this inbox & outbox things? Should inbox & outbox tables exist in my database?? As if:

CREATE TABLE IF NOT EXISTS inboxes (
id SERIAL,
account_id SERIAL NOT NULL,
);

Or is this a thing that exists as a document? and the inbox_url & outbox_url link to each of its own corresponding document within the file system?

Inbox and outbox work as API endpoints. At a minimum, you need to store these URLs for remote accounts. For local accounts, I recommend storing inbox and outbox contents (all incoming and outgoing activities).

thx, @silverpill
so i think i understand the part for storing inbox outbox urls for remote accounts. For local accounts, however, im still quite confused about.
because i imagine, a local user will have inbox and outbox full of contents.

let me use mastodon as an example. its inbox and outbox will be full of “toots”.

The part where I still don’t understand enough is what happen when remote user Alice who is following my local user Bob.

When Alice wants to see if Bob has got any new toots recently. Alice performs a request to see what is Bob’s outbox look like.

When my server receive this request, do I simply return all the toots Bob has published since Bob’s account creation?

My next big confusion is about Bob’s inbox, since Bob’s inbox is full of contents he subscribed to. How do I even store those contents?

many many thx!!!

Yes, but you should return activities such as Create, not toots which are Notes.

You can store incoming activities as JSON objects in database.