What is dogfooding
Dogfooding is the practice of an organization to use its own product (wikipedia). We are strong believers in dogfooding - it is the ultimate test of user experience. It also helps us find bottlenecks, get ideas for new improvements. Oh and we fix the occasional bug we hit during dogfooding. If you aren’t using your own product why should anybody else?
In this post I will show you the Radzen Admin. It is an application that we use every day to track the company performance. We created this application with Radzen and maintain it on a regular basis.
Getting the data
We use Gumroad to sell the Radzen subscriptions. We access the Gumroad API via a Radzen REST data source.
Then we import it in a PostgreSQL data source for faster and easier access.
Calculating and displaying metrics
The dashboard page displays various metrics - MRR (Monthly Recurring Revenue), annual revenue etc. We use custom methods to calculate those numbers. It is all done with C# and Linq queries. Here is one for example:
public async Task<decimal> GetMonthlyRecurringRevenue()
{
var sales = await RadzenDb.GetRadzenDbSales();
return sales.Where(sale => sale.Cancelled != true && sale.RecurringCharge != true)
.Sum(sale => sale.Price).Value / 12;
}
We invoke that method in Radzen and display its value in a Heading component.
Tracking the annual revenue with a chart
Another custom method provides data for the Annual revenue chart. Here is how we implemented it:
public async Task<IEnumerable<MonthlyRevenue>> GetRevenueSinceStartOfTheYear(DateTime today)
{
var sales = await RadzenDb.GetRadzenDbSales();
var startOfTheYear = new DateTime(today.Year, 1, 1);
return sales.Where(sale => sale.CreatedAt <= today && sale.CreatedAt >= startOfTheYear)
.ToList()
.OrderBy(sale => sale.CreatedAt)
.GroupBy(sale => new DateTime(sale.CreatedAt.Year, sale.CreatedAt.Month, 1))
.Select(group => new MonthlyRevenue
{
Month = group.Key.ToString("MMM"),
Revenue = group.Sum(sale => sale.Price.Value)
});
}
We invoke this method twice to get the revenue for the current and last year. Then configure the Radzen Blazor Chart to use the data.
By the way you can create a similar dashboard with Radzen by following the Create a Complete Application tutorial.
Deployment
We deploy via a single git push
command. The Docker file which Radzen automatically generates is extended to pass the database connection string.
FROM mcr.microsoft.com/dotnet/core/sdk:3.1.100
COPY . /app
WORKDIR /app
RUN dotnet publish -c Release -o out
ENV ASPNETCORE_URLS http://*:5000
ENV ConnectionStrings__RadzenDbConnection "Host=<host>;Port=<port>;Database=radzen_db;User ID=<user>;Password=<password>;"
WORKDIR /app/out
ENTRYPOINT ["dotnet", "Admin.dll"]