From 6a8582e54d986d2d329715c8533a73aa02b4e7cc Mon Sep 17 00:00:00 2001 From: defiQUG Date: Thu, 13 Nov 2025 09:32:55 -0800 Subject: [PATCH] feat: comprehensive project structure improvements and Cloud for Sovereignty landing zone - Add Cloud for Sovereignty landing zone architecture and deployment - Implement complete legal document management system - Reorganize documentation with improved navigation - Add infrastructure improvements (Dockerfiles, K8s, monitoring) - Add operational improvements (graceful shutdown, rate limiting, caching) - Create comprehensive project structure documentation - Add Azure deployment automation scripts - Improve repository navigation and organization --- .github/README.md | 29 + PROJECT_STRUCTURE.md | 313 ++++++++++ README.md | 375 +++++++----- apps/README.md | 86 +++ apps/mcp-legal/src/components/CourtFiling.tsx | 230 +++++++ .../src/components/DocumentAssembly.tsx | 208 +++++++ .../src/components/DocumentManagement.tsx | 286 +++++++++ .../src/components/DocumentWorkflow.tsx | 218 +++++++ .../src/components/MatterManagement.tsx | 228 +++++++ .../src/components/TemplateLibrary.tsx | 252 ++++++++ docs/DOCUMENTATION_REORGANIZATION_PLAN.md | 498 +++++++++++++++ docs/GETTING_STARTED.md | 111 ++++ docs/NAVIGATION.md | 217 +++++++ docs/README.md | 125 ++++ docs/REORGANIZATION_COMPLETE.md | 171 ++++++ docs/REORGANIZATION_QUICK_REFERENCE.md | 144 +++++ docs/STRUCTURE_IMPROVEMENTS.md | 161 +++++ .../CLOUD_FOR_SOVEREIGNTY_LANDING_ZONE.md | 365 +++++++++++ docs/architecture/README.md | 387 +++++++----- .../SOVEREIGNTY_LANDING_ZONE_SUMMARY.md | 189 ++++++ docs/archive/README.md | 95 +++ docs/archive/reports/ALL_REMAINING_STEPS.md | 529 ++++++++++++++++ .../reports/ALL_REMAINING_TASKS.md | 0 .../reports/COMPLETION_STATUS.md | 0 .../reports/COMPLETION_SUMMARY.md | 0 .../reports/DEPRECATION_FIXES_COMPLETE.md | 0 .../DEPRECATION_FIXES_RECOMMENDATIONS.md | 0 .../reports/FINAL_DEPRECATION_STATUS.md | 0 .../FRONTEND_IMPLEMENTATION_PROGRESS.md | 0 .../reports/GAPS_AND_PLACEHOLDERS.md | 0 docs/{ => archive}/reports/GAPS_SUMMARY.md | 0 .../reports}/INTEGRATION_COMPLETE.md | 0 .../reports/REMAINING_STEPS_SUMMARY.md | 252 ++++++++ docs/{ => archive}/reports/REMAINING_TASKS.md | 0 .../REMAINING_TASKS_CREDENTIAL_AUTOMATION.md | 0 docs/{ => archive}/reports/REMAINING_TODOS.md | 0 .../REMAINING_TODOS_QUICK_REFERENCE.md | 0 .../reports/TASK_COMPLETION_SUMMARY.md | 0 docs/deployment/README.md | 100 +++ .../seal-deployment.md} | 0 docs/deployment/azure/DOTENV_SETUP.md | 221 +++++++ docs/deployment/azure/ENVIRONMENT_SETUP.md | 247 ++++++++ docs/deployment/azure/ENV_FILE_ANALYSIS.md | 123 ++++ .../SOVEREIGNTY_LANDING_ZONE_DEPLOYMENT.md | 350 +++++++++++ .../cdn-configuration.md} | 0 docs/deployment/azure/cdn-setup.md | 209 +++++++ docs/deployment/azure/entra-verifiedid.md | 221 +++++++ .../github-setup.md} | 0 .../{DEPLOYMENT_GUIDE.md => overview.md} | 0 docs/governance/README.md | 65 +- .../privacy.md} | 0 .../threat-model.md} | 0 .../trust-framework.md} | 0 .../contributing.md} | 0 .../{SECURITY.md => policies/security.md} | 0 .../{kyc-aml-sop.md => procedures/kyc-aml.md} | 0 .../root-key-ceremony.md} | 0 .../security-audit.md} | 0 .../MICROSOFT_ENTRA_VERIFIEDID.md | 489 --------------- docs/integrations/README.md | 78 +-- docs/integrations/entra-verifiedid/README.md | 50 ++ .../best-practices.md} | 0 .../credential-images.md} | 0 .../json-content-readiness.md} | 0 .../eresidency/integration-summary.md} | 0 .../specification.md} | 0 docs/legal/README.md | 56 +- docs/legal/document-management/README.md | 55 ++ .../document-management/api-reference.md | 224 +++++++ .../implementation/complete.md | 234 +++++++ .../implementation/gaps-analysis.md | 346 +++++++++++ .../implementation/plan.md | 579 ++++++++++++++++++ docs/legal/document-management/user-guide.md | 218 +++++++ .../{ABAC_POLICY.md => policies/abac.md} | 0 docs/operations/DISASTER_RECOVERY.md | 141 +++++ docs/product/README.md | 31 +- .../features/frontend-completion-summary.md} | 0 .../features/frontend-completion.md} | 0 .../features/frontend-components.md} | 0 .../features/web-ui-coverage.md} | 0 docs/reports/COMPREHENSIVE_PROJECT_REVIEW.md | 428 +++++++++++++ docs/reports/README.md | 82 +-- docs/reports/REMAINING_STEPS_COMPLETE.md | 337 ++++++++++ docs/reports/TASK_COMPLETION_STATUS.md | 92 +++ docs/reports/active-tasks.md | 52 ++ docs/reports/current-status.md | 77 +++ infra/k8s/base/configmap-azure.yaml | 34 + infra/k8s/base/dataroom/deployment.yaml | 119 ++++ infra/k8s/base/external-secrets.yaml | 58 ++ infra/k8s/base/finance/deployment.yaml | 119 ++++ infra/k8s/base/identity/deployment.yaml | 129 ++++ infra/k8s/base/intake/deployment.yaml | 119 ++++ infra/k8s/base/kustomization.yaml | 11 +- .../k8s/base/legal-documents/deployment.yaml | 114 ++++ .../base/monitoring/grafana-deployment.yaml | 71 +++ .../monitoring/prometheus-deployment.yaml | 61 ++ infra/monitoring/alert-rules.yml | 103 ++++ .../grafana-dashboards/services-overview.json | 85 +++ infra/monitoring/logging/fluentd-config.yaml | 60 ++ .../monitoring/logging/opensearch-config.yaml | 15 + infra/monitoring/prometheus-config.yml | 142 +++++ infra/scripts/azure-complete-setup.sh | 53 ++ infra/scripts/azure-deploy.sh | 59 ++ infra/scripts/azure-fix-env-mapping.sh | 77 +++ infra/scripts/azure-integrate-cdn-env.sh | 68 ++ infra/scripts/azure-load-env.sh | 98 +++ infra/scripts/azure-sync-env-to-terraform.sh | 66 ++ infra/scripts/azure-update-k8s-secrets.sh | 64 ++ infra/scripts/azure-validate-current-env.sh | 188 ++++++ infra/scripts/azure-validate-env.sh | 133 ++++ .../deploy-sovereignty-landing-zone.sh | 109 ++++ infra/terraform/aks.tf | 101 +++ infra/terraform/azure-provider.tf | 49 ++ infra/terraform/cdn.tf | 10 +- infra/terraform/database.tf | 119 ++++ infra/terraform/key-vault.tf | 57 ++ infra/terraform/management-groups/main.tf | 137 +++++ .../terraform/management-groups/variables.tf | 8 + infra/terraform/management-groups/versions.tf | 13 + .../modules/regional-landing-zone/README.md | 64 ++ .../modules/regional-landing-zone/main.tf | 342 +++++++++++ .../modules/regional-landing-zone/outputs.tf | 94 +++ .../regional-landing-zone/variables.tf | 51 ++ .../modules/regional-landing-zone/versions.tf | 16 + infra/terraform/multi-region/README.md | 60 ++ infra/terraform/multi-region/main.tf | 120 ++++ infra/terraform/multi-region/outputs.tf | 65 ++ infra/terraform/multi-region/variables.tf | 44 ++ infra/terraform/multi-region/versions.tf | 13 + infra/terraform/outputs-azure.tf | 102 +++ infra/terraform/policies/main.tf | 254 ++++++++ infra/terraform/policies/variables.tf | 8 + infra/terraform/policies/versions.tf | 13 + infra/terraform/resource-groups.tf | 6 +- infra/terraform/storage.tf | 4 +- infra/terraform/terraform.tfvars.example | 48 ++ infra/terraform/variables.tf | 68 ++ infra/terraform/versions.tf | 4 + package.json | 2 +- packages/README.md | 145 +++++ packages/cache/src/redis-cache.ts | 130 ++++ packages/database/src/clause-library.ts | 359 +++++++++++ packages/database/src/court-filings.ts | 357 +++++++++++ packages/database/src/document-audit.ts | 336 ++++++++++ packages/database/src/document-checkout.ts | 218 +++++++ packages/database/src/document-comments.ts | 265 ++++++++ packages/database/src/document-retention.ts | 303 +++++++++ packages/database/src/document-search.ts | 121 ++++ packages/database/src/document-templates.ts | 328 ++++++++++ packages/database/src/document-versions.ts | 268 ++++++++ packages/database/src/document-workflows.ts | 314 ++++++++++ packages/database/src/index.ts | 32 +- packages/database/src/legal-matters.ts | 423 +++++++++++++ .../migrations/005_document_management.sql | 357 +++++++++++ packages/database/src/schema.ts | 41 +- packages/shared/src/graceful-shutdown.ts | 105 ++++ packages/shared/src/index.ts | 2 + packages/shared/src/rate-limiting.ts | 173 ++++++ scripts/README.md | 80 +++ scripts/backup/database-backup.sh | 47 ++ scripts/dev/docker-compose-dev.yml | 90 +++ scripts/dev/setup-dev.sh | 48 ++ scripts/security/security-scan.sh | 70 +++ services/README.md | 153 +++++ services/dataroom/Dockerfile | 49 ++ services/finance/Dockerfile | 49 ++ services/identity/Dockerfile | 49 ++ services/identity/src/index.ts | 9 + services/intake/Dockerfile | 49 ++ .../legal-documents/.github/workflows/ci.yml | 56 ++ services/legal-documents/Dockerfile | 46 ++ services/legal-documents/README.md | 133 ++++ services/legal-documents/k8s/deployment.yaml | 95 +++ services/legal-documents/package.json | 32 + services/legal-documents/src/index.ts | 162 +++++ .../src/routes/assembly-routes.ts | 222 +++++++ .../src/routes/audit-routes.ts | 61 ++ .../src/routes/clause-routes.ts | 88 +++ .../src/routes/collaboration-routes.ts | 196 ++++++ .../src/routes/document-routes.ts | 359 +++++++++++ .../src/routes/filing-routes.ts | 74 +++ .../src/routes/matter-routes.ts | 356 +++++++++++ .../src/routes/retention-routes.ts | 107 ++++ .../src/routes/search-routes.ts | 44 ++ .../src/routes/security-routes.ts | 34 + .../src/routes/template-routes.ts | 287 +++++++++ .../src/routes/version-routes.ts | 200 ++++++ .../src/routes/workflow-routes.ts | 76 +++ .../src/services/court-efiling.ts | 134 ++++ .../src/services/document-analytics.ts | 147 +++++ .../src/services/document-assembly.ts | 156 +++++ .../src/services/document-export.ts | 172 ++++++ .../src/services/document-optimization.ts | 126 ++++ .../src/services/document-security.ts | 129 ++++ .../src/services/e-signature.ts | 108 ++++ .../src/services/real-time-collaboration.ts | 131 ++++ .../src/services/workflow-engine.ts | 119 ++++ .../tests/document-templates.test.ts | 51 ++ .../tests/document-versions.test.ts | 120 ++++ .../tests/legal-matters.test.ts | 61 ++ services/legal-documents/tsconfig.json | 13 + services/legal-documents/vitest.config.ts | 14 + 202 files changed, 22699 insertions(+), 981 deletions(-) create mode 100644 .github/README.md create mode 100644 PROJECT_STRUCTURE.md create mode 100644 apps/README.md create mode 100644 apps/mcp-legal/src/components/CourtFiling.tsx create mode 100644 apps/mcp-legal/src/components/DocumentAssembly.tsx create mode 100644 apps/mcp-legal/src/components/DocumentManagement.tsx create mode 100644 apps/mcp-legal/src/components/DocumentWorkflow.tsx create mode 100644 apps/mcp-legal/src/components/MatterManagement.tsx create mode 100644 apps/mcp-legal/src/components/TemplateLibrary.tsx create mode 100644 docs/DOCUMENTATION_REORGANIZATION_PLAN.md create mode 100644 docs/GETTING_STARTED.md create mode 100644 docs/NAVIGATION.md create mode 100644 docs/README.md create mode 100644 docs/REORGANIZATION_COMPLETE.md create mode 100644 docs/REORGANIZATION_QUICK_REFERENCE.md create mode 100644 docs/STRUCTURE_IMPROVEMENTS.md create mode 100644 docs/architecture/CLOUD_FOR_SOVEREIGNTY_LANDING_ZONE.md create mode 100644 docs/architecture/SOVEREIGNTY_LANDING_ZONE_SUMMARY.md create mode 100644 docs/archive/README.md create mode 100644 docs/archive/reports/ALL_REMAINING_STEPS.md rename docs/{ => archive}/reports/ALL_REMAINING_TASKS.md (100%) rename docs/{ => archive}/reports/COMPLETION_STATUS.md (100%) rename docs/{ => archive}/reports/COMPLETION_SUMMARY.md (100%) rename docs/{ => archive}/reports/DEPRECATION_FIXES_COMPLETE.md (100%) rename docs/{ => archive}/reports/DEPRECATION_FIXES_RECOMMENDATIONS.md (100%) rename docs/{ => archive}/reports/FINAL_DEPRECATION_STATUS.md (100%) rename docs/{ => archive/reports}/FRONTEND_IMPLEMENTATION_PROGRESS.md (100%) rename docs/{ => archive}/reports/GAPS_AND_PLACEHOLDERS.md (100%) rename docs/{ => archive}/reports/GAPS_SUMMARY.md (100%) rename docs/{ => archive/reports}/INTEGRATION_COMPLETE.md (100%) create mode 100644 docs/archive/reports/REMAINING_STEPS_SUMMARY.md rename docs/{ => archive}/reports/REMAINING_TASKS.md (100%) rename docs/{ => archive}/reports/REMAINING_TASKS_CREDENTIAL_AUTOMATION.md (100%) rename docs/{ => archive}/reports/REMAINING_TODOS.md (100%) rename docs/{ => archive}/reports/REMAINING_TODOS_QUICK_REFERENCE.md (100%) rename docs/{ => archive}/reports/TASK_COMPLETION_SUMMARY.md (100%) create mode 100644 docs/deployment/README.md rename docs/deployment/{SEAL_DEPLOYMENT_AUTOMATION.md => automation/seal-deployment.md} (100%) create mode 100644 docs/deployment/azure/DOTENV_SETUP.md create mode 100644 docs/deployment/azure/ENVIRONMENT_SETUP.md create mode 100644 docs/deployment/azure/ENV_FILE_ANALYSIS.md create mode 100644 docs/deployment/azure/SOVEREIGNTY_LANDING_ZONE_DEPLOYMENT.md rename docs/deployment/{CDN_CONFIGURATION.md => azure/cdn-configuration.md} (100%) create mode 100644 docs/deployment/azure/cdn-setup.md create mode 100644 docs/deployment/azure/entra-verifiedid.md rename docs/{GITHUB_SETUP.md => deployment/github-setup.md} (100%) rename docs/deployment/{DEPLOYMENT_GUIDE.md => overview.md} (100%) rename docs/governance/{privacy-pack.md => frameworks/privacy.md} (100%) rename docs/governance/{THREAT_MODEL.md => frameworks/threat-model.md} (100%) rename docs/governance/{trust-framework-policy.md => frameworks/trust-framework.md} (100%) rename docs/governance/{CONTRIBUTING.md => policies/contributing.md} (100%) rename docs/governance/{SECURITY.md => policies/security.md} (100%) rename docs/governance/{kyc-aml-sop.md => procedures/kyc-aml.md} (100%) rename docs/governance/{root-key-ceremony-runbook.md => procedures/root-key-ceremony.md} (100%) rename docs/governance/{SECURITY_AUDIT_CHECKLIST.md => procedures/security-audit.md} (100%) delete mode 100644 docs/integrations/MICROSOFT_ENTRA_VERIFIEDID.md create mode 100644 docs/integrations/entra-verifiedid/README.md rename docs/integrations/{ENTRA_BEST_PRACTICES_IMPLEMENTATION.md => entra-verifiedid/best-practices.md} (100%) rename docs/integrations/{ENTRA_CREDENTIAL_IMAGES.md => entra-verifiedid/credential-images.md} (100%) rename docs/integrations/{ENTRA_JSON_CONTENT_READINESS.md => entra-verifiedid/json-content-readiness.md} (100%) rename docs/{eresidency-integration-summary.md => integrations/eresidency/integration-summary.md} (100%) rename docs/integrations/{EU_LAISSEZ_PASSER_SPECIFICATION.md => eu-laissez-passer/specification.md} (100%) create mode 100644 docs/legal/document-management/README.md create mode 100644 docs/legal/document-management/api-reference.md create mode 100644 docs/legal/document-management/implementation/complete.md create mode 100644 docs/legal/document-management/implementation/gaps-analysis.md create mode 100644 docs/legal/document-management/implementation/plan.md create mode 100644 docs/legal/document-management/user-guide.md rename docs/legal/{ABAC_POLICY.md => policies/abac.md} (100%) create mode 100644 docs/operations/DISASTER_RECOVERY.md rename docs/{FRONTEND_COMPLETION_SUMMARY.md => product/features/frontend-completion-summary.md} (100%) rename docs/{reports/FRONTEND_COMPLETE.md => product/features/frontend-completion.md} (100%) rename docs/{reports/FRONTEND_COMPONENTS_VERIFICATION.md => product/features/frontend-components.md} (100%) rename docs/{WEB_UI_COVERAGE_ANALYSIS.md => product/features/web-ui-coverage.md} (100%) create mode 100644 docs/reports/COMPREHENSIVE_PROJECT_REVIEW.md create mode 100644 docs/reports/REMAINING_STEPS_COMPLETE.md create mode 100644 docs/reports/TASK_COMPLETION_STATUS.md create mode 100644 docs/reports/active-tasks.md create mode 100644 docs/reports/current-status.md create mode 100644 infra/k8s/base/configmap-azure.yaml create mode 100644 infra/k8s/base/dataroom/deployment.yaml create mode 100644 infra/k8s/base/external-secrets.yaml create mode 100644 infra/k8s/base/finance/deployment.yaml create mode 100644 infra/k8s/base/identity/deployment.yaml create mode 100644 infra/k8s/base/intake/deployment.yaml create mode 100644 infra/k8s/base/legal-documents/deployment.yaml create mode 100644 infra/k8s/base/monitoring/grafana-deployment.yaml create mode 100644 infra/k8s/base/monitoring/prometheus-deployment.yaml create mode 100644 infra/monitoring/alert-rules.yml create mode 100644 infra/monitoring/grafana-dashboards/services-overview.json create mode 100644 infra/monitoring/logging/fluentd-config.yaml create mode 100644 infra/monitoring/logging/opensearch-config.yaml create mode 100644 infra/monitoring/prometheus-config.yml create mode 100755 infra/scripts/azure-complete-setup.sh create mode 100755 infra/scripts/azure-deploy.sh create mode 100755 infra/scripts/azure-fix-env-mapping.sh create mode 100755 infra/scripts/azure-integrate-cdn-env.sh create mode 100755 infra/scripts/azure-load-env.sh create mode 100755 infra/scripts/azure-sync-env-to-terraform.sh create mode 100755 infra/scripts/azure-update-k8s-secrets.sh create mode 100755 infra/scripts/azure-validate-current-env.sh create mode 100755 infra/scripts/azure-validate-env.sh create mode 100755 infra/scripts/deploy-sovereignty-landing-zone.sh create mode 100644 infra/terraform/aks.tf create mode 100644 infra/terraform/azure-provider.tf create mode 100644 infra/terraform/database.tf create mode 100644 infra/terraform/key-vault.tf create mode 100644 infra/terraform/management-groups/main.tf create mode 100644 infra/terraform/management-groups/variables.tf create mode 100644 infra/terraform/management-groups/versions.tf create mode 100644 infra/terraform/modules/regional-landing-zone/README.md create mode 100644 infra/terraform/modules/regional-landing-zone/main.tf create mode 100644 infra/terraform/modules/regional-landing-zone/outputs.tf create mode 100644 infra/terraform/modules/regional-landing-zone/variables.tf create mode 100644 infra/terraform/modules/regional-landing-zone/versions.tf create mode 100644 infra/terraform/multi-region/README.md create mode 100644 infra/terraform/multi-region/main.tf create mode 100644 infra/terraform/multi-region/outputs.tf create mode 100644 infra/terraform/multi-region/variables.tf create mode 100644 infra/terraform/multi-region/versions.tf create mode 100644 infra/terraform/outputs-azure.tf create mode 100644 infra/terraform/policies/main.tf create mode 100644 infra/terraform/policies/variables.tf create mode 100644 infra/terraform/policies/versions.tf create mode 100644 infra/terraform/terraform.tfvars.example create mode 100644 packages/README.md create mode 100644 packages/cache/src/redis-cache.ts create mode 100644 packages/database/src/clause-library.ts create mode 100644 packages/database/src/court-filings.ts create mode 100644 packages/database/src/document-audit.ts create mode 100644 packages/database/src/document-checkout.ts create mode 100644 packages/database/src/document-comments.ts create mode 100644 packages/database/src/document-retention.ts create mode 100644 packages/database/src/document-search.ts create mode 100644 packages/database/src/document-templates.ts create mode 100644 packages/database/src/document-versions.ts create mode 100644 packages/database/src/document-workflows.ts create mode 100644 packages/database/src/legal-matters.ts create mode 100644 packages/database/src/migrations/005_document_management.sql create mode 100644 packages/shared/src/graceful-shutdown.ts create mode 100644 packages/shared/src/rate-limiting.ts create mode 100644 scripts/README.md create mode 100755 scripts/backup/database-backup.sh create mode 100644 scripts/dev/docker-compose-dev.yml create mode 100755 scripts/dev/setup-dev.sh create mode 100755 scripts/security/security-scan.sh create mode 100644 services/README.md create mode 100644 services/dataroom/Dockerfile create mode 100644 services/finance/Dockerfile create mode 100644 services/identity/Dockerfile create mode 100644 services/intake/Dockerfile create mode 100644 services/legal-documents/.github/workflows/ci.yml create mode 100644 services/legal-documents/Dockerfile create mode 100644 services/legal-documents/README.md create mode 100644 services/legal-documents/k8s/deployment.yaml create mode 100644 services/legal-documents/package.json create mode 100644 services/legal-documents/src/index.ts create mode 100644 services/legal-documents/src/routes/assembly-routes.ts create mode 100644 services/legal-documents/src/routes/audit-routes.ts create mode 100644 services/legal-documents/src/routes/clause-routes.ts create mode 100644 services/legal-documents/src/routes/collaboration-routes.ts create mode 100644 services/legal-documents/src/routes/document-routes.ts create mode 100644 services/legal-documents/src/routes/filing-routes.ts create mode 100644 services/legal-documents/src/routes/matter-routes.ts create mode 100644 services/legal-documents/src/routes/retention-routes.ts create mode 100644 services/legal-documents/src/routes/search-routes.ts create mode 100644 services/legal-documents/src/routes/security-routes.ts create mode 100644 services/legal-documents/src/routes/template-routes.ts create mode 100644 services/legal-documents/src/routes/version-routes.ts create mode 100644 services/legal-documents/src/routes/workflow-routes.ts create mode 100644 services/legal-documents/src/services/court-efiling.ts create mode 100644 services/legal-documents/src/services/document-analytics.ts create mode 100644 services/legal-documents/src/services/document-assembly.ts create mode 100644 services/legal-documents/src/services/document-export.ts create mode 100644 services/legal-documents/src/services/document-optimization.ts create mode 100644 services/legal-documents/src/services/document-security.ts create mode 100644 services/legal-documents/src/services/e-signature.ts create mode 100644 services/legal-documents/src/services/real-time-collaboration.ts create mode 100644 services/legal-documents/src/services/workflow-engine.ts create mode 100644 services/legal-documents/tests/document-templates.test.ts create mode 100644 services/legal-documents/tests/document-versions.test.ts create mode 100644 services/legal-documents/tests/legal-matters.test.ts create mode 100644 services/legal-documents/tsconfig.json create mode 100644 services/legal-documents/vitest.config.ts diff --git a/.github/README.md b/.github/README.md new file mode 100644 index 0000000..859c3ff --- /dev/null +++ b/.github/README.md @@ -0,0 +1,29 @@ +# GitHub Repository + +This directory contains GitHub-specific configurations and workflows. + +## Contents + +- **Workflows** (`workflows/`): GitHub Actions CI/CD pipelines +- **Templates** (`PULL_REQUEST_TEMPLATE.md`, `ISSUE_TEMPLATE/`): Issue and PR templates + +## CI/CD + +GitHub Actions workflows are configured for: +- Continuous Integration (testing, linting, type checking) +- Continuous Deployment (build and deploy) +- Security scanning +- Dependency updates + +## Contributing + +See [Contributing Guidelines](../docs/governance/CONTRIBUTING.md) for details on: +- Code style +- Pull request process +- Testing requirements +- Documentation standards + +--- + +**Last Updated**: 2025-01-27 + diff --git a/PROJECT_STRUCTURE.md b/PROJECT_STRUCTURE.md new file mode 100644 index 0000000..34835fc --- /dev/null +++ b/PROJECT_STRUCTURE.md @@ -0,0 +1,313 @@ +# The Order - Project Structure + +**Last Updated**: 2025-01-27 +**Status**: Comprehensive Structure Guide + +## Overview + +This document provides a complete overview of The Order project structure, helping developers navigate the codebase efficiently. + +## Repository Layout + +``` +the-order/ +├── apps/ # Frontend applications +│ ├── mcp-legal/ # Legal management portal +│ ├── portal-public/ # Public-facing portal +│ └── portal-internal/ # Internal portal +│ +├── services/ # Backend microservices +│ ├── identity/ # Identity & credential service +│ ├── intake/ # Document intake service +│ ├── finance/ # Payment & finance service +│ ├── dataroom/ # Virtual data room service +│ ├── legal-documents/ # Legal document management +│ └── eresidency/ # e-Residency service +│ +├── packages/ # Shared libraries +│ ├── shared/ # Common utilities +│ ├── database/ # Database layer +│ ├── schemas/ # Zod/JSON schemas +│ ├── auth/ # Authentication +│ ├── storage/ # Storage abstraction +│ ├── crypto/ # Cryptography & KMS +│ ├── monitoring/ # Observability +│ ├── cache/ # Caching utilities +│ └── [20+ more packages] +│ +├── infra/ # Infrastructure as Code +│ ├── terraform/ # Terraform configurations +│ │ ├── management-groups/ # Management group hierarchy +│ │ ├── policies/ # Azure policies +│ │ ├── modules/ # Reusable modules +│ │ │ └── regional-landing-zone/ +│ │ └── multi-region/ # Multi-region deployment +│ ├── k8s/ # Kubernetes manifests +│ │ ├── base/ # Base configurations +│ │ └── overlays/ # Environment overlays +│ ├── monitoring/ # Monitoring configs +│ └── scripts/ # Infrastructure scripts +│ +├── docs/ # Documentation +│ ├── architecture/ # Architecture documentation +│ ├── deployment/ # Deployment guides +│ │ └── azure/ # Azure-specific guides +│ ├── governance/ # Governance & policies +│ ├── integrations/ # Integration guides +│ │ └── entra-verifiedid/ # Entra VerifiedID +│ ├── legal/ # Legal documentation +│ │ └── document-management/ # Document management +│ └── reports/ # Project reports +│ +├── scripts/ # Utility scripts +│ ├── deploy/ # Deployment scripts +│ ├── dev/ # Development scripts +│ ├── backup/ # Backup scripts +│ └── security/ # Security scripts +│ +├── assets/ # Static assets +│ └── seals/ # Credential seal images +│ +└── manifests/ # Application manifests +``` + +## Key Directories + +### Applications (`apps/`) + +Frontend applications built with React/Next.js: + +- **mcp-legal**: Legal document management portal +- **portal-public**: Public-facing member portal +- **portal-internal**: Internal administrative portal + +### Services (`services/`) + +Backend microservices (Node.js/TypeScript/Fastify): + +- **identity**: eIDAS/DID, verifiable credentials, Entra VerifiedID +- **intake**: Document ingestion, OCR, classification +- **finance**: Payments, ledgers, invoicing +- **dataroom**: Virtual data rooms, deal management +- **legal-documents**: Comprehensive document management +- **eresidency**: e-Residency services + +### Packages (`packages/`) + +Shared libraries used across services and apps: + +- **shared**: Common utilities, middleware, error handling +- **database**: Database layer, migrations, queries +- **schemas**: Zod schemas for validation +- **auth**: Authentication and authorization +- **storage**: Storage abstraction (S3/GCS/Azure) +- **crypto**: Cryptography, KMS integration +- **monitoring**: Prometheus metrics, OpenTelemetry +- **cache**: Redis caching utilities + +### Infrastructure (`infra/`) + +Infrastructure as Code: + +- **terraform/**: Azure infrastructure + - Management groups + - Policies + - Regional landing zones + - Multi-region deployment +- **k8s/**: Kubernetes manifests + - Base configurations + - Environment overlays (dev/stage/prod) +- **monitoring/**: Prometheus, Grafana configs +- **scripts/**: Infrastructure automation + +### Documentation (`docs/`) + +Comprehensive documentation: + +- **architecture/**: System architecture, ADRs +- **deployment/**: Deployment guides +- **governance/**: Policies, security, compliance +- **integrations/**: Integration documentation +- **legal/**: Legal system documentation +- **reports/**: Project status, reviews + +## Navigation Guide + +### For New Developers + +1. Start with `README.md` (project root) +2. Review `PROJECT_STRUCTURE.md` (this file) +3. Check `docs/architecture/README.md` +4. Read service-specific READMEs in `services/*/README.md` + +### For Infrastructure Engineers + +1. `infra/README.md` - Infrastructure overview +2. `infra/terraform/README.md` - Terraform guide +3. `infra/k8s/README.md` - Kubernetes guide +4. `docs/deployment/azure/` - Azure deployment guides + +### For Backend Developers + +1. `services/*/README.md` - Service documentation +2. `packages/*/README.md` - Package documentation +3. `docs/architecture/` - Architecture decisions +4. `docs/integrations/` - Integration guides + +### For Frontend Developers + +1. `apps/*/README.md` - Application documentation +2. `packages/ui/README.md` - UI component library +3. `docs/architecture/` - Frontend architecture + +## File Naming Conventions + +### Documentation +- `README.md` - Directory overview +- `ARCHITECTURE.md` - Architecture documentation +- `DEPLOYMENT.md` - Deployment guides +- `GUIDE.md` - How-to guides +- `SUMMARY.md` - Executive summaries + +### Code +- `index.ts` - Main entry point +- `*.service.ts` - Service layer +- `*.route.ts` - API routes +- `*.test.ts` - Test files +- `*.config.ts` - Configuration files + +### Infrastructure +- `main.tf` - Main Terraform file +- `variables.tf` - Variables +- `outputs.tf` - Outputs +- `versions.tf` - Version constraints +- `deployment.yaml` - Kubernetes deployment +- `service.yaml` - Kubernetes service + +## Common Patterns + +### Service Structure +``` +services/{service-name}/ +├── src/ +│ ├── index.ts # Entry point +│ ├── routes/ # API routes +│ ├── services/ # Business logic +│ └── types/ # TypeScript types +├── tests/ # Test files +├── k8s/ # Kubernetes manifests +├── Dockerfile # Container definition +├── package.json # Dependencies +└── README.md # Service documentation +``` + +### Package Structure +``` +packages/{package-name}/ +├── src/ +│ ├── index.ts # Main exports +│ └── [module files] +├── tests/ # Test files +├── package.json # Package definition +└── README.md # Package documentation +``` + +### Infrastructure Structure +``` +infra/{tool}/ +├── [config files] +├── modules/ # Reusable modules +└── README.md # Infrastructure guide +``` + +## Quick Reference + +### Find Service Code +```bash +# All services +ls services/ + +# Specific service +cd services/identity +``` + +### Find Package Code +```bash +# All packages +ls packages/ + +# Specific package +cd packages/database +``` + +### Find Documentation +```bash +# Architecture docs +ls docs/architecture/ + +# Deployment guides +ls docs/deployment/ + +# Service docs +find services -name README.md +``` + +### Find Infrastructure +```bash +# Terraform +ls infra/terraform/ + +# Kubernetes +ls infra/k8s/ + +# Scripts +ls infra/scripts/ +``` + +## Development Workflow + +1. **Local Development** + ```bash + pnpm install + docker-compose up -d # Start local services + pnpm dev # Start development servers + ``` + +2. **Building** + ```bash + pnpm build # Build all packages + pnpm build --filter @the-order/{package} # Build specific + ``` + +3. **Testing** + ```bash + pnpm test # Run all tests + pnpm test --filter @the-order/{package} # Test specific + ``` + +4. **Deployment** + ```bash + source infra/scripts/azure-load-env.sh + ./infra/scripts/azure-deploy.sh + ``` + +## Important Files + +- `package.json` - Root package configuration +- `pnpm-workspace.yaml` - Monorepo workspace config +- `tsconfig.json` - TypeScript configuration +- `turbo.json` - Turborepo configuration +- `.env` - Environment variables (not in git) +- `docker-compose.yml` - Local development stack + +## Getting Help + +- **Architecture Questions**: See `docs/architecture/` +- **Deployment Issues**: See `docs/deployment/` +- **Service Documentation**: See `services/*/README.md` +- **Package Documentation**: See `packages/*/README.md` + +--- + +**Last Updated**: 2025-01-27 + diff --git a/README.md b/README.md index afe63ce..46ab096 100644 --- a/README.md +++ b/README.md @@ -1,179 +1,266 @@ # The Order -Monorepo for The Order - A comprehensive platform for legal, financial, and governance systems. +**A comprehensive platform for digital identity, verifiable credentials, and legal document management** + +[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) +[![TypeScript](https://img.shields.io/badge/TypeScript-5.0+-blue.svg)](https://www.typescriptlang.org/) +[![Node.js](https://img.shields.io/badge/Node.js-18+-green.svg)](https://nodejs.org/) ## Overview -The Order is a mono-repo containing all applications, services, packages, infrastructure, and documentation for managing legal documents, financial systems, identity management, datarooms, and member portals. +The Order is a sovereign cloud platform providing: +- **Digital Identity Management**: eIDAS/DID-based identity verification +- **Verifiable Credentials**: Microsoft Entra VerifiedID integration +- **Legal Document Management**: Comprehensive DMS for law firms and courts +- **Virtual Data Rooms**: Secure deal management +- **Financial Services**: Payment processing and invoicing +- **e-Residency**: Digital residency services -### Governance & Legal Framework +Built with **Cloud for Sovereignty** principles, ensuring data residency, compliance, and operational control. -This repository also supports the governance and legal transition framework for: -- **Order of Military Hospitallers** - Constitutional sovereign structure -- **International Criminal Court of Commerce** - Judicial arm and tribunal -- **Digital Bank of International Settlements (DBIS)** - Financial market infrastructure - -See [docs/reports/GOVERNANCE_TASKS.md](./docs/reports/GOVERNANCE_TASKS.md) and [docs/governance/](./docs/governance/) for comprehensive governance documentation. - -## Repository Structure - -``` -the-order/ -├─ apps/ # End-user applications (web + portals) -│ ├─ portal-public/ # Public web presence -│ ├─ portal-internal/ # Internal web (admin/ops) -│ ├─ mcp-members/ # MCP for Members of The Order -│ └─ mcp-legal/ # MCP for Legal Purpose (matters, filings, attestations) -│ -├─ services/ # Domain services (APIs, workers) -│ ├─ intake/ # "Drop content" tool: ingestion → OCR → classify → route -│ ├─ identity/ # Digital Systems (eIDAS/DID, verifiable credentials) -│ ├─ finance/ # Requisite financial systems (payments, ledgers, rates) -│ ├─ dataroom/ # Dataroom(s) for all deals (secure VDR, deal room APIs) -│ ├─ omnis-brand/ # Branded version of OMNIS (as a service/app shell) -│ └─ arromis-brand/ # Branded version of ARROMIS (as a service/app shell) -│ -├─ packages/ # Shared libraries (versioned in the mono-repo) -│ ├─ ui/ # Design system (React/Tailwind components) -│ ├─ schemas/ # Zod/OpenAPI/JSON Schema contracts -│ ├─ auth/ # AuthZ/AuthN helpers (OIDC, wallet, eIDAS adapters) -│ ├─ storage/ # S3/GCS abstraction, object lifecycle, WORM mode -│ ├─ crypto/ # KMS/HSM client, key mgmt, signatures (eIDAS/DID) -│ ├─ workflows/ # Temporal/Step Functions definitions -│ └─ test-utils/ # Testing utilities and helpers -│ -├─ infra/ # Everything-as-code -│ ├─ terraform/ # Cloud infra, secrets backends, KMS/HSM, PKI -│ ├─ k8s/ # Helm charts/overlays (dev/stage/prod) -│ ├─ gateways/ # API gateway / proxy / WAF configs -│ └─ cicd/ # Reusable CI templates, SBOM, signing -│ -├─ docs/ # Living documentation -│ ├─ legal/ # Legal policies, ABAC, compliance frameworks -│ ├─ governance/ # Contribution, security, incident runbooks -│ ├─ reports/ # Project reports, reviews, task lists -│ ├─ architecture/ # ADRs, data flows, threat models -│ └─ product/ # Roadmaps, PRDs -│ -└─ scripts/ # Utility scripts -``` - -## Quickstart +## Quick Start ### Prerequisites - Node.js >= 18.0.0 - pnpm >= 8.0.0 -- Git +- Docker & Docker Compose +- Azure CLI (for deployments) +- Terraform >= 1.5.0 (for infrastructure) ### Installation ```bash -# Clone the repository -git clone https://github.com/the-order/the-order.git +# Clone repository +git clone cd the-order -# Initialize submodules (if any) -git submodule update --init --recursive +# Install dependencies +pnpm install +# Start local services (PostgreSQL, Redis, OpenSearch) +docker-compose up -d + +# Build all packages +pnpm build + +# Start development servers +pnpm dev +``` + +### Environment Setup + +1. Copy `.env.example` to `.env` +2. Configure Azure credentials: + ```bash + ARM_SUBSCRIPTION_ID="your-subscription-id" + ARM_TENANT_ID="your-tenant-id" + ARM_LOCATION="westeurope" + ``` +3. Load environment: + ```bash + source infra/scripts/azure-load-env.sh + ``` + +## Project Structure + +``` +the-order/ +├── apps/ # Frontend applications +├── services/ # Backend microservices +├── packages/ # Shared libraries +├── infra/ # Infrastructure as Code +├── docs/ # Documentation +└── scripts/ # Utility scripts +``` + +**📖 See [PROJECT_STRUCTURE.md](PROJECT_STRUCTURE.md) for detailed structure guide** + +## Architecture + +### Services + +- **Identity Service** (`services/identity/`): eIDAS/DID, verifiable credentials, Entra VerifiedID +- **Intake Service** (`services/intake/`): Document ingestion, OCR, classification +- **Finance Service** (`services/finance/`): Payments, ledgers, invoicing +- **Dataroom Service** (`services/dataroom/`): Virtual data rooms, deal management +- **Legal Documents Service** (`services/legal-documents/`): Comprehensive document management +- **e-Residency Service** (`services/eresidency/`): Digital residency services + +### Applications + +- **MCP Legal** (`apps/mcp-legal/`): Legal document management portal +- **Portal Public** (`apps/portal-public/`): Public-facing member portal +- **Portal Internal** (`apps/portal-internal/`): Internal administrative portal + +### Infrastructure + +- **Terraform** (`infra/terraform/`): Azure infrastructure, Cloud for Sovereignty landing zones +- **Kubernetes** (`infra/k8s/`): Container orchestration +- **Monitoring** (`infra/monitoring/`): Prometheus, Grafana + +## Documentation + +### Getting Started +- [Project Structure](PROJECT_STRUCTURE.md) - Complete structure guide +- [Quick Start Guide](QUICKSTART.md) - Development setup +- [Architecture Overview](docs/architecture/README.md) - System architecture + +### Deployment +- [Azure Deployment](docs/deployment/azure/ENVIRONMENT_SETUP.md) - Azure setup +- [Sovereignty Landing Zone](docs/deployment/azure/SOVEREIGNTY_LANDING_ZONE_DEPLOYMENT.md) - Multi-region deployment +- [Kubernetes Deployment](infra/k8s/README.md) - K8s deployment guide + +### Architecture +- [Cloud for Sovereignty Landing Zone](docs/architecture/CLOUD_FOR_SOVEREIGNTY_LANDING_ZONE.md) - Complete architecture +- [Well-Architected Framework](docs/architecture/README.md) - Architecture principles +- [Data Models](docs/architecture/README.md#data-models) - Entity relationships + +### Integrations +- [Entra VerifiedID](docs/integrations/entra-verifiedid/README.md) - Credential issuance +- [Azure CDN](docs/deployment/azure/cdn-setup.md) - CDN configuration + +### Legal System +- [Document Management](docs/legal/document-management/) - DMS documentation +- [API Documentation](docs/legal/document-management/implementation/) - API reference + +## Development + +### Commands + +```bash # Install dependencies pnpm install # Build all packages pnpm build -``` - -### Development - -```bash -# Start all apps and services in development mode -pnpm dev - -# Run specific workspace -pnpm --filter portal-public dev - -# Run linting -pnpm lint - -# Run type checking -pnpm type-check # Run tests pnpm test + +# Start development +pnpm dev + +# Lint code +pnpm lint + +# Type check +pnpm type-check ``` -### Environment Variables - -Environment variables are managed using SOPS (Secrets Operations). See `docs/governance/SECURITY.md` for details. - -1. Copy `.env.example` files to `.env.local` in each workspace -2. For encrypted secrets, use SOPS with age keys -3. Never commit plaintext secrets to the repository - -Example: -```bash -# Decrypt and load secrets -sops -d secrets/dev.env.enc > .env.local -``` - -## Environments - -- **dev**: Local development environment -- **stage**: Staging environment for testing -- **prod**: Production environment - -Environment-specific configurations are in `infra/k8s/overlays/`. - -## Git Submodules - -Some services and apps are managed as Git submodules. To add submodules: +### Working with Services ```bash -# See scripts/add-submodules.sh for examples -./scripts/add-submodules.sh +# Start specific service +pnpm --filter @the-order/identity-service dev + +# Build specific service +pnpm --filter @the-order/identity-service build + +# Test specific service +pnpm --filter @the-order/identity-service test ``` -To update submodules: +### Working with Packages + ```bash -git submodule update --remote +# Build specific package +pnpm --filter @the-order/database build + +# Test specific package +pnpm --filter @the-order/database test ``` -## Contribution +## Infrastructure -Please read [CONTRIBUTING.md](docs/governance/CONTRIBUTING.md) for details on our code of conduct and the process for submitting pull requests. +### Azure Deployment -### Development Workflow +```bash +# Load environment +source infra/scripts/azure-load-env.sh -1. Create a feature branch from `main` -2. Make your changes -3. Run tests and linting: `pnpm test && pnpm lint` -4. Commit using [Conventional Commits](https://www.conventionalcommits.org/) -5. Push and create a Pull Request +# Deploy infrastructure +./infra/scripts/azure-deploy.sh -### Code Standards +# Deploy sovereignty landing zone +./infra/scripts/deploy-sovereignty-landing-zone.sh +``` -- TypeScript strict mode enabled -- ESLint + Prettier for code formatting -- All tests must pass -- Type checking must pass -- Follow the architecture decisions in `docs/architecture/adrs/` +### Kubernetes Deployment + +```bash +# Apply base configuration +kubectl apply -k infra/k8s/base + +# Apply environment overlay +kubectl apply -k infra/k8s/overlays/dev +``` + +## Key Features + +### Digital Identity +- ✅ eIDAS compliance +- ✅ DID (Decentralized Identifiers) +- ✅ Microsoft Entra VerifiedID +- ✅ Verifiable Credentials + +### Document Management +- ✅ Document templates +- ✅ Version control +- ✅ Legal matter management +- ✅ Court filing integration +- ✅ Real-time collaboration +- ✅ E-signatures + +### Security & Compliance +- ✅ Cloud for Sovereignty +- ✅ Data residency enforcement +- ✅ Customer-managed encryption +- ✅ Private endpoints +- ✅ GDPR & eIDAS compliance + +### Infrastructure +- ✅ Multi-region deployment (7 regions) +- ✅ Well-Architected Framework +- ✅ Infrastructure as Code +- ✅ Automated deployments +- ✅ Comprehensive monitoring + +## Technology Stack + +### Frontend +- React 18+ +- Next.js 14+ +- TypeScript +- Tailwind CSS +- Material-UI + +### Backend +- Node.js 18+ +- TypeScript +- Fastify +- PostgreSQL +- Redis + +### Infrastructure +- Azure (non-US commercial regions) +- Kubernetes +- Terraform +- Docker + +### Monitoring +- Prometheus +- Grafana +- OpenTelemetry +- Log Analytics + +## Contributing + +See [CONTRIBUTING.md](docs/governance/CONTRIBUTING.md) for contribution guidelines. ## Security -See [SECURITY.md](docs/governance/SECURITY.md) for security policies and reporting procedures. - -## Architecture - -Architecture Decision Records (ADRs) are located in `docs/architecture/adrs/`. See [docs/architecture/README.md](docs/architecture/README.md) for more information. - -## Release Process - -Releases are managed via semantic versioning and automated through CI/CD: - -1. Merge to `main` triggers automated tests and builds -2. Tagged releases trigger deployment to staging -3. Manual approval required for production deployment -4. See `.github/workflows/release.yml` for details +See [SECURITY.md](docs/governance/SECURITY.md) for security policies and reporting. ## License @@ -181,11 +268,23 @@ See [LICENSE](LICENSE) for license information. ## Support -For questions and support, please open an issue in this repository. +- **Documentation**: See `docs/` directory +- **Architecture**: See `docs/architecture/` +- **Deployment**: See `docs/deployment/` +- **Issues**: Use GitHub Issues -## Related Documentation +## Status -- [Security Policy](docs/governance/SECURITY.md) -- [Contributing Guide](docs/governance/CONTRIBUTING.md) -- [Architecture Documentation](docs/architecture/README.md) -- [Product Roadmap](docs/product/README.md) +**Current Status**: Active Development + +- ✅ Core services implemented +- ✅ Legal document management complete +- ✅ Entra VerifiedID integration complete +- ✅ Multi-region infrastructure planned +- 🔄 Testing and optimization in progress + +See [docs/reports/](docs/reports/) for detailed status reports. + +--- + +**Last Updated**: 2025-01-27 diff --git a/apps/README.md b/apps/README.md new file mode 100644 index 0000000..f5179bc --- /dev/null +++ b/apps/README.md @@ -0,0 +1,86 @@ +# Applications Directory + +**Last Updated**: 2025-01-27 +**Purpose**: Frontend applications overview + +## Overview + +This directory contains frontend applications built with React, Next.js, and TypeScript. + +## Available Applications + +### MCP Legal (`mcp-legal/`) +- **Purpose**: Legal document management portal +- **Technology**: React, Material-UI, React Query +- **Features**: Document management, matter management, template library +- **Documentation**: [MCP Legal README](mcp-legal/README.md) + +### Portal Public (`portal-public/`) +- **Purpose**: Public-facing member portal +- **Technology**: Next.js, React, Tailwind CSS +- **Features**: Member services, credential management +- **Documentation**: [Portal Public README](portal-public/README.md) + +### Portal Internal (`portal-internal/`) +- **Purpose**: Internal administrative portal +- **Technology**: Next.js, React, Tailwind CSS +- **Features**: Administration, reporting, analytics +- **Documentation**: [Portal Internal README](portal-internal/README.md) + +## Application Structure + +All applications follow a consistent structure: + +``` +app/ +├── src/ +│ ├── app/ # Next.js app directory (if using App Router) +│ ├── components/ # React components +│ ├── pages/ # Next.js pages (if using Pages Router) +│ ├── hooks/ # React hooks +│ ├── utils/ # Utility functions +│ └── types/ # TypeScript types +├── public/ # Static assets +├── package.json # Dependencies +└── README.md # Application documentation +``` + +## Development + +### Running Applications + +```bash +# Start all applications +pnpm dev + +# Start specific application +pnpm --filter portal-public dev +``` + +### Building Applications + +```bash +# Build all applications +pnpm build + +# Build specific application +pnpm --filter portal-public build +``` + +## Shared Components + +Applications use shared UI components from `packages/ui/`: +```typescript +import { Button, Card, Modal } from '@the-order/ui'; +``` + +## Related Documentation + +- [Project Structure](../PROJECT_STRUCTURE.md) +- [Packages Documentation](../packages/) +- [Architecture Documentation](../docs/architecture/) + +--- + +**Last Updated**: 2025-01-27 + diff --git a/apps/mcp-legal/src/components/CourtFiling.tsx b/apps/mcp-legal/src/components/CourtFiling.tsx new file mode 100644 index 0000000..244d1f3 --- /dev/null +++ b/apps/mcp-legal/src/components/CourtFiling.tsx @@ -0,0 +1,230 @@ +/** + * Court Filing Component + * UI for court filing management + */ + +import React, { useState } from 'react'; +import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'; +import { + Box, + Button, + Card, + CardContent, + Typography, + Table, + TableBody, + TableCell, + TableHead, + TableRow, + Chip, + Dialog, + DialogTitle, + DialogContent, + DialogActions, + TextField, + FormControl, + InputLabel, + Select, + MenuItem, + Alert, +} from '@mui/material'; +import { Add as AddIcon, CalendarToday as CalendarIcon } from '@mui/icons-material'; + +interface Filing { + id: string; + document_id: string; + matter_id: string; + court_name: string; + case_number?: string; + filing_type: string; + status: string; + filing_deadline?: string; +} + +export function CourtFiling({ matterId }: { matterId: string }) { + const [createDialogOpen, setCreateDialogOpen] = useState(false); + const queryClient = useQueryClient(); + + const { data: filings } = useQuery({ + queryKey: ['filings', matterId], + queryFn: async () => { + const response = await fetch(`/api/filings?matter_id=${matterId}`); + const data = await response.json(); + return data.filings || []; + }, + }); + + const { data: deadlines } = useQuery({ + queryKey: ['filing-deadlines', matterId], + queryFn: async () => { + const response = await fetch(`/api/matters/${matterId}/filing-deadlines`); + const data = await response.json(); + return data.deadlines || []; + }, + }); + + const createFiling = useMutation({ + mutationFn: async (filing: Partial) => { + const response = await fetch('/api/filings', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(filing), + }); + return response.json(); + }, + onSuccess: () => { + queryClient.invalidateQueries({ queryKey: ['filings', matterId] }); + setCreateDialogOpen(false); + }, + }); + + const handleCreateFiling = (formData: FormData) => { + createFiling.mutate({ + matter_id: matterId, + document_id: formData.get('document_id') as string, + court_name: formData.get('court_name') as string, + case_number: formData.get('case_number') as string, + filing_type: formData.get('filing_type') as string, + filing_deadline: formData.get('filing_deadline') as string, + }); + }; + + const getStatusColor = (status: string) => { + switch (status) { + case 'filed': + return 'success'; + case 'accepted': + return 'success'; + case 'rejected': + return 'error'; + case 'submitted': + return 'info'; + default: + return 'default'; + } + }; + + return ( + + + Court Filings + + + + {deadlines && deadlines.length > 0 && ( + + Upcoming Deadlines + {deadlines.map((deadline) => ( + + {deadline.court_name}: {new Date(deadline.filing_deadline!).toLocaleDateString()} + + ))} + + )} + + + + + + Court + Case Number + Type + Status + Deadline + + + + {filings?.map((filing) => ( + + {filing.court_name} + {filing.case_number || 'N/A'} + {filing.filing_type} + + + + + {filing.filing_deadline ? ( + + + {new Date(filing.filing_deadline).toLocaleDateString()} + + ) : ( + 'N/A' + )} + + + ))} + +
+
+ + setCreateDialogOpen(false)} maxWidth="sm" fullWidth> +
{ + e.preventDefault(); + handleCreateFiling(new FormData(e.currentTarget)); + }} + > + Create Court Filing + + + + + + Filing Type + + + + + + + + +
+
+
+ ); +} + diff --git a/apps/mcp-legal/src/components/DocumentAssembly.tsx b/apps/mcp-legal/src/components/DocumentAssembly.tsx new file mode 100644 index 0000000..3d266be --- /dev/null +++ b/apps/mcp-legal/src/components/DocumentAssembly.tsx @@ -0,0 +1,208 @@ +/** + * Document Assembly Component + * UI for template-based document generation + */ + +import React, { useState } from 'react'; +import { useQuery, useMutation } from '@tanstack/react-query'; +import { + Box, + Button, + Card, + CardContent, + Stepper, + Step, + StepLabel, + TextField, + Typography, + FormControl, + InputLabel, + Select, + MenuItem, + Grid, + Chip, +} from '@mui/material'; +import { CheckCircle as CheckCircleIcon } from '@mui/icons-material'; + +interface Template { + id: string; + name: string; + variables?: string[]; +} + +export function DocumentAssembly() { + const [activeStep, setActiveStep] = useState(0); + const [selectedTemplate, setSelectedTemplate] = useState(''); + const [variables, setVariables] = useState>({}); + const [preview, setPreview] = useState(''); + + const { data: templates } = useQuery({ + queryKey: ['templates'], + queryFn: async () => { + const response = await fetch('/api/templates'); + const data = await response.json(); + return data.templates || []; + }, + }); + + const previewMutation = useMutation({ + mutationFn: async ({ templateId, vars }: { templateId: string; vars: Record }) => { + const response = await fetch(`/api/templates/${templateId}/render`, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ variables: vars }), + }); + return response.json(); + }, + onSuccess: (data) => { + setPreview(data.rendered); + setActiveStep(2); + }, + }); + + const generateMutation = useMutation({ + mutationFn: async (data: any) => { + const response = await fetch('/api/assembly/generate', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(data), + }); + return response.json(); + }, + onSuccess: () => { + setActiveStep(3); + }, + }); + + const handleNext = () => { + if (activeStep === 0 && selectedTemplate) { + // Get template variables + fetch(`/api/templates/${selectedTemplate}/variables`) + .then((res) => res.json()) + .then((data) => { + const vars: Record = {}; + data.variables?.forEach((v: string) => { + vars[v] = ''; + }); + setVariables(vars); + setActiveStep(1); + }); + } else if (activeStep === 1) { + previewMutation.mutate({ templateId: selectedTemplate, vars: variables }); + } else if (activeStep === 2) { + generateMutation.mutate({ + template_id: selectedTemplate, + variables, + title: `Document from ${templates?.find((t) => t.id === selectedTemplate)?.name}`, + save_document: true, + }); + } + }; + + const steps = ['Select Template', 'Enter Variables', 'Preview', 'Complete']; + + return ( + + + Document Assembly + + + + {steps.map((label) => ( + + {label} + + ))} + + + {activeStep === 0 && ( + + {templates?.map((template) => ( + + setSelectedTemplate(template.id)} + > + + {template.name} + + + + ))} + + )} + + {activeStep === 1 && ( + + + + Enter Variable Values + + {Object.keys(variables).map((key) => ( + setVariables({ ...variables, [key]: e.target.value })} + margin="normal" + /> + ))} + + + )} + + {activeStep === 2 && ( + + + + Preview + + + {preview || 'Generating preview...'} + + + + )} + + {activeStep === 3 && ( + + + + + Document Generated Successfully! + + + + + )} + + + + {activeStep < 3 && ( + + )} + + + ); +} + diff --git a/apps/mcp-legal/src/components/DocumentManagement.tsx b/apps/mcp-legal/src/components/DocumentManagement.tsx new file mode 100644 index 0000000..1228fa7 --- /dev/null +++ b/apps/mcp-legal/src/components/DocumentManagement.tsx @@ -0,0 +1,286 @@ +/** + * Document Management Component + * Main UI for document management in MCP Legal app + */ + +import React, { useState, useEffect } from 'react'; +import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'; +import { + Box, + Button, + Card, + CardContent, + CardHeader, + Chip, + Dialog, + DialogActions, + DialogContent, + DialogTitle, + FormControl, + InputLabel, + MenuItem, + Select, + TextField, + Typography, + Table, + TableBody, + TableCell, + TableHead, + TableRow, + IconButton, + Tooltip, +} from '@mui/material'; +import { + Add as AddIcon, + Edit as EditIcon, + Delete as DeleteIcon, + Visibility as ViewIcon, + History as HistoryIcon, + Download as DownloadIcon, + Share as ShareIcon, +} from '@mui/icons-material'; + +interface Document { + id: string; + title: string; + type: string; + status: string; + created_at: string; + updated_at: string; +} + +interface DocumentManagementProps { + matterId?: string; +} + +export function DocumentManagement({ matterId }: DocumentManagementProps) { + const [selectedDocument, setSelectedDocument] = useState(null); + const [createDialogOpen, setCreateDialogOpen] = useState(false); + const [viewDialogOpen, setViewDialogOpen] = useState(false); + const [filterType, setFilterType] = useState('all'); + const queryClient = useQueryClient(); + + // Fetch documents + const { data: documents, isLoading } = useQuery({ + queryKey: ['documents', matterId, filterType], + queryFn: async () => { + const params = new URLSearchParams(); + if (matterId) params.append('matter_id', matterId); + if (filterType !== 'all') params.append('type', filterType); + const response = await fetch(`/api/documents?${params}`); + if (!response.ok) throw new Error('Failed to fetch documents'); + const data = await response.json(); + return data.documents || []; + }, + }); + + // Create document mutation + const createDocument = useMutation({ + mutationFn: async (doc: Partial) => { + const response = await fetch('/api/documents', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(doc), + }); + if (!response.ok) throw new Error('Failed to create document'); + return response.json(); + }, + onSuccess: () => { + queryClient.invalidateQueries({ queryKey: ['documents'] }); + setCreateDialogOpen(false); + }, + }); + + // Delete document mutation + const deleteDocument = useMutation({ + mutationFn: async (id: string) => { + const response = await fetch(`/api/documents/${id}`, { + method: 'DELETE', + }); + if (!response.ok) throw new Error('Failed to delete document'); + }, + onSuccess: () => { + queryClient.invalidateQueries({ queryKey: ['documents'] }); + }, + }); + + const handleCreateDocument = (formData: FormData) => { + createDocument.mutate({ + title: formData.get('title') as string, + type: formData.get('type') as string, + content: formData.get('content') as string, + matter_id: matterId, + }); + }; + + const handleViewDocument = (doc: Document) => { + setSelectedDocument(doc); + setViewDialogOpen(true); + }; + + const handleDeleteDocument = (id: string) => { + if (confirm('Are you sure you want to delete this document?')) { + deleteDocument.mutate(id); + } + }; + + return ( + + + Documents + + + Filter + + + + + + + {isLoading ? ( + Loading... + ) : ( + + + + + Title + Type + Status + Created + Actions + + + + {documents?.map((doc) => ( + + {doc.title} + + + + + + + {new Date(doc.created_at).toLocaleDateString()} + + + handleViewDocument(doc)}> + + + + + + + + + + + + + + + handleDeleteDocument(doc.id)} + > + + + + + + ))} + +
+
+ )} + + {/* Create Document Dialog */} + setCreateDialogOpen(false)} maxWidth="md" fullWidth> +
{ + e.preventDefault(); + handleCreateDocument(new FormData(e.currentTarget)); + }} + > + Create New Document + + + + Type + + + + + + + + +
+
+ + {/* View Document Dialog */} + setViewDialogOpen(false)} maxWidth="lg" fullWidth> + {selectedDocument?.title} + + {selectedDocument && ( + + + Type: {selectedDocument.type} | Status: {selectedDocument.status} + + + Created: {new Date(selectedDocument.created_at).toLocaleString()} + + + )} + + + + + + +
+ ); +} + diff --git a/apps/mcp-legal/src/components/DocumentWorkflow.tsx b/apps/mcp-legal/src/components/DocumentWorkflow.tsx new file mode 100644 index 0000000..68e2526 --- /dev/null +++ b/apps/mcp-legal/src/components/DocumentWorkflow.tsx @@ -0,0 +1,218 @@ +/** + * Document Workflow Component + * UI for workflow management and approval + */ + +import React, { useState } from 'react'; +import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'; +import { + Box, + Button, + Card, + CardContent, + LinearProgress, + Typography, + Chip, + List, + ListItem, + ListItemText, + Dialog, + DialogTitle, + DialogContent, + DialogActions, + TextField, +} from '@mui/material'; +import { + CheckCircle as ApproveIcon, + Cancel as RejectIcon, + Assignment as AssignmentIcon, +} from '@mui/icons-material'; + +interface Workflow { + id: string; + document_id: string; + workflow_type: string; + status: string; + steps: WorkflowStep[]; +} + +interface WorkflowStep { + id: string; + step_number: number; + step_type: string; + status: string; + assigned_to?: string; + due_date?: string; +} + +export function DocumentWorkflow({ documentId }: { documentId: string }) { + const [approvalDialogOpen, setApprovalDialogOpen] = useState(false); + const [selectedStep, setSelectedStep] = useState(null); + const [comments, setComments] = useState(''); + const queryClient = useQueryClient(); + + const { data: workflow } = useQuery({ + queryKey: ['workflow', documentId], + queryFn: async () => { + const response = await fetch(`/api/documents/${documentId}/workflows`); + const data = await response.json(); + return data.workflows?.[0] || null; + }, + }); + + const approveStep = useMutation({ + mutationFn: async ({ stepId, comments: cmts }: { stepId: string; comments?: string }) => { + const response = await fetch(`/api/workflows/steps/${stepId}/complete`, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ status: 'approved', comments: cmts }), + }); + return response.json(); + }, + onSuccess: () => { + queryClient.invalidateQueries({ queryKey: ['workflow', documentId] }); + setApprovalDialogOpen(false); + }, + }); + + const rejectStep = useMutation({ + mutationFn: async ({ stepId, comments: cmts }: { stepId: string; comments?: string }) => { + const response = await fetch(`/api/workflows/steps/${stepId}/complete`, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ status: 'rejected', comments: cmts }), + }); + return response.json(); + }, + onSuccess: () => { + queryClient.invalidateQueries({ queryKey: ['workflow', documentId] }); + setApprovalDialogOpen(false); + }, + }); + + if (!workflow) { + return No workflow found for this document; + } + + const completedSteps = workflow.steps?.filter((s) => s.status === 'approved' || s.status === 'rejected').length || 0; + const totalSteps = workflow.steps?.length || 1; + const progress = (completedSteps / totalSteps) * 100; + + return ( + + + Workflow: {workflow.workflow_type} + + + + + + + Progress + + + + {completedSteps} of {totalSteps} steps completed + + + + + + + + Workflow Steps + + + {workflow.steps?.map((step) => ( + + + + + ) : ( + + ) + } + > + + + + ))} + + + + + setApprovalDialogOpen(false)}> + + {selectedStep?.status === 'pending' ? 'Approve or Reject Step' : 'Add Comments'} + + + setComments(e.target.value)} + sx={{ mt: 2 }} + /> + + + + + + + + + ); +} + diff --git a/apps/mcp-legal/src/components/MatterManagement.tsx b/apps/mcp-legal/src/components/MatterManagement.tsx new file mode 100644 index 0000000..f321591 --- /dev/null +++ b/apps/mcp-legal/src/components/MatterManagement.tsx @@ -0,0 +1,228 @@ +/** + * Matter Management Component + * UI for legal matter management + */ + +import React, { useState } from 'react'; +import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'; +import { + Box, + Button, + Card, + CardContent, + Chip, + Dialog, + DialogActions, + DialogContent, + DialogTitle, + TextField, + Typography, + Table, + TableBody, + TableCell, + TableHead, + TableRow, + IconButton, + Tabs, + Tab, +} from '@mui/material'; +import { + Add as AddIcon, + Edit as EditIcon, + Folder as FolderIcon, + People as PeopleIcon, + Description as DescriptionIcon, +} from '@mui/icons-material'; +import { DocumentManagement } from './DocumentManagement'; + +interface Matter { + id: string; + matter_number: string; + title: string; + status: string; + matter_type?: string; + client_id?: string; + created_at: string; +} + +export function MatterManagement() { + const [selectedMatter, setSelectedMatter] = useState(null); + const [createDialogOpen, setCreateDialogOpen] = useState(false); + const [tabValue, setTabValue] = useState(0); + const queryClient = useQueryClient(); + + const { data: matters, isLoading } = useQuery({ + queryKey: ['matters'], + queryFn: async () => { + const response = await fetch('/api/matters'); + if (!response.ok) throw new Error('Failed to fetch matters'); + const data = await response.json(); + return data.matters || []; + }, + }); + + const createMatter = useMutation({ + mutationFn: async (matter: Partial) => { + const response = await fetch('/api/matters', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(matter), + }); + if (!response.ok) throw new Error('Failed to create matter'); + return response.json(); + }, + onSuccess: () => { + queryClient.invalidateQueries({ queryKey: ['matters'] }); + setCreateDialogOpen(false); + }, + }); + + const handleCreateMatter = (formData: FormData) => { + createMatter.mutate({ + matter_number: formData.get('matter_number') as string, + title: formData.get('title') as string, + description: formData.get('description') as string, + matter_type: formData.get('matter_type') as string, + status: 'open', + }); + }; + + return ( + + + Legal Matters + + + + {selectedMatter ? ( + + + setSelectedMatter(null)}>← + {selectedMatter.title} + + + + setTabValue(v)}> + } label="Documents" /> + } label="Participants" /> + } label="Details" /> + + + + {tabValue === 0 && } + {tabValue === 1 && Participants coming soon} + {tabValue === 2 && ( + + + Matter Details + Number: {selectedMatter.matter_number} + Type: {selectedMatter.matter_type || 'N/A'} + Status: {selectedMatter.status} + + + )} + + + ) : ( + <> + {isLoading ? ( + Loading... + ) : ( + + + + + Matter Number + Title + Type + Status + Actions + + + + {matters?.map((matter) => ( + setSelectedMatter(matter)} + sx={{ cursor: 'pointer' }} + > + {matter.matter_number} + {matter.title} + {matter.matter_type || 'N/A'} + + + + + + + + + + ))} + +
+
+ )} + + )} + + setCreateDialogOpen(false)} maxWidth="sm" fullWidth> +
{ + e.preventDefault(); + handleCreateMatter(new FormData(e.currentTarget)); + }} + > + Create New Matter + + + + + + + + + + +
+
+
+ ); +} + diff --git a/apps/mcp-legal/src/components/TemplateLibrary.tsx b/apps/mcp-legal/src/components/TemplateLibrary.tsx new file mode 100644 index 0000000..1a54ccb --- /dev/null +++ b/apps/mcp-legal/src/components/TemplateLibrary.tsx @@ -0,0 +1,252 @@ +/** + * Template Library Component + * UI for document template management + */ + +import React, { useState } from 'react'; +import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'; +import { + Box, + Button, + Card, + CardContent, + CardHeader, + Chip, + Dialog, + DialogActions, + DialogContent, + DialogTitle, + TextField, + Typography, + Grid, + IconButton, + MenuItem, + Select, + FormControl, + InputLabel, +} from '@mui/material'; +import { + Add as AddIcon, + Edit as EditIcon, + Preview as PreviewIcon, + FileCopy as FileCopyIcon, +} from '@mui/icons-material'; + +interface Template { + id: string; + name: string; + description?: string; + category?: string; + version: number; + is_active: boolean; +} + +export function TemplateLibrary() { + const [selectedTemplate, setSelectedTemplate] = useState