Skip to content

add example for tanstack db and dynamoDb with multiple entities#6

Merged
JohannesKonings merged 4 commits intomainfrom
tanstack-db-persons
Dec 27, 2025
Merged

add example for tanstack db and dynamoDb with multiple entities#6
JohannesKonings merged 4 commits intomainfrom
tanstack-db-persons

Conversation

@JohannesKonings
Copy link
Owner

No description provided.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

/**
* Generate persons in batches (for memory efficiency with large datasets)
*/
async function* generatePersonsBatched(
Copy link

Copilot AI Dec 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused function generatePersonsBatched.

Copilot uses AI. Check for mistakes.
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

/**
* Get primary email from contacts
*/
function getPrimaryEmail(contacts: ContactInfo[]): string | undefined {
Copy link

Copilot AI Dec 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused function getPrimaryEmail.

Copilot uses AI. Check for mistakes.
/**
* Get primary address city
*/
function getPrimaryCity(addresses: Address[]): string | undefined {
Copy link

Copilot AI Dec 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused function getPrimaryCity.

Copilot uses AI. Check for mistakes.
/**
* Get current employer
*/
function getCurrentEmployer(employments: Employment[]): string | undefined {
Copy link

Copilot AI Dec 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused function getCurrentEmployer.

Copilot uses AI. Check for mistakes.
/**
* Get full name
*/
function getFullName(person: Person): string {
Copy link

Copilot AI Dec 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused function getFullName.

Copilot uses AI. Check for mistakes.
// Persons Service - Collection Queries
// =============================================================================

const PersonsService = new Service(
Copy link

Copilot AI Dec 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused variable PersonsService.

Copilot uses AI. Check for mistakes.
* Useful for ElectroDB enum validation
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const getEnumValues = (enumSchema: ZodType): readonly string[] =>
Copy link

Copilot AI Dec 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused variable getEnumValues.

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI commented Dec 27, 2025

@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.

@JohannesKonings
Copy link
Owner Author

@copilot I added changes, review again

Copy link

Copilot AI commented Dec 27, 2025

@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.

@JohannesKonings JohannesKonings merged commit 882c09d into main Dec 27, 2025
@JohannesKonings JohannesKonings deleted the tanstack-db-persons branch December 27, 2025 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants