Skip to main content

Cleanup - Remove Demo Content

Overview: What Is Demo and What Is Infrastructure?

Before cleaning up, it is important to understand which parts of the Reference Extension are demo functionality and which parts are reusable infrastructure.

Demo Functionality (Can Be Removed)

The Reference Extension contains several demo features showing different implementation patterns. All of these can be removed completely:

AreaPathDescription
Componentssrc/components/*All UI components (except ErrorFallback.tsx)
Server Functionssrc/serverFunctions/*All server functions
Domain Logicsrc/domain/comments/Database access logic for comments
Domain Logicsrc/domain/project.tsProject API integration
Schemasrc/db/schema.tsThe comments table definition

The demo functionality shown in these files can be removed safely. If you want to revisit how certain parts were implemented, you can always inspect the upstream repository.

Infrastructure (Should Be Kept)

The following components are your Extension foundation and should not be removed:

AreaPathPurpose
Error UIsrc/components/ErrorFallback.tsxError-boundary fallback for the entire app
Authenticationsrc/middleware/auth.tsSession verification and access-token handling
Error handlingsrc/middleware/error-handling.tsGlobal error handling with Zod validation
Database setupsrc/db/index.tsPostgreSQL connection pool
Migrationssrc/db/migrate.ts, src/server/plugins/migrations.tsAutomatic schema migrations
Routersrc/router.tsx, src/routes/__root.tsxTanStack Router configuration
Main routesrc/routes/index.tsxEntry point (adjust content, keep file)
Webhook routesrc/routes/api/webhooks.mittwald.tsWebhook handler for Extension lifecycle
Environmentsrc/env.tsEnvironment variable validation
Error definitionssrc/global-errors.tsReusable error classes
Ghost setupsrc/ghosts.tsRPC layer using @mittwald/react-ghostmaker (adjust content, keep file)
Hookssrc/hooks/useFormErrorHandling.tsxReusable form-error hook

The extension_instance table in src/db/schema.ts is also infrastructure. It stores instance-specific data and the encrypted access token.

Remove Demo Functionality

Frontend Components

Delete all files and folders in src/components/ except ErrorFallback.tsx.

Delete complete folders:

  • src/components/comments/ - Comment feature (chat UI, forms, loading states)
  • src/components/project/ - Project display and editing

Delete individual files:

  • GreetingCard.tsx - Welcome card
  • APIReferenceCard.tsx - Link to API documentation
  • DeveloperPortalCard.tsx - Link to developer portal
  • FlowDocumentationCard.tsx - Link to flow documentation
  • ReadmeCard.tsx - README display
  • EditProjectDescriptionModal.tsx - Modal for editing project description

Then update src/routes/index.tsx. Remove imports and usages of deleted components and replace the content with your own UI.

If you only want to clean up first, you can remove the full section with card layout and keep only the title. You can also add a temporary test UI to verify everything still works. For example:

import { Title } from "@mittwald/mstudio-ext-react-components";
import { LayoutCard, Text } from "@mittwald/flow-remote-react-components";

function App() {
return (
<>
<Title>Hello Contributor!</Title>
<LayoutCard>
<Text>Test</Text>
</LayoutCard>
</>
);
}

Server Functions

Delete everything in src/serverFunctions/.

Delete complete folder:

  • src/serverFunctions/comments/ - Contains all comment-related server functions:
  • get-comments.ts - Load comments
  • add-comment.ts - Create comments
  • delete-comment.ts - Delete comments
  • get-user-name.ts - Fetch user name from mittwald API
  • get-user-avatar.ts - Fetch avatar URL from mittwald API

Delete individual files:

  • edit-project-description.ts - Edit project description
  • get-project-of-extension-instance.ts - Load project information

Then adjust src/ghosts.ts and remove all imports and ghost definitions for deleted server functions. Keep the file itself, because you will register your own server functions there later.

Also remove domain logic:

  • src/domain/comments/ - Entire folder including comments.ts
  • src/domain/project.ts - Project API integration

Database Schema

In src/db/schema.ts, remove the comments table:

// Remove this table definition:
export const comments = pgTable("comments", {
id: varchar({ length: 36 }).primaryKey(),
extensionInstanceId: varchar({ length: 36 })
.notNull()
.references(() => extensionInstances.id),
userId: varchar({ length: 36 }).notNull(),
text: text().notNull(),
createdAt: timestamp().defaultNow().notNull(),
});

Then create a migration that removes the table from the database:

# Generate a new migration based on the updated schema
pnpm run db:generate-migrations

The generated migration should look roughly like this:

DROP TABLE IF EXISTS "comments";

Tips for a Clean Cleanup

1. Work Step by Step

Remove components in reverse dependency order:

  1. First: Frontend components and imports in index.tsx
  2. Then: Server functions and ghost exports
  3. Then: Domain logic
  4. Finally: Database schema and migration

This avoids TypeScript errors during cleanup.

2. Use TypeScript as a Helper

After deleting files, TypeScript will show all remaining references. Run pnpm check or pnpm build regularly:

pnpm check

Fix all reported errors before moving on.

3. Use Git History

If you later want to inspect how a feature was implemented, demo code is still available in Git history:

git log --oneline --all -- src/components/
git show <commit-hash>:src/components/comments/CommentsCard.tsx

You can also inspect the upstream repository any time.

4. Test Before Committing

Make sure everything still works after cleanup:

# TypeScript check
pnpm check

# Build check
pnpm build

# Start locally and verify manually
pnpm docker:dev:build

Now test your DEV Extension Instance to ensure no errors are thrown and the UI renders correctly. If everything works, commit and push your changes. Your deployed Extension should then update as well.