punimtag/MONOREPO_MIGRATION.md
Tanya 68d280e8f5 feat: Add new analysis documents and update installation scripts for backend integration
This commit introduces several new analysis documents, including Auto-Match Load Performance Analysis, Folder Picker Analysis, Monorepo Migration Summary, and various performance analysis documents. Additionally, the installation scripts are updated to reflect changes in backend service paths, ensuring proper integration with the new backend structure. These enhancements provide better documentation and streamline the setup process for users.
2025-12-30 15:04:32 -05:00

3.1 KiB

Monorepo Migration Summary

This document summarizes the migration from separate punimtag and punimtag-viewer projects to a unified monorepo structure.

Migration Date

December 2024

Changes Made

Directory Structure

Before:

punimtag/
├── src/web/          # Backend API
└── frontend/         # Admin React frontend

punimtag-viewer/      # Separate repository
└── (Next.js viewer)

After:

punimtag/
├── backend/          # FastAPI backend (renamed from src/web)
├── admin-frontend/   # React admin interface (renamed from frontend)
└── viewer-frontend/  # Next.js viewer (moved from punimtag-viewer)

Import Path Changes

All Python imports have been updated:

  • from src.web.*from backend.*
  • import src.web.*import backend.*

Configuration Updates

  1. install.sh: Updated to install dependencies for both frontends
  2. package.json: Created root package.json with workspace scripts
  3. run_api_with_worker.sh: Updated to use backend.app instead of src.web.app
  4. run_worker.sh: Updated to use backend.worker instead of src.web.worker
  5. docker-compose.yml: Updated service commands to use backend.* paths

Environment Files

  • admin-frontend/.env: Backend API URL configuration
  • viewer-frontend/.env.local: Database and NextAuth configuration

Port Configuration

  • Admin Frontend: Port 3000 (unchanged)
  • Viewer Frontend: Port 3001 (configured in viewer-frontend/package.json)
  • Backend API: Port 8000 (unchanged)

Running the Application

Development

Terminal 1 - Backend:

source venv/bin/activate
export PYTHONPATH=$(pwd)
uvicorn backend.app:app --host 127.0.0.1 --port 8000

Terminal 2 - Admin Frontend:

cd admin-frontend
npm run dev

Terminal 3 - Viewer Frontend:

cd viewer-frontend
npm run dev

Using Root Scripts

# Install all dependencies
npm run install:all

# Run individual services
npm run dev:backend
npm run dev:admin
npm run dev:viewer

Benefits

  1. Unified Setup: Single installation script for all components
  2. Easier Maintenance: All code in one repository
  3. Shared Configuration: Common environment variables and settings
  4. Simplified Deployment: Single repository to deploy
  5. Better Organization: Clear separation of admin and viewer interfaces

Migration Checklist

  • Rename src/web to backend
  • Rename frontend to admin-frontend
  • Copy punimtag-viewer to viewer-frontend
  • Update all Python imports
  • Update all scripts
  • Update install.sh
  • Create root package.json
  • Update docker-compose.yml
  • Update README.md
  • Update scripts in scripts/ directory

Notes

  • The viewer frontend manages the punimtag_auth database
  • Both frontends share the main punimtag database
  • Backend API serves both frontends
  • All database schemas remain unchanged

Next Steps

  1. Test all three services start correctly
  2. Verify database connections work
  3. Test authentication flows
  4. Update CI/CD pipelines if applicable
  5. Archive or remove the old punimtag-viewer repository