Highly ambitious ATProtocol AppView service and sdks
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 135 lines 4.2 kB view raw view rendered
1# Introduction 2 3Slices is an open source platform for building structured data applications on 4the AT Protocol network. 5 6## What is Slices? 7 8Slices lets you define custom data schemas and build applications that store, 9query, and sync structured records across the decentralized AT Protocol network. 10Think of it as a schema-first backend that automatically handles data 11validation, indexing, and cross-network synchronization. 12 13## How Slices Works on AT Protocol 14 15```mermaid 16flowchart LR 17 Users[Users<br/>Create/Update Records] --> PDS[PDS Nodes<br/>Store user data] 18 PDS --> Firehose[Firehose<br/>Stream of all events] 19 Firehose --> SlicesNetwork[Slices Network - AppView<br/>• Monitors all AT Protocol data<br/>• Routes to relevant slices] 20 SlicesNetwork --> SliceA[Slice A<br/>• Blog lexicons<br/>• Post records<br/>• Comment queries] 21 SlicesNetwork --> SliceB[Slice B<br/>• Music lexicons<br/>• Album records<br/>• Playlist queries] 22 SliceA --> ClientA[Application<br/>Client<br/>• Read/write data] 23 SliceB --> ClientB[Application<br/>Client<br/>• Read/write data] 24``` 25 26**Flow:** 27 281. Users create records on their Personal Data Server (PDS) 292. The Firehose streams all network events in real-time 303. The Slices Network monitors the firehose and routes data to relevant slices 314. Each slice indexes only records matching its specific lexicons 325. Application clients connect to specific slices to read/write data 33 34## Quick Start 35 36Get started in under a minute: 37 38```bash 39# Install the CLI globally 40deno install -g -A jsr:@slices/cli --name slices 41 42# Initialize a new slice project 43slices init my-app 44 45# Start developing 46cd my-app 47deno task dev 48``` 49 50The `slices init` command creates a full-stack Deno app with OAuth 51authentication, automatically creates your slice on the network, and generates a 52type-safe TypeScript SDK. 53 54## Simple Example 55 56Define a schema for vinyl albums: 57 58```json lexicons/com/recordcollector/album.json 59{ 60 "lexicon": 1, 61 "id": "com.recordcollector.album", 62 "defs": { 63 "main": { 64 "type": "record", 65 "record": { 66 "type": "object", 67 "required": ["title", "artist", "releaseDate"], 68 "properties": { 69 "title": { "type": "string" }, 70 "artist": { "type": "string" }, 71 "releaseDate": { "type": "string", "format": "datetime" }, 72 "genre": { "type": "array", "items": { "type": "string" } }, 73 "condition": { "type": "string" } 74 } 75 } 76 } 77 } 78} 79``` 80 81Push your lexicon and regenerate the SDK: 82 83```bash 84# Push your lexicon to the slice 85slices lexicon push 86 87# Regenerate TypeScript SDK 88slices codegen 89``` 90 91Use the auto-generated, type-safe client: 92 93```typescript 94import { AtprotoClient } from "./generated_client.ts"; 95 96const client = new AtprotoClient({ 97 baseUrl: "https://api.slices.network", 98 sliceUri: "at://your-slice-uri", 99}); 100 101// Get all grunge albums 102const albums = await client.com.recordcollector.album.getRecords({ 103 where: { genre: { contains: "grunge" } }, 104 sortBy: [{ field: "releaseDate", direction: "desc" }], 105}); 106``` 107 108## Key Features 109 110- **Schema Validation**: Define lexicons that enforce data structure and 111 constraints 112- **Auto-generated APIs**: REST endpoints created automatically from your 113 schemas 114- **TypeScript SDKs**: Type-safe clients generated from your lexicons 115- **Real-time Sync**: Automatic synchronization across the AT Protocol network 116- **Advanced Querying**: Filter, sort, and paginate records with a powerful 117 query API 118- **OAuth Built-in**: Authentication with any AT Protocol account 119 120## When to Use Slices 121 122Slices is ideal for: 123 124- **Social Applications**: Build specialized communities, forums, or social 125 features 126- **Content Platforms**: Create blogs, documentation sites, or media libraries 127- **SaaS Products**: Develop collaborative tools with structured data needs 128- **Web APIs**: Design REST APIs with automatic validation and documentation 129- **Decentralized Apps**: Build on AT Protocol without managing infrastructure 130 131## Next Steps 132 133- [Getting Started](./getting-started.md) - Set up your first slice 134- [Core Concepts](./concepts.md) - Understand lexicons and collections 135- [API Reference](./api-reference.md) - Explore the full API