# The Order

**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 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

Built with **Cloud for Sovereignty** principles, ensuring data residency, compliance, and operational control.

## Quick Start

### Prerequisites

- Node.js >= 18.0.0
- pnpm >= 8.0.0
- Docker & Docker Compose
- Azure CLI (for deployments)
- Terraform >= 1.5.0 (for infrastructure)

### Installation

```bash
# Clone repository
git clone <repository-url>
cd the-order

# 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

# Run tests
pnpm test

# Start development
pnpm dev

# Lint code
pnpm lint

# Type check
pnpm type-check
```

### Working with Services

```bash
# 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
```

### Working with Packages

```bash
# Build specific package
pnpm --filter @the-order/database build

# Test specific package
pnpm --filter @the-order/database test
```

## Infrastructure

### Azure Deployment

```bash
# Load environment
source infra/scripts/azure-load-env.sh

# Deploy infrastructure
./infra/scripts/azure-deploy.sh

# Deploy sovereignty landing zone
./infra/scripts/deploy-sovereignty-landing-zone.sh
```

### 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.

## License

See [LICENSE](LICENSE) for license information.

## Support

- **Documentation**: See `docs/` directory
- **Architecture**: See `docs/architecture/`
- **Deployment**: See `docs/deployment/`
- **Issues**: Use GitHub Issues

## Status

**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
