π Streamline your logistics operations with OnWay, a robust C# ASP.NET Core API for managing shipments, deliveries, drivers, and vehicles. Built with Domain-Driven Design (DDD) and Clean Architecture, OnWay provides a scalable solution for logistics businesses.
β Authentication & Authorization β Secure login, registration, and account verification β Shipment Management β Create, track, and manage shipments with real-time updates β Driver & Vehicle Assignment β Assign drivers and vehicles to shipments efficiently β Geolocation & Routing β Generate Waze routes using Geoapify API β Package Tracking β Add, track, and manage packages within shipments β Real-Time Status Updates β Monitor shipment status (Created, In Transit, Delivered, etc.) β Scalable & Maintainable β Built with DDD, CQRS, and Repository Pattern
| Category | Technologies Used |
|---|---|
| Language | C# (.NET 8) |
| Framework | ASP.NET Core Web API |
| Architecture | Domain-Driven Design (DDD) |
| Database | SQL (PostgreSQL, SQL Server) |
| Geocoding | Geoapify API (for address resolution) |
| Routing | Waze API (for real-time navigation) |
| Authentication | JWT (JSON Web Tokens) |
| Testing | xUnit, Moq (Mocking) |
- .NET 8 SDK (Download here)
- PostgreSQL / SQL Server (for database storage)
- Geoapify API Key (for geolocation services)
- Waze API Key (for route generation)
-
Clone the repository
git clone https://github.com/your-repo/OnWay.git cd OnWay -
Restore dependencies
dotnet restore
-
Set up environment variables Create a
.envfile insrc/ONW_API/with:ASPNETCORE_ENVIRONMENT=Development GEOAPIFY_API_KEY=your_geoapify_key WAZE_API_KEY=your_waze_key
-
Run migrations (if using Entity Framework Core)
dotnet ef migrations add InitialCreate dotnet ef database update
-
Start the API
dotnet run --project src/ONW_API/ONW_API.csproj
-
Access the API The API will be available at
http://localhost:5000
using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
var client = new HttpClient();
var url = "https://localhost:5000/api/auth/register";
var command = new
{
Email = "transporter@example.com",
Password = "SecurePassword123!",
Name = "John Doe",
Phone = "+5511999999999"
};
var json = JsonSerializer.Serialize(command);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync(url, content);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);var loginUrl = "https://localhost:5000/api/auth/login";
var loginCommand = new { Email = "transporter@example.com", Password = "SecurePassword123!" };
var loginJson = JsonSerializer.Serialize(loginCommand);
var loginContent = new StringContent(loginJson, Encoding.UTF8, "application/json");
var loginResponse = await client.PostAsync(loginUrl, loginContent);
var loginResult = await loginResponse.Content.ReadAsStringAsync();
var loginData = JsonSerializer.Deserialize<dynamic>(loginResult);
var token = loginData.AccessToken;var shipmentUrl = "https://localhost:5000/api/shipments";
var shipmentRequest = new
{
Origin = new { Address = "Rua A", City = "SΓ£o Paulo", State = "SP" },
Destination = new { Address = "Rua B", City = "Rio de Janeiro", State = "RJ" }
};
var shipmentJson = JsonSerializer.Serialize(shipmentRequest);
var shipmentContent = new StringContent(shipmentJson, Encoding.UTF8, "application/json");
shipmentContent.Headers.Add("Authorization", $"Bearer {token}");
var shipmentResponse = await client.PostAsync(shipmentUrl, shipmentContent);
var shipmentResult = await shipmentResponse.Content.ReadAsStringAsync();
Console.WriteLine(shipmentResult);var wazeUrl = "https://localhost:5000/geolocation/waze-route";
var wazeRequest = new
{
Street = "Rua A",
Number = "123",
District = "Centro",
City = "SΓ£o Paulo",
State = "SP",
ZipCode = "01000000"
};
var wazeJson = JsonSerializer.Serialize(wazeRequest);
var wazeContent = new StringContent(wazeJson, Encoding.UTF8, "application/json");
wazeContent.Headers.Add("Authorization", $"Bearer {token}");
var wazeResponse = await client.PostAsync(wazeUrl, wazeContent);
var wazeResult = await wazeResponse.Content.ReadAsStringAsync();
Console.WriteLine(wazeResult);OnWay/
βββ src/
β βββ ONW_API/ # Main API project
β β βββ API/ # Controllers & DTOs
β β βββ Application/ # Use Cases & Commands
β β βββ Domain/ # Core business logic
β β βββ Infrastructure/ # External services (Geoapify, Waze)
β β βββ ONW_API.csproj # Project file
β βββ Tests/ # Unit & Integration Tests
βββ .gitignore
βββ README.md # This file
βββ LICENSE
| Variable | Description | Example Value |
|---|---|---|
GEOAPIFY_API_KEY |
Geoapify API key for geocoding | your_geoapify_api_key_here |
WAZE_API_KEY |
Waze API key for route generation | your_waze_api_key_here |
JWT_SECRET |
Secret key for JWT authentication | your_jwt_secret_here |
- Modify
appsettings.jsonfor connection strings:{ "ConnectionStrings": { "DefaultConnection": "Server=localhost;Database=OnWayDB;User Id=postgres;Password=yourpassword;" } }
git clone https://github.com/your-repo/OnWay.git
cd OnWay
dotnet runπ API Documentation: Swagger UI (after running the API)