Skip to Content
πŸ“š MyStoryFlow Docs β€” Your guide to preserving family stories

F000 - Monorepo Setup for Analyzer App

Objective

Set up the analyzer-app within the MyStoryFlow monorepo by duplicating and cleaning the tools-app.

Prerequisites

  • Access to MyStoryFlow monorepo
  • Node.js 18+ installed
  • Existing tools-app as template

Setup Steps

1. Duplicate Tools App

cd mystoryflow/apps cp -r tools-app analyzer-app cd analyzer-app

2. Clean Package.json

{ "name": "analyzer-app", "version": "0.1.0", "private": true, "scripts": { "dev": "next dev -p 3005", "build": "next build", "start": "next start", "lint": "next lint", "test": "jest", "test:watch": "jest --watch", "test:coverage": "jest --coverage" }, "dependencies": { // Keep all Next.js dependencies // Add MyStoryFlow packages: "@mystoryflow/auth": "*", "@mystoryflow/ui": "*", "@mystoryflow/analytics": "*", "@mystoryflow/database": "*", "@mystoryflow/shared": "*", // Remove tools-specific deps } }

3. Update App Configuration

next.config.js

/** @type {import('next').NextConfig} */ const nextConfig = { reactStrictMode: true, transpilePackages: [ '@mystoryflow/ui', '@mystoryflow/auth', '@mystoryflow/analytics' ], async redirects() { return [ { source: '/', destination: '/dashboard', permanent: false, }, ] }, } module.exports = nextConfig

Update turbo.json (in root)

{ "pipeline": { "analyzer-app#build": { "dependsOn": [ "^build" ], "outputs": [ ".next/**", "!.next/cache/**" ] }, "analyzer-app#dev": { "dependsOn": [ "@mystoryflow/ui#build", "@mystoryflow/auth#build", "@mystoryflow/analytics#build" ], "cache": false, "persistent": true } } }

4. Environment Variables

Create .env.local:

# Inherit from root .env NEXT_PUBLIC_APP_NAME="MyStoryFlow Analyzer" NEXT_PUBLIC_APP_URL=http://localhost:3005 # Analyzer-specific NEXT_PUBLIC_ANALYZER_VERSION=1.0.0 ANALYZER_UPLOAD_SIZE_LIMIT_MB=150 ANALYZER_MAX_MANUSCRIPT_WORDS=200000 ANALYZER_MIN_MANUSCRIPT_WORDS=1000 # AI Services (shared with other apps) # These come from root .env

5. Clean Up Tools-Specific Code

Remove:

  • /src/app/(tools)/* - All tools routes
  • /src/components/tools/* - Tools components
  • /src/lib/* - Tools-specific utilities
  • /public/tools/* - Tools assets
  • /scripts/* - Tools scripts
  • All tools-specific migrations

Keep:

  • Basic app structure
  • Layout components
  • Common utilities
  • Supabase setup

6. Update Root Layout

src/app/layout.tsx:

import { Inter } from 'next/font/google' import { Providers } from '@/components/providers' import { Navigation } from '@mystoryflow/ui' import { AnalyticsProvider } from '@mystoryflow/analytics' import './globals.css' const inter = Inter({ subsets: ['latin'] }) export const metadata = { title: 'MyStoryFlow Analyzer - AI-Powered Manuscript Analysis', description: 'Professional manuscript analysis for authors', } export default function RootLayout({ children, }: { children: React.ReactNode }) { return ( <html lang="en"> <body className={inter.className}> <AnalyticsProvider> <Providers> <Navigation appName="analyzer" /> {children} </Providers> </AnalyticsProvider> </body> </html> ) }

7. Create Base Pages Structure

src/app/ β”œβ”€β”€ (auth)/ β”‚ β”œβ”€β”€ sign-in/ β”‚ └── sign-up/ β”œβ”€β”€ (dashboard)/ β”‚ β”œβ”€β”€ dashboard/ β”‚ β”‚ └── page.tsx β”‚ β”œβ”€β”€ manuscripts/ β”‚ β”‚ β”œβ”€β”€ page.tsx β”‚ β”‚ β”œβ”€β”€ new/ β”‚ β”‚ └── [id]/ β”‚ β”œβ”€β”€ analysis/ β”‚ β”‚ └── [id]/ β”‚ └── settings/ β”œβ”€β”€ api/ β”‚ β”œβ”€β”€ manuscripts/ β”‚ β”œβ”€β”€ analysis/ β”‚ └── upload/ └── page.tsx (redirect to dashboard)

8. Vercel Configuration

Create vercel.json:

{ "framework": "nextjs", "buildCommand": "cd ../.. && npm run build --workspace=analyzer-app", "installCommand": "cd ../.. && npm install", "outputDirectory": ".next" }

9. Update Git Configuration

Add to root .gitignore:

# Analyzer app specific apps/analyzer-app/.env.local apps/analyzer-app/.next apps/analyzer-app/out

Verification Checklist

  • App runs on port 3005
  • Can import @mystoryflow packages
  • Authentication works (shared with main app)
  • No tools-specific code remains
  • Turbo build works from root
  • Environment variables load correctly

Next Steps

Proceed to F000B-SHARED-PACKAGES to integrate shared functionality.