xpeditis2.0/apps/backend
David 76d940d73b feat: ajouter l'onglet Historique des devis et remplacer le statut Paiement en attente
Le statut PENDING_PAYMENT ne designe plus un paiement en attente mais un devis :
une reservation construite dont les frais de booking ne sont pas encore regles.
L'enum backend devient QUOTE, converti en place par migration.

Les deux onglets se partagent desormais la meme liste :
- « Reservations » n'affiche que PENDING, ACCEPTED et REJECTED ;
- « Historique des devis » regroupe QUOTE, PENDING_BANK_TRANSFER et CANCELLED,
  avec les actions propres a un devis (modifier, payer, supprimer).

La table, l'export et les filtres sont extraits dans BookingListView pour eviter
de dupliquer la page entre les deux vues.

Tableau de bord :
- l'alerte « Paiement en attente » disparait des points a traiter, les devis non
  regles ne bloquant aucun envoi en cours ;
- « Sans reponse du transporteur » devient « En attente du transporteur ».

Migration verifiee en transaction annulee sur la base de dev : les lignes
PENDING_PAYMENT deviennent QUOTE, l'enum et le defaut de colonne suivent.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NZJ5aowZJVAcyPZw5TiNEm
2026-09-14 11:43:57 +02:00
..
docs fix email send 2025-12-05 13:55:40 +01:00
load-tests feature 2025-11-04 07:30:15 +01:00
postman feat: Phase 4 - Production-ready security, monitoring & testing infrastructure 2025-10-14 18:46:18 +02:00
scripts feat(infra): adaptateur OpenAI et index de connaissances du wiki 2026-09-07 21:40:51 +02:00
src feat: ajouter l'onglet Historique des devis et remplacer le statut Paiement en attente 2026-09-14 11:43:57 +02:00
test fix v1.0.0 2025-12-23 11:49:57 +01:00
.dockerignore fix 2026-02-10 22:48:23 +01:00
.env.example feat(auth): amorcer l administrateur depuis l environnement et neutraliser les comptes de test 2026-09-07 21:40:50 +02:00
.eslintrc.js fix v1.0.0 2025-12-23 11:49:57 +01:00
docker-entrypoint.sh fix portainer deploy 2025-11-19 15:17:53 +01:00
Dockerfile fix security 2026-06-12 11:33:37 +02:00
nest-cli.json feat(infra): adaptateur OpenAI et index de connaissances du wiki 2026-09-07 21:40:51 +02:00
package-lock.json feat(api): purge periodique des donnees arrivees a echeance 2026-09-07 21:40:57 +02:00
package.json feat(api): purge periodique des donnees arrivees a echeance 2026-09-07 21:40:57 +02:00
README.md first commit 2025-10-07 18:39:32 +02:00
tsconfig.build.json fix blog 2026-05-12 21:01:52 +02:00
tsconfig.json fix: use tsc directly instead of nest build to resolve path aliases 2025-11-17 01:41:28 +01:00
tsconfig.test.json fix preprod 2025-11-12 18:10:52 +01:00

Xpeditis Backend API

NestJS-based API for the Xpeditis maritime freight booking platform, built with Hexagonal Architecture.

🏗️ Architecture

This backend follows Hexagonal Architecture (Ports & Adapters pattern):

src/
├── domain/              # 🔵 Pure business logic (NO external dependencies)
│   ├── entities/       # Business entities
│   ├── value-objects/  # Value objects (Email, PortCode, etc.)
│   ├── services/       # Domain services
│   ├── ports/
│   │   ├── in/        # API Ports (use cases exposed by domain)
│   │   └── out/       # SPI Ports (interfaces required by domain)
│   └── exceptions/    # Business exceptions
│
├── application/         # 🟢 Controllers & DTOs
│   ├── controllers/    # REST controllers
│   ├── dto/           # Data Transfer Objects
│   ├── mappers/       # DTO ↔ Domain mappers
│   └── config/        # Application configuration
│
└── infrastructure/      # 🟡 External integrations
    ├── persistence/    # TypeORM repositories
    ├── cache/         # Redis cache adapter
    ├── carriers/      # Maersk, MSC, CMA CGM connectors
    ├── email/         # Email service adapter
    ├── storage/       # S3 storage adapter
    └── config/        # Infrastructure configuration

Key Principles

  1. Domain is isolated: No imports of NestJS, TypeORM, or any framework in domain layer
  2. Dependencies point inward: Infrastructure → Application → Domain
  3. Testable: Domain can be tested without any framework
  4. Flexible: Change database, framework, or external services without touching domain

🚀 Quick Start

Prerequisites

  • Node.js 20+
  • PostgreSQL 15+
  • Redis 7+
  • Docker (optional, for local development)

Install Dependencies

npm install

Setup Environment

cp .env.example .env
# Edit .env with your configuration

Start Development Server

npm run dev

Server runs on: http://localhost:4000

API Documentation: http://localhost:4000/api/docs

📝 Available Scripts

Development

  • npm run dev - Start development server with hot reload
  • npm run start - Start server
  • npm run start:debug - Start with debugging
  • npm run build - Build for production
  • npm run start:prod - Start production server

Testing

  • npm test - Run unit tests
  • npm run test:watch - Run tests in watch mode
  • npm run test:cov - Run tests with coverage
  • npm run test:e2e - Run end-to-end tests
  • npm run test:debug - Debug tests

Code Quality

  • npm run lint - Lint code
  • npm run format - Format code with Prettier

Database

  • npm run migration:generate -- src/infrastructure/persistence/migrations/MigrationName - Generate migration
  • npm run migration:run - Run migrations
  • npm run migration:revert - Revert last migration

🔑 Environment Variables

See .env.example for all available variables.

Required:

  • DATABASE_HOST, DATABASE_PORT, DATABASE_USER, DATABASE_PASSWORD, DATABASE_NAME
  • REDIS_HOST, REDIS_PORT, REDIS_PASSWORD
  • JWT_SECRET

Optional (for production):

  • OAuth credentials (Google, Microsoft)
  • Carrier API keys (Maersk, MSC, CMA CGM, etc.)
  • AWS S3 credentials
  • Email service credentials
  • Sentry DSN

📚 API Documentation

Swagger/OpenAPI documentation is available at /api/docs when the server is running.

Endpoints:

Health

  • GET /api/v1/health - Health check
  • GET /api/v1/health/ready - Readiness check
  • GET /api/v1/health/live - Liveness check

(More endpoints will be added in Phase 1)

🧪 Testing

Unit Tests

Test domain logic without any external dependencies:

npm test

Example (domain/services/booking.service.spec.ts):

describe('BookingService', () => {
  it('should create booking with valid rate quote', () => {
    const service = new BookingService(mockRepository);
    const result = service.createBooking(validInput);
    expect(result.bookingNumber).toMatch(/^WCM-\d{4}-[A-Z0-9]{6}$/);
  });
});

Integration Tests

Test infrastructure adapters with real dependencies:

npm run test:e2e

Coverage

npm run test:cov

Targets:

  • Domain: 90%+
  • Application: 80%+
  • Infrastructure: 70%+

🏛️ Hexagonal Architecture Guidelines

✅ DO

  • Domain layer:

    • Pure TypeScript classes
    • Define interfaces (ports)
    • Implement business logic
    • Throw domain exceptions
  • Application layer:

    • Import from @domain/* only
    • Validate DTOs
    • Map DTOs ↔ Domain entities
    • Handle HTTP-specific concerns
  • Infrastructure layer:

    • Import from @domain/* only
    • Implement port interfaces
    • Handle framework-specific code
    • Map ORM entities ↔ Domain entities

❌ DON'T

  • Import NestJS decorators in domain
  • Import TypeORM in domain
  • Put business logic in controllers
  • Put business logic in repositories
  • Use any type
  • Skip tests

🔒 Security

  • Passwords hashed with bcrypt (12 rounds)
  • JWT tokens (access: 15min, refresh: 7 days)
  • Helmet.js for security headers
  • CORS configured
  • Rate limiting enabled
  • Input validation with class-validator
  • SQL injection prevention (TypeORM)
  • XSS protection

📊 Logging

Using Pino logger with structured JSON logs.

Log levels:

  • Development: debug
  • Production: info

Pretty print in development with pino-pretty.

🚢 Carrier Integrations

MVP supports these carriers:

  • Maersk
  • MSC
  • CMA CGM
  • Hapag-Lloyd
  • ONE (Ocean Network Express)

Each connector implements CarrierConnectorPort with:

  • Circuit breaker (5s timeout)
  • Retry logic
  • Rate limiting
  • Error normalization

📖 Further Reading

🤝 Contributing

  1. Follow hexagonal architecture principles
  2. Write tests (domain: 90%+, application: 80%+)
  3. Use TypeScript strict mode
  4. Format with Prettier
  5. Lint with ESLint
  6. Document API with Swagger decorators

📝 License

Proprietary - All rights reserved


Built with ❤️ using NestJS and Hexagonal Architecture