Below is a complete, ready-to-implement source code structure with essential files and sample code for a Real-Time GPS Tracking Dashboard using Angular (frontend) and ASP.NET Core (backend) with SignalR and SQL Server.
The structure is minimal but production-friendly — includes Docker, migrations, and run instructions. Use this as a starter and extend as needed.
Repository root
gps-tracking/
├─ backend/
│ ├─ src/
│ │ ├─ GpsTracking.sln
│ │ ├─ GpsTracking.Api/ # ASP.NET Core Web API + SignalR
│ │ ├─ GpsTracking.Core/ # Domain models / DTOs
│ │ └─ GpsTracking.Infrastructure/ # EF Core DbContext, Migrations
│ ├─ docker-compose.yml
│ └─ README.md
├─ frontend/
│ ├─ gps-dashboard/ # Angular project
│ │ ├─ src/
│ │ │ ├─ app/
│ │ │ │ ├─ components/
│ │ │ │ │ ├─ live-map/
│ │ │ │ │ │ ├─ live-map.component.ts
│ │ │ │ │ │ ├─ live-map.component.html
│ │ │ │ │ │ └─ live-map.component.scss
│ │ │ │ │ └─ device-list/
│ │ │ │ ├─ services/
│ │ │ │ │ ├─ tracking.service.ts
│ │ │ │ │ └─ signalr.service.ts
│ │ │ │ ├─ models/
│ │ │ │ │ └─ location.model.ts
│ │ │ │ ├─ app.module.ts
│ │ │ │ └─ app.component.*
│ │ │ └─ index.html
│ │ ├─ angular.json
│ │ └─ package.json
│ └─ README.md
└─ README.md
Backend — ASP.NET Core (essential files & snippets)
Projects
GpsTracking.Api— ASP.NET Core Web API with SignalR hub and REST endpoints.GpsTracking.Core— DTOs and domain models.GpsTracking.Infrastructure—ApplicationDbContext, EF entities, migrations.
GpsTracking.Core (models / DTOs)
GpsTracking.Core/Models/Device.cs
namespace GpsTracking.Core.Models
{
public class Device
{
public string DeviceId { get; set; } = null!;
public string Name { get; set; } = "";
public string? Type { get; set; }
public bool IsActive { get; set; } = true;
}
}
GpsTracking.Core/Models/LocationLog.cs
using System;
namespace GpsTracking.Core.Models
{
public class LocationLog
{
public int LogId { get; set; }
public string DeviceId { get; set; } = null!;
public double Latitude { get; set; }
public double Longitude { get; set; }
public double? Speed { get; set; }
public double? Direction { get; set; }
public DateTime RecordedAt { get; set; } = DateTime.UtcNow;
}
}
GpsTracking.Core/DTOs/LocationDto.cs
public class LocationDto
{
public string DeviceId { get; set; } = null!;
public double Latitude { get; set; }
public double Longitude { get; set; }
public double? Speed { get; set; }
public double? Direction { get; set; }
public DateTime RecordedAt { get; set; } = DateTime.UtcNow;
}
GpsTracking.Infrastructure — DbContext & EF configuration
GpsTracking.Infrastructure/ApplicationDbContext.cs
using Microsoft.EntityFrameworkCore;
using GpsTracking.Core.Models;
namespace GpsTracking.Infrastructure
{
public class ApplicationDbContext : DbContext
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> opts) : base(opts) { }
public DbSet<Device> Devices { get; set; }
public DbSet<LocationLog> LocationLogs { get; set; }
protected override void OnModelCreating(ModelBuilder builder)
{
builder.Entity<Device>().HasKey(d => d.DeviceId);
builder.Entity<LocationLog>().HasKey(l => l.LogId);
builder.Entity<LocationLog>()
.HasIndex(l => new { l.DeviceId, l.RecordedAt });
}
}
}
Add EF Core packages to projects:
dotnet add GpsTracking.Infrastructure package Microsoft.EntityFrameworkCore.SqlServer
dotnet add GpsTracking.Infrastructure package Microsoft.EntityFrameworkCore.Design
dotnet add GpsTracking.Api package Microsoft.EntityFrameworkCore.SqlServer
dotnet tool install --global dotnet-ef
Create migration and update DB (run from solution root):
cd backend/src/GpsTracking.Api
dotnet ef migrations add InitialCreate --project ../GpsTracking.Infrastructure --startup-project ./ -o ../GpsTracking.Infrastructure/Migrations
dotnet ef database update --project ../GpsTracking.Infrastructure --startup-project .
GpsTracking.Api — Program.cs (minimal)
Program.cs
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
// DbContext
builder.Services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection")));
// SignalR
builder.Services.AddSignalR();
// CORS (allow frontend)
builder.Services.AddCors(options =>
{
options.AddDefaultPolicy(policy =>
{
policy.AllowAnyHeader().AllowAnyMethod().AllowCredentials().WithOrigins("http://localhost:4200");
});
});
var app = builder.Build();
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseCors();
app.UseAuthorization();
app.MapControllers();
app.MapHub<TrackingHub>("/gpsHub");
app.Run();
SignalR Hub
GpsTracking.Api/Hubs/TrackingHub.cs
using Microsoft.AspNetCore.SignalR;
using GpsTracking.Core.DTOs;
public class TrackingHub : Hub
{
public async Task BroadcastLocation(LocationDto dto)
{
await Clients.All.SendAsync("locationUpdated", dto);
}
}
Controller: receive device updates and broadcast
GpsTracking.Api/Controllers/TrackingController.cs
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SignalR;
using GpsTracking.Core.DTOs;
using GpsTracking.Infrastructure;
[ApiController]
[Route("api/[controller]")]
public class TrackingController : ControllerBase
{
private readonly ApplicationDbContext _db;
private readonly IHubContext<TrackingHub> _hub;
public TrackingController(ApplicationDbContext db, IHubContext<TrackingHub> hub)
{
_db = db;
_hub = hub;
}
[HttpPost("update-location")]
public async Task<IActionResult> UpdateLocation([FromBody] LocationDto dto)
{
// persist
var log = new LocationLog
{
DeviceId = dto.DeviceId,
Latitude = dto.Latitude,
Longitude = dto.Longitude,
Speed = dto.Speed,
Direction = dto.Direction,
RecordedAt = dto.RecordedAt
};
_db.LocationLogs.Add(log);
await _db.SaveChangesAsync();
// broadcast
await _hub.Clients.All.SendAsync("locationUpdated", dto);
return Ok();
}
[HttpGet("history/{deviceId}")]
public IActionResult GetHistory(string deviceId, int limit = 100)
{
var rows = _db.LocationLogs
.Where(l => l.DeviceId == deviceId)
.OrderByDescending(l => l.RecordedAt)
.Take(limit)
.ToList();
return Ok(rows);
}
}

Join the conversation! Your thoughts help the community grow.