How undertakerprog/speedtest works
Project Overview & Type
• The SpeedTest project is a multi-faceted application that includes both a full-stack ASP.NET backend (Web API) and a WPF-based Desktop client.
• Its primary purpose is to provide various network tests – managing server lists, measuring ping values, determining user and server locations, and testing download speeds.
• The README highlights robust backend API endpoints (with Swagger documentation) along with a desktop user interface. Docker and Redis are used for containerization and caching support, respectively.
Analyzing the File Structure
• Top-level Directories/Projects:
• Desktop: Contains the WPF-based desktop application including its UI pages (XAML files and code-behind), models, helpers, and service layers for local tests.
• Web: Contains the ASP.NET backend project, organized into subdirectories for controllers (named “Сontroller”), services, models, and caching (using Redis).
• Infrastructure: A separate library (class library) that encapsulates file operations and other foundational helpers, which may be shared across projects.
• WebTest: Contains MSTest-based tests for API endpoints, service logic, and models, ensuring that the API behaves as expected.
• Additional files: Docker configuration files (docker-compose.yml, Dockerfile) for running the project in containers and CI/CD configuration files for automated builds (under .github/workflows).
Main Components in the Architecture
a. Desktop Client:
• Built with WPF, responsible for allowing users to perform speed tests, select servers, and monitor speeds.
• Interfaces with the backend APIs for performing tests.
b. ASP.NET Backend (Web API):
• Exposes endpoints grouped by functionality: Location, Ping, Server management, and SpeedTest.
• Implements key business logic for determining the best or nearest server, running speed tests, and caching responses.
• Uses Swagger for auto-generated API documentation.
c. Infrastructure Library:
• Provides common functionalities (e.g., file reading) to be utilized by one or more of the other projects.
d. Redis Caching:
• Acts as a caching layer to store and quickly retrieve data (e.g., server-city details).
• Configured in appsettings and tested via endpoints.
e. Testing Layer:
• The WebTest project provides automated tests to validate controllers and service logic.
f. Docker & CI/CD Integration:
• Dockerfiles and Docker Compose configuration facilitate containerized deployment.
• CI/CD workflows (as found in .github/workflows) automate build and deployment processes.
Relationships & Interactions
• The Desktop application communicates with the ASP.NET backend via HTTP calls – consuming endpoints for speed tests, server selections, and more.
• The Web API interacts with Redis for caching efficient results, especially for retrieving server data quickly.
• The Infrastructure project serves as a shared library used by the Desktop and potentially the Web API.
• Unit and integration tests in the WebTest project verify the correctness of business logic and API endpoints.
Important Architectural Patterns/Design Principles
• Separation of Concerns: The front end (TUI in WPF) is separate from the backend logic which is structured into controllers, models, and services.
• Layered Architecture / MVC (for the Web API): Controllers forward requests to corresponding services, and responses are packaged with clearly defined models.
• Dependency Injection & Interface-Driven Design: Both the API and the desktop client use service abstractions (like ILocationService, IPingService, etc.) to decouple components.
• Containerization: Docker is used to package and deploy the application, aiding scalability and simplified environment setup.
Technology Highlights
• ASP.NET for backend endpoint implementation along with Swagger for documentation.
• WPF for the Desktop client interface.
• Redis for caching to improve performance and reduce load times.
• MSTest for unit testing ensuring the application’s robustness.
• Docker/Docker Compose for containerized deployment.