You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This module provides a self‑contained, offline backend implementation used by the app to showcase and manually test
4
+
email UI and flows without connecting to a real mail server. It implements the Backend API and loads demo data from
5
+
resources bundled with the library.
6
+
7
+
## What it does
8
+
9
+
- Exposes a Backend that
10
+
- returns a predefined folder list
11
+
- supports basic sync of message lists
12
+
- supports threaded conversations (based on standard Message-Id, In-Reply-To, and References headers)
13
+
- pretends to move/copy/upload messages successfully
14
+
- sends messages by handing them to the app storage layer (no network)
15
+
- Loads folders and messages from `src/main/resources/mailbox`.
16
+
17
+
## How data is organized
18
+
19
+
- Folder tree definition: `src/main/resources/mailbox/contents.json`
20
+
- Describes folders by `serverId`, display name, type (INBOX, SENT, …), and a list of `messageServerIds` per folder.
21
+
- Supports nested folders through the `subFolders` field. The backend flattens nested folders internally so they show up as "Parent/Child" names.
22
+
- Special folders (Inbox, Drafts, Sent, Spam, Trash, Archive) are ensured to always exist.
23
+
- Messages: EML files in `src/main/resources/mailbox/<folderServerId>/<messageServerId>.eml`
24
+
- Example: `src/main/resources/mailbox/inbox/intro.eml` corresponds to `folderServerId=inbox` and `messageServerId=intro`.
25
+
26
+
Key classes
27
+
28
+
- DemoBackend: Backend implementation wired to simple commands.
29
+
- DemoStore: In‑memory source of truth backed by resources.
30
+
- DemoDataLoader: Reads contents.json and parses .eml files into Message objects.
31
+
32
+
Limitations (by design)
33
+
34
+
- No real network access; search, part fetching, and some operations are not implemented and will throw.
35
+
- Push is not supported.
36
+
- Only data found in contents.json and the matching .eml files is available.
37
+
38
+
## Using the demo backend in apps
39
+
40
+
This module is a Kotlin/JVM library. Applications can depend on `backend:demo` and select the demo backend when creating
41
+
accounts for testing/development. The exact wiring is app‑specific (see the app modules in this repository for how
42
+
they register/select backends).
43
+
44
+
## Editing demo content
45
+
46
+
1) Add a new message
47
+
- Place your EML file at: `src/main/resources/mailbox/<folderServerId>/<yourMessageId>.eml`
48
+
- Run `./gradlew :backend:demo:updateDemoMailbox` to regenerate `src/main/resources/mailbox/contents.json`.
49
+
50
+
2) Add a new folder (optionally nested)
51
+
- Create the corresponding directory under `src/main/resources/mailbox/<yourFolderServerId>/` and place the `.eml` files inside it.
52
+
- Then run `./gradlew :backend:demo:updateDemoMailbox` to update `contents.json`.
53
+
54
+
### Threaded messages
55
+
56
+
Threading is supported by the app when messages include standard headers. The demo backend simply exposes the messages; the UI groups them into threads.
57
+
58
+
To create a conversation thread in a folder:
59
+
60
+
- Give each message a unique `Message-Id` header.
61
+
- For replies, set `In-Reply-To` to the `Message-Id` of the parent message.
62
+
- Maintain a `References` header that contains the chain of ancestor `Message-Id`s (root first, then each reply). Many clients do this automatically; for demo EMLs, edit the headers manually.
63
+
- Place all messages of a thread in the same folder.
64
+
- Subject prefixes like `Re:` are optional and not used for threading.
65
+
66
+
Example headers in a reply message:
67
+
68
+
```
69
+
Message-Id: <reply-2@example.test>
70
+
In-Reply-To: <root-1@example.test>
71
+
References: <root-1@example.test>
72
+
```
73
+
74
+
Notes and limitations for threads:
75
+
76
+
- Cross-folder threading is not supported by the demo backend; keep a thread’s messages in one folder.
77
+
- The backend does not infer threads from filenames or `messageServerIds`; only the MIME headers control threading.
0 commit comments