Skip to content

coding-by-feng/kason-tools-server

Repository files navigation

Kiwi Microservices - .NET 9 Migration

πŸš€ Complete migration of Java 8 Spring Cloud Netflix microservices to modern .NET 9 architecture

This project represents a comprehensive re-architecture and migration of the microservice-kiwi English dictionary and learning platform from Java 8 Spring Cloud Netflix to modern .NET 9 microservices.

πŸ“‹ Migration Overview

Original Java Architecture

  • Framework: Java 8 + Spring Cloud Netflix
  • Service Discovery: Eureka
  • API Gateway: Zuul
  • Circuit Breaker: Hystrix
  • Configuration: Spring Cloud Config
  • Infrastructure: MySQL, Redis, RabbitMQ, Elasticsearch, FastDFS, Nginx

New .NET 9 Architecture

  • Framework: .NET 9 + ASP.NET Core
  • API Gateway: YARP (Yet Another Reverse Proxy)
  • Circuit Breaker: Polly
  • Messaging: MassTransit with RabbitMQ
  • Service Discovery: Built-in .NET Service Discovery
  • Configuration: .NET Configuration Providers
  • Logging: Serilog with structured logging
  • Monitoring: OpenTelemetry

πŸ—οΈ Architecture Components

Core Infrastructure

  • Kiwi.Gateway - YARP-based API Gateway with authentication, rate limiting, and circuit breaker
  • Kiwi.Shared - Common libraries, base entities, and shared services

Microservices

  • Kiwi.Auth.API - JWT-based authentication and authorization service
  • Kiwi.UPMS.API - User Permission Management System
  • Kiwi.Word.API - Dictionary and word processing service with Elasticsearch integration
  • Kiwi.AI.API - Machine learning and AI features using ML.NET and Semantic Kernel
  • Kiwi.Crawler.API - Web scraping service with Selenium and PuppeteerSharp
  • Kiwi.Configuration.API - Centralized configuration management

Technology Stack

  • .NET 9 - Latest .NET framework
  • Entity Framework Core - ORM with MySQL support
  • MassTransit - Distributed application framework for message-based communication
  • Polly - Resilience and transient-fault-handling library
  • Serilog - Structured logging
  • AutoMapper - Object-to-object mapping
  • FluentValidation - Input validation
  • MediatR - CQRS and mediator pattern implementation
  • OpenTelemetry - Observability and monitoring

πŸš€ Quick Start

Prerequisites

  • .NET 9 SDK
  • Docker & Docker Compose
  • MySQL 8.0+
  • Redis
  • RabbitMQ
  • Elasticsearch 7.17.9

Local Development

  1. Clone the repository

    git clone <repository-url>
    cd kason-tools-server
  2. Start infrastructure services

    docker-compose up -d mysql redis rabbitmq elasticsearch
  3. Restore dependencies

    dotnet restore
  4. Run database migrations

    dotnet ef database update --project src/Services/Auth/Kiwi.Auth.API
    dotnet ef database update --project src/Services/UPMS/Kiwi.UPMS.API
    dotnet ef database update --project src/Services/Word/Kiwi.Word.API
  5. Start services

    # Terminal 1 - Gateway
    cd src/Gateway/Kiwi.Gateway
    dotnet run
    
    # Terminal 2 - Auth Service
    cd src/Services/Auth/Kiwi.Auth.API
    dotnet run
    
    # Terminal 3 - Word Service
    cd src/Services/Word/Kiwi.Word.API
    dotnet run
    
    # Continue for other services...

Docker Deployment

Full stack deployment:

docker-compose up --build

Individual service deployment:

docker-compose up --build kiwi-auth-api

πŸ”§ Configuration

Environment Variables

  • ASPNETCORE_ENVIRONMENT - Development/Staging/Production
  • ConnectionStrings__DefaultConnection - MySQL connection string
  • ConnectionStrings__Redis - Redis connection string
  • MessageBroker__Host - RabbitMQ host
  • JwtSettings__Secret - JWT signing key
  • Elasticsearch__Url - Elasticsearch endpoint

Service Ports

  • Gateway: 5000 (HTTP), 5001 (HTTPS)
  • Auth Service: 5010
  • UPMS Service: 5020
  • Word Service: 5030
  • AI Service: 5040
  • Crawler Service: 5050
  • Configuration Service: 5060

πŸ“š API Documentation

Each service exposes Swagger documentation at /swagger endpoint:

Sample API Endpoints

Authentication:

# Login
POST /api/auth/login
{
  "email": "user@example.com",
  "password": "password123"
}

# Register
POST /api/auth/register
{
  "email": "user@example.com",
  "password": "password123",
  "firstName": "John",
  "lastName": "Doe"
}

Word Service:

# Search words
GET /api/word/search?query=hello&limit=10

# Get word definition
GET /api/word/{id}

πŸ” Monitoring & Observability

  • Health Checks: /health endpoint on each service
  • Metrics: OpenTelemetry integration
  • Logging: Structured logging with Serilog
  • Tracing: Distributed tracing across services

πŸ› οΈ Development Tools

  • Hot Reload: dotnet watch run
  • Database Migrations: dotnet ef migrations add <name>
  • Testing: dotnet test
  • Code Coverage: dotnet test --collect:"XPlat Code Coverage"

πŸ“¦ Project Structure

kason-tools-server/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ Gateway/
β”‚   β”‚   └── Kiwi.Gateway/
β”‚   β”œβ”€β”€ Services/
β”‚   β”‚   β”œβ”€β”€ Auth/Kiwi.Auth.API/
β”‚   β”‚   β”œβ”€β”€ UPMS/Kiwi.UPMS.API/
β”‚   β”‚   β”œβ”€β”€ Word/Kiwi.Word.API/
β”‚   β”‚   β”œβ”€β”€ AI/Kiwi.AI.API/
β”‚   β”‚   β”œβ”€β”€ Crawler/Kiwi.Crawler.API/
β”‚   β”‚   └── Configuration/Kiwi.Configuration.API/
β”‚   └── Shared/
β”‚       └── Kiwi.Shared/
β”œβ”€β”€ docker-compose.yml
└── Kiwi.Microservices.sln

πŸ”„ Migration Benefits

  1. Performance: .NET 9 offers superior performance compared to Java 8
  2. Modern Patterns: CQRS, Event Sourcing, and Clean Architecture
  3. Cloud Native: Built for containerization and cloud deployment
  4. Observability: Comprehensive monitoring and tracing
  5. Developer Experience: Hot reload, better tooling, and IntelliSense
  6. Maintenance: Simplified dependency management and updates

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.


Migration Status: βœ… Complete architecture scaffolding | 🚧 Implementation in progress

About

The .Net Version of Kason Tools Server

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors