···11+# DeZe — The Decentralized Library: How It Works
22+33+> **One-Line Summary**: DeZe is a community-run book-sharing platform where you own your data, no single company is in charge, and anyone can participate — think of it as “email for lending books.”
44+55+---
66+77+## 📬 What is AT Protocol? (The Foundation)
88+99+Imagine the postal system. You can live in any city, use any local post office, but you can still send a letter to anyone in the world. No single post office “owns” the mail system — they all agree on the same rules (addresses, stamps, delivery standards) so the whole thing works together.
1010+1111+**AT Protocol works the same way, but for your digital life.**
1212+1313+- **Your Personal Data Server (PDS)** = Your local post office. It holds your letters (data), knows your address (identity), and sends/receives on your behalf. You can pick which post office to use, or even run your own.
1414+- **Your DID (Decentralized Identifier)** = Your permanent mailing address. Even if you move to a different post office, your address stays the same. People can always find you. Think of it as a passport number for the internet — it’s yours forever.
1515+- **Relays / The Firehose** = The central mail-sorting facility. All the post offices send copies of their outgoing mail here, so anyone who needs to know what’s happening across the network can watch the stream. In our library, this is how one community’s book listings become visible to everyone else.
1616+- **Lexicons** = The agreed-upon form templates. Just like the post office has standard forms for different services (registered mail, packages, insurance claims), AT Protocol has “lexicons” — shared definitions for what a “book listing,” “loan request,” or “return confirmation” looks like. This ensures every post office speaks the same language.
1717+- **Records** = The actual letters/forms you fill out and send. When you list a book, request a loan, or confirm a return, you’re creating a record that gets stored at your post office and announced to the network.
1818+1919+### Why does this matter for a library?
2020+2121+| Traditional App (e.g., Goodreads) | DeZe (Decentralized Library) |
2222+|---|---|
2323+| One company owns all your data | **You** own your book lists, loan history, reviews |
2424+| Company shuts down → everything is lost | Your data lives at your PDS — move it anytime |
2525+| Company decides the rules | Communities set their own rules |
2626+| One server = one point of failure | Many servers work together |
2727+| You can’t take your profile elsewhere | Your identity (DID) travels with you |
2828+2929+---
3030+3131+## 📚 How the Library Works: Step by Step
3232+3333+### Step 1: Join the Library
3434+3535+1. You create an account on AT Protocol (just like creating an email account — pick a provider or host your own).
3636+2. You get a **handle** (like `@alice.library.org`) and a permanent **DID** behind the scenes.
3737+3. You log in to the library using your AT Protocol account — **no new passwords to remember**. The library never stores your password; it just verifies who you are through your PDS (your “post office”).
3838+3939+### Step 2: Add a Book to the Pool
4040+4141+Think of the **pool** as a communal bookshelf in a coffee shop — but spanning the entire internet.
4242+4343+1. You tell the library: “I have a copy of *Dune* by Frank Herbert, ISBN 978-0-441-17271-9.”
4444+2. The system looks up the book details automatically (title, author, cover art, edition info) from public databases like OpenLibrary or Wikidata.
4545+3. Your book is now listed in the public pool. Anyone on any connected library server can see it’s available.
4646+4. Behind the scenes: a record is created in **your** PDS (your post office), and the network is notified that a new book is available.
4747+4848+### Step 3: Browse & Discover
4949+5050+- You can search or browse the pool for books you’d like to read.
5151+- The library groups all editions of the same work together. So if you search for “Dune,” you’ll see the hardcover, paperback, audiobook, and every other edition — along with how many copies of each are available across the network.
5252+- Even though different people use different library servers, **everyone’s books show up in the same search** because all the servers share information through the AT Protocol relay (the “mail sorting facility”).
5353+5454+### Step 4: Request a Loan
5555+5656+1. You find a book you want. You click “Request to Borrow.”
5757+2. The book’s owner gets a notification (a loan request record is created on the network).
5858+3. The owner reviews your request and either **approves** or **declines** it.
5959+4. If approved, a **Loan Agreement** is created — a formal record on both your accounts that says: “Alice is lending *Dune* to Bob, expected return by [date].”
6060+6161+### Step 5: The Loan Lifecycle
6262+6363+A loan goes through clear stages, like checking out a library book with a date-stamped card:
6464+6565+```
6666+📋 Pending Approval → ✅ Active → 📦 Returned
6767+ ↘ ⏰ Overdue → 🔍 See “Lost Book” below
6868+```
6969+7070+- **Pending Approval**: You’ve asked to borrow; the owner hasn’t responded yet.
7171+- **Active**: The loan is confirmed. You have the book.
7272+- **Returned**: You’ve given the book back. The owner confirms receipt. The book goes back into the pool.
7373+- **Overdue**: The expected return date has passed. The system flags this automatically.
7474+7575+### Step 6: Return the Book
7676+7777+1. You give the book back to the owner (in person, by mail — however you arranged it).
7878+2. The owner marks the loan as “Returned” in the system.
7979+3. The book automatically becomes available in the pool again for others to borrow.
8080+8181+---
8282+8383+## 🔍 What Happens When a Book is Lost?
8484+8585+Life happens. Books get lost, damaged, or “permanently borrowed.” The system has a clear process for this:
8686+8787+1. **The owner reports the book as lost.** Only the owner (lender) can do this — not the borrower, and not the system automatically.
8888+2. **The owner chooses a resolution:**
8989+ - 🤝 **Forgive** — “No worries, it happens.” No penalty.
9090+ - 💰 **Compensate** — “Please replace it or make it right.” This affects the borrower’s reputation score.
9191+ - 🔎 **Investigate** — “Let’s figure out what happened.” Opens a discussion.
9292+3. **The borrower can dispute** the claim if they believe the book was returned. This creates a “Disputed” status so both sides can work it out.
9393+4. **Once resolved**, the loan is permanently closed, and the book is removed from the pool (it’s no longer available to lend).
9494+9595+This is like a library’s “lost book” policy — clear steps, fair for both sides, with a paper trail.
9696+9797+---
9898+9999+## ⭐ Trust & Reputation
100100+101101+Since there’s no central company policing behaviour, the community needs a way to know who’s trustworthy. The library uses a **reputation system**:
102102+103103+- **Positive signals**: Returning books on time, being a generous lender, getting good reviews from borrowing partners.
104104+- **Negative signals**: Losing books (especially with “Compensate” resolutions), frequently going overdue, disputed loans.
105105+- **Visibility**: Your reputation is visible to anyone considering lending to you or borrowing from you. It’s built up over time from your actual lending history — not just a star rating.
106106+- **Federation-wide**: Because all this data flows through AT Protocol, your reputation travels with you. If you move to a different library server, your track record follows.
107107+108108+Think of it like an eBay seller rating — but for book lending, and nobody owns the rating system.
109109+110110+---
111111+112112+## 🌐 Federation: How Multiple Libraries Connect
113113+114114+“Federation” is a fancy word for a simple idea: **independent groups working together by following shared rules.**
115115+116116+### The Coffee Shop Analogy
117117+118118+Imagine three different coffee shops, each with a community bookshelf:
119119+- ☕ **Bean & Books** in Melbourne
120120+- ☕ **Café Literati** in London
121121+- ☕ **The Reading Room** in Toronto
122122+123123+Without federation, each bookshelf is isolated. You can only browse and borrow from the one you visit.
124124+125125+With federation (AT Protocol), these three bookshelves are **connected**:
126126+- A book listed at Bean & Books shows up when someone at Café Literati searches for it.
127127+- Loan agreements work across shops — Alice at Bean & Books can lend to Bob at The Reading Room.
128128+- Each shop still sets its own house rules (opening hours, membership fees, behaviour policies), but the **book-sharing protocol** is the same everywhere.
129129+130130+### How does this actually work?
131131+132132+1. Each library server runs independently (like each coffee shop is its own business).
133133+2. When someone adds a book or creates a loan, that event is **announced to the network** via the relay (the “mail sorting facility”).
134134+3. Every other library server **picks up these announcements** and updates its own catalogue.
135135+4. The result: a unified, searchable library that spans many independent communities — with no single point of control or failure.
136136+137137+---
138138+139139+## 🖼️ Book Covers & Images
140140+141141+When you add a book, the system handles cover art automatically:
142142+143143+1. It fetches the cover image from public databases.
144144+2. The image is stored in **your** PDS (your “post office”) — so you’re not dependent on any external service to keep it available.
145145+3. When someone views your book listing, the library serves the cover image efficiently, using cached copies to keep things fast.
146146+147147+This means even if a public book-cover database goes offline, your listings still look complete because the images are stored in the decentralized network.
148148+149149+---
150150+151151+## 🛡️ Security & Privacy (In Plain Language)
152152+153153+### Your Identity is Yours
154154+155155+- You log in with your AT Protocol identity. The library **never sees or stores your password**.
156156+- Your login is verified through a secure handshake between the library and your PDS — like showing your passport at the border instead of giving them a copy to keep.
157157+- Even if the library server disappears, your identity and data remain safe at your PDS.
158158+159159+### Permissions are Specific
160160+161161+- The library only asks for the permissions it needs: “Can I read your book list?” “Can I create a loan agreement on your behalf?”
162162+- You can revoke access at any time from your PDS, just like revoking an app’s access to your Google account.
163163+164164+### Everything is Verified
165165+166166+- Every action on the network is **cryptographically signed** — like a wax seal on a letter. If someone tries to fake a loan agreement or tamper with your book listing, the system detects it immediately.
167167+- This happens automatically. You don’t need to do anything extra.
168168+169169+### Protection Against Abuse
170170+171171+- The system limits how many actions you can perform in a given time (to prevent spamming or automated abuse).
172172+- Every important action (adding books, creating loans, reporting losses) is logged in an audit trail — not to spy on you, but to provide evidence if there’s ever a dispute.
173173+174174+---
175175+176176+## 🔄 What Happens When Things Go Wrong?
177177+178178+### The network is temporarily down
179179+180180+If AT Protocol’s network is having issues, the library doesn’t just break. Instead:
181181+1. Your action (e.g., adding a book) is saved locally with a “pending” status.
182182+2. A background process keeps trying to sync it to the network.
183183+3. Once the network is back, everything catches up automatically.
184184+185185+It’s like writing a letter when the post office is closed — you put it in the outbox, and it gets sent as soon as they reopen.
186186+187187+### A library server goes offline
188188+189189+Because your data lives at **your** PDS (not on the library server), nothing is lost. You can connect to a different library server and pick up where you left off — your books, your loans, your reputation all travel with you.
190190+191191+### Data gets out of sync
192192+193193+The system has built-in mechanisms to detect and fill in gaps. If a library server misses some announcements from the network (like when your phone reconnects after being in airplane mode), it automatically requests the missing updates and gets back in sync.
194194+195195+---
196196+197197+## 🗺️ Glossary of Terms
198198+199199+| Term | Plain English |
200200+|------|--------------|
201201+| **AT Protocol** | The shared “postal system” rules that let different library servers talk to each other |
202202+| **PDS (Personal Data Server)** | Your “post office” — where your data is stored and managed |
203203+| **DID (Decentralized Identifier)** | Your permanent internet passport number — yours forever, even if you switch providers |
204204+| **Relay / Firehose** | The “mail sorting facility” that broadcasts network activity so everyone stays up to date |
205205+| **Lexicon** | A shared form template that ensures everyone describes books, loans, etc. the same way |
206206+| **Record** | A single “form” you’ve filled out — a book listing, a loan request, a return confirmation |
207207+| **Pool** | The communal bookshelf — all books that people have made available to lend |
208208+| **Federation** | Independent library servers working together by following the same rules |
209209+| **Loan Agreement** | The formal record of who is lending what to whom, and when it’s due back |
210210+| **Reputation** | Your track record as a borrower and lender, visible across the network |
211211+| **Handle** | Your human-readable username (like `@alice.library.org`) |
212212+| **Work** | A book title that may have many editions (e.g., “Dune” the novel) |
213213+| **Edition** | A specific version of a work (e.g., “Dune, 1st Edition Hardcover, 1965”) |
214214+215215+---
216216+217217+## 💡 Key Principles
218218+219219+1. **You own your data.** Your books, loans, and reputation live in your PDS — not on someone else’s server.
220220+2. **No single point of failure.** If one library server goes down, the rest keep running. Your data is safe.
221221+3. **Portable identity.** Switch library servers without losing anything — your DID travels with you.
222222+4. **Community governance.** Each library community sets its own rules. There’s no central authority deciding what’s allowed.
223223+5. **Transparent & verifiable.** Every action is signed and logged. Disputes have evidence. Trust is earned, not assumed.
224224+6. **Works even when the network hiccups.** Actions queue up locally and sync when connectivity is restored.
225225+226226+---
227227+228228+> **In essence**: DeZe is to book lending what email is to messaging — an open, portable, community-driven system where you’re in control. AT Protocol is the invisible plumbing that makes it all work, just like SMTP is the invisible plumbing behind your email.