|
| 1 | +# Vue Todo App with Data Client |
| 2 | + |
| 3 | +A simple Todo application demonstrating the use of `@data-client/vue` for reactive state management in Vue 3. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- ✅ Add, toggle, and delete todos |
| 8 | +- 🔄 Optimistic updates for instant UI feedback |
| 9 | +- 🌐 RESTful API integration with JSONPlaceholder |
| 10 | +- 💾 Automatic caching and normalization |
| 11 | +- 🎨 Modern, responsive UI |
| 12 | +- ⚡ Built with Vite for fast development |
| 13 | + |
| 14 | +## Tech Stack |
| 15 | + |
| 16 | +- **Vue 3** - Progressive JavaScript framework |
| 17 | +- **@data-client/vue** - Reactive normalized state management |
| 18 | +- **@data-client/rest** - REST resource definitions |
| 19 | +- **TypeScript** - Type safety |
| 20 | +- **Vite** - Build tool |
| 21 | + |
| 22 | +## Getting Started |
| 23 | + |
| 24 | +### Install Dependencies |
| 25 | + |
| 26 | +```bash |
| 27 | +npm install |
| 28 | +``` |
| 29 | + |
| 30 | +### Run Development Server |
| 31 | + |
| 32 | +```bash |
| 33 | +npm run dev |
| 34 | +``` |
| 35 | + |
| 36 | +The app will be available at `http://localhost:3000` |
| 37 | + |
| 38 | +### Build for Production |
| 39 | + |
| 40 | +```bash |
| 41 | +npm run build |
| 42 | +``` |
| 43 | + |
| 44 | +### Preview Production Build |
| 45 | + |
| 46 | +```bash |
| 47 | +npm run preview |
| 48 | +``` |
| 49 | + |
| 50 | +## Project Structure |
| 51 | + |
| 52 | +``` |
| 53 | +vue-todo-app/ |
| 54 | +├── src/ |
| 55 | +│ ├── components/ |
| 56 | +│ │ ├── TodoItem.vue # Individual todo item component |
| 57 | +│ │ ├── TodoList.vue # Main todo list container |
| 58 | +│ │ └── TodoListContent.vue # Todo list content with suspense |
| 59 | +│ ├── resources/ |
| 60 | +│ │ ├── PlaceholderBaseResource.ts # Base resource configuration |
| 61 | +│ │ ├── TodoResource.ts # Todo entity and endpoints |
| 62 | +│ │ └── UserResource.ts # User entity and endpoints |
| 63 | +│ ├── App.vue # Root component |
| 64 | +│ └── main.ts # App entry point |
| 65 | +├── index.html |
| 66 | +├── package.json |
| 67 | +├── tsconfig.json |
| 68 | +└── vite.config.ts |
| 69 | +``` |
| 70 | + |
| 71 | +## Key Concepts |
| 72 | + |
| 73 | +### Data Client Integration |
| 74 | + |
| 75 | +The app uses `@data-client/vue` for state management: |
| 76 | + |
| 77 | +- **`DataClientPlugin`** - Vue plugin that provides data client functionality |
| 78 | +- **`useSuspense`** - Composable for suspense-based data fetching |
| 79 | +- **`useController`** - Composable for triggering mutations (create, update, delete) |
| 80 | + |
| 81 | +### Resource Definitions |
| 82 | + |
| 83 | +Resources are defined using `@data-client/rest`: |
| 84 | + |
| 85 | +- **Entities** - Type-safe data models with normalization |
| 86 | +- **Resources** - CRUD endpoints for entities |
| 87 | +- **Schemas** - Query definitions for derived data |
| 88 | + |
| 89 | +### Optimistic Updates |
| 90 | + |
| 91 | +The app uses optimistic updates for instant UI feedback. Changes appear immediately while the API request is in flight. |
| 92 | + |
| 93 | +## API |
| 94 | + |
| 95 | +This app uses the [JSONPlaceholder](https://jsonplaceholder.typicode.com) API for demonstration purposes. Note that the API doesn't persist changes, but the app simulates persistence through Data Client's caching. |
| 96 | + |
| 97 | +## Learn More |
| 98 | + |
| 99 | +- [Data Client Documentation](https://dataclient.io) |
| 100 | +- [Vue 3 Documentation](https://vuejs.org) |
| 101 | +- [@data-client/vue Package](https://www.npmjs.com/package/@data-client/vue) |
| 102 | + |
0 commit comments