[Replace with Feature Name]
[Brief description of the feature]
Replace this with a brief note about what this feature does and why it's important.
Overview
[Brief description of the feature and its purpose]
Architecture Flow
Data Flow Diagram
Feature Integration Architecture
Prerequisites
- ✅ Feature is implemented and tested locally
- ✅ Database schema changes (if any) are deployed
- ✅ Environment variables are configured
- ✅ Feature flags are enabled in
config.ts
Implementation Plan
Phase 1: Database Schema & Backend Functions
Database Schema Updates
// convex/schema.ts
export const [tableName] = defineTable({
// Define your table schema here
})
.index("by_[field]", ["[field]"]);Convex Functions Implementation
// convex/[feature].ts
import { query, mutation } from "./_generated/server";
import { v } from "convex/values";
export const [functionName] = query({
args: {
// Define your arguments here
},
handler: async (ctx, args) => {
// Implement your query logic here
},
});
export const [functionName] = mutation({
args: {
// Define your arguments here
},
handler: async (ctx, args) => {
// Implement your mutation logic here
},
});Phase 2: Frontend Components & Hooks
Custom Hooks for Feature Management
// app/hooks/use-[feature].ts
import { useQuery, useMutation } from "convex/react";
import { api } from "~/convex/_generated/api";
import { useSession } from "better-auth/react";
import { useCallback } from "react";
export function use[Feature]() {
const { data: session } = useSession();
const userId = session?.user?.id as Id<"users"> | undefined;
// Add your hooks logic here
return {
// Return your hook values here
};
}Feature Components
// app/components/[feature]/[component-name].tsx
import { Button } from "~/components/ui/button";
import { Card, CardContent, CardHeader, CardTitle } from "~/components/ui/card";
export function [ComponentName]() {
// Add your component logic here
return (
<div className="space-y-4">
<h2 className="text-2xl font-bold">[Component Title]</h2>
{/* Add your component JSX here */}
</div>
);
}Phase 3: Route Integration & Layout Updates
Route Implementation
// app/routes/[route-path].tsx
import type { Route } from "./+types/[route-name]";
import { [ComponentName] } from "~/components/[feature]/[component-name]";
export default function [RouteName]Route(props: Route.ComponentProps) {
return (
<div className="container mx-auto py-8">
<[ComponentName] />
</div>
);
}Testing
Local Testing
- Start your development server:
bun run dev - Navigate to the feature route
- Test all functionality
- Verify database operations work correctly
Production Testing
- Deploy to staging environment
- Test with real data
- Verify performance and error handling
- Check logs for any issues
Configuration
Feature Flags
Enable the feature in your configuration:
// config.ts
export const config: AppConfig = {
features: {
// ... other features
[featureName]: true, // Enable this feature
},
// ... rest of config
};Environment Variables
Add any required environment variables:
# .env.local
[FEATURE_NAME]_API_KEY=your_api_key_here
[FEATURE_NAME]_WEBHOOK_SECRET=whsec_...Architectural Changes
Before Implementation
After Implementation
Database Schema Evolution
Troubleshooting
Common Issues
[Issue 1]:
- Check that the feature flag is enabled in
config.ts - Verify the route is properly configured
- Check browser console for errors
[Issue 2]:
- Ensure schema changes are deployed:
bunx convex deploy - Check Convex dashboard for function errors
- Verify user permissions
[Issue 3]:
- Check query performance in Convex dashboard
- Consider adding indexes for frequently queried fields
- Optimize component re-renders
Next Steps
- Add authentication checks
- Implement error boundaries
- Add loading states
- Write unit tests
- Add analytics tracking
- Consider caching strategies