add example for tanstack db and dynamoDb with multiple entities#6
add example for tanstack db and dynamoDb with multiple entities#6JohannesKonings merged 4 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a comprehensive example of using TanStack DB with DynamoDB and ElectroDB to manage multiple related entities (persons with addresses, bank accounts, contacts, and employment records). The implementation demonstrates single-table design patterns and includes a complete CRUD UI.
Key changes:
- Adds ElectroDB integration with Zod-to-ElectroDB schema conversion for type-safe DynamoDB operations
- Implements TanStack DB collections with server functions for managing persons and related entities
- Changes project path aliases from
@/*to#src/*throughout the codebase - Adds React Compiler plugin to Vite configuration
Reviewed changes
Copilot reviewed 60 out of 62 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| package.json | Adds electrodb, @faker-js/faker, React form/table libs; updates dependencies; adds knip and seed scripts |
| tsconfig.json, vite.config.ts, components.json | Updates path aliases from @/* to #src/* |
| knip.json | Adds configuration for unused code detection |
| lib/constructs/* | Adds DatabasePersons construct; updates Webapp to support both todos and persons tables |
| src/webapp/types/person.ts | Defines comprehensive Zod schemas for Person and related entities |
| src/webapp/integrations/electrodb/* | Implements Zod-to-ElectroDB converter and entity definitions |
| src/webapp/db-collections/persons.ts | Creates TanStack DB collections with server functions for all entities |
| src/webapp/hooks/useDbPersons.ts | Provides React hooks for CRUD operations on persons and related data |
| src/webapp/components/persons/* | Implements complete CRUD UI with forms, cards, modals, and table |
| src/webapp/routes/demo/db-person.tsx | Main page for managing persons with detail panel |
| scripts/seed-persons.ts | Script to populate DynamoDB with fake person data |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/webapp/data/fake-persons.ts
Outdated
| /** | ||
| * Generate persons in batches (for memory efficiency with large datasets) | ||
| */ | ||
| async function* generatePersonsBatched( |
There was a problem hiding this comment.
Unused function generatePersonsBatched.
There was a problem hiding this comment.
@copilot open a new pull request to apply changes based on this feedback
src/webapp/data/fake-persons.ts
Outdated
| /** | ||
| * Get primary email from contacts | ||
| */ | ||
| function getPrimaryEmail(contacts: ContactInfo[]): string | undefined { |
There was a problem hiding this comment.
Unused function getPrimaryEmail.
src/webapp/data/fake-persons.ts
Outdated
| /** | ||
| * Get primary address city | ||
| */ | ||
| function getPrimaryCity(addresses: Address[]): string | undefined { |
There was a problem hiding this comment.
Unused function getPrimaryCity.
src/webapp/data/fake-persons.ts
Outdated
| /** | ||
| * Get current employer | ||
| */ | ||
| function getCurrentEmployer(employments: Employment[]): string | undefined { |
There was a problem hiding this comment.
Unused function getCurrentEmployer.
src/webapp/data/fake-persons.ts
Outdated
| /** | ||
| * Get full name | ||
| */ | ||
| function getFullName(person: Person): string { |
There was a problem hiding this comment.
Unused function getFullName.
| // Persons Service - Collection Queries | ||
| // ============================================================================= | ||
|
|
||
| const PersonsService = new Service( |
There was a problem hiding this comment.
Unused variable PersonsService.
| * Useful for ElectroDB enum validation | ||
| */ | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| const getEnumValues = (enumSchema: ZodType): readonly string[] => |
There was a problem hiding this comment.
Unused variable getEnumValues.
|
@JohannesKonings I've opened a new pull request, #7, to work on those changes. Once the pull request is ready, I'll request review from you. |
|
@copilot I added changes, review again |
|
@JohannesKonings I've opened a new pull request, #8, to work on those changes. Once the pull request is ready, I'll request review from you. |
No description provided.