DEV Community

Alex
Alex

Posted on

Building a Privacy-First Financial Analysis PWA with Blazor WebAssembly + On-Device AI (Gemini Nano)

Free, offline-capable, multi-language financial statement analysis for Ukrainian businesses - powered 100% in the browser (no servers, no API keys).

Live Demo: https://whitewaw.github.io/Assessment-of-Ukrainian-financial-statements/

GitHub Repo: https://github.com/whitewAw/Assessment-of-Ukrainian-financial-statements


Why I Built This

Small and medium businesses in Ukraine (and anywhere) often need quick insights from their balance sheet and income statement without sending data to third-party services or paying SaaS fees. I wanted:

  • Zero back-end infrastructure
  • Professional-grade ratio analysis and multi-year comparison
  • Installable PWA with offline mode
  • Strict privacy: data never leaves the browser
  • AI assistance without OpenAI keys or billing surprises

Blazor WebAssembly + Chrome's built-in Gemini Nano made this possible.


Core Highlights

Feature -> Benefit

  • Blazor WebAssembly (.NET 10) -> Full C# front-end, no server required
  • AOT Compilation -> Faster startup + optimized runtime
  • On-Device AI (Gemini Nano) -> Private financial chat & contextual insights
  • 16 Analysis Tables -> Comprehensive coverage of capital, liquidity, solvency, efficiency
  • 7 Interactive Charts -> Visual composition & trend exploration
  • Multi-Language (6) -> Ukrainian, English, German, Spanish, French, Russian
  • PWA + Offline -> Works after first load; installable
  • Local Storage + JSON Import/Export -> Data portability without backend
  • Privacy-First -> No telemetry, no tracking, no API keys

AI Assistant: 100% Client-Side

Chrome 127+ exposes a Prompt API enabling local inference via Gemini Nano. No keys, no cloud calls.

Example capability prompt:

const capabilities = await LanguageModel.availability();
"available"
Enter fullscreen mode Exit fullscreen mode

Sample financial question internally passed to the AI service:

var prompt = $$"""
Using the company's working capital ( {model.WorkingCapitalCurrent} ), current ratio ( {model.CurrentRatio} ), and debt-to-equity ( {model.DebtToEquity} ), provide:
1. A concise stability assessment
2. Top 3 risks (if any)
3. Recommended next action
Answer in Ukrainian if source data locale is 'uk'.
"""$$;
Enter fullscreen mode Exit fullscreen mode

The assistant streams responses for better UX and can explain formulas contextually.


Architecture Overview

AFS/ (Blazor WASM App)
  App.razor          → Root + Router
  Pages/             → UI pages (AI Assistant, Tables, Charts)
  wwwroot/index.html → SEO meta + PWA shell
AFS.ComponentLibrary/
  Components/        → Reusable UI (Tables, Charts, Chat)
AFS.Core/
  Models/            → Financial & ratio models
  Services/          → Calculation + AI integration + Storage
  Interfaces/        → Abstractions (IAIFinancialAdvisor, etc.)
Enter fullscreen mode Exit fullscreen mode

Key separation: AFS.Core handles pure calculations (testable logic), while UI stays thin.


Financial Analysis Coverage

Includes:

  • Liquidity: Current, Quick, Cash, Working Capital
  • Solvency: Debt-to-Equity, Interest Coverage, Leverage
  • Profitability: ROA, ROE, Margins
  • Efficiency: Turnover metrics (assets, receivables, inventory, payables)
  • Stability: Autonomy coefficient, classification levels
  • Fixed & Intangible asset efficiency

Each table is generated from strongly typed models instead of ad-hoc dictionaries, enabling safer refactors.


Performance Choices

  • AOT publish shrinks cold start and improves runtime math-heavy loops
  • IL trimming + Brotli compression reduces payload
  • Critical CSS inlined in index.html for faster LCP
  • Service Worker caches static assets → instant repeat visits

Publishing command:

# Release build with AOT
 dotnet publish AFS/AFS.csproj -c Release -o build
Enter fullscreen mode Exit fullscreen mode

Privacy & Data Handling

No calls are made to external APIs for analysis. Data stays:

  • In memory (runtime calculations)
  • In browser Local Storage (optional save)
  • Optional JSON export:
{
  "Year": 2024,
  "Form1": { "AssetsTotal": 1234567 },
  "Form2": { "NetProfit": 45678 }
}
Enter fullscreen mode Exit fullscreen mode

You control export/import - nothing is uploaded.


Getting Started (Local)

# Clone
 git clone https://github.com/whitewAw/Assessment-of-Ukrainian-financial-statements.git
 cd Assessment-of-Ukrainian-financial-statements

# Restore
 dotnet restore

# Ensure WASM tooling
 dotnet workload install wasm-tools

# Run
 dotnet run --project AFS
# Visit https://localhost:7157
Enter fullscreen mode Exit fullscreen mode

Enable AI (Chrome):

  1. Update to Chrome 127+
  2. chrome://flags/#prompt-api-for-gemini-nano → Enabled
  3. First run downloads Gemini Nano (~1.7GB one-time)

Example: Ratio Calculation Service (Simplified)

public class LiquidityRatioService
{
    public decimal CurrentRatio(decimal currentAssets, decimal currentLiabilities)
        => currentLiabilities == 0 ? 0 : currentAssets / currentLiabilities;

    public decimal QuickRatio(decimal liquidAssets, decimal currentLiabilities)
        => currentLiabilities == 0 ? 0 : liquidAssets / currentLiabilities;
}
Enter fullscreen mode Exit fullscreen mode

Integrated into a composite financial model so derived ratios are accessible to the AI advisor.


Internationalization (i18n)

Resx-based resources under AFS.ComponentLibrary/Resources/:

  • Resource.uk.resx
  • Resource.en.resx
  • etc.

Culture selector updates displayed language instantly - no reload.


SEO & GitHub Pages Quirk

Because this is a Blazor SPA hosted on GitHub Pages, Google Search Console may show a "False 404" during inspection of dynamic routes. A 404.html fallback mirrors index.html so all routes hydrate properly. Canonical + hreflang tags are manually set in index.html.


Roadmap (Selected)

  • PDF report generation (AI summary + graphs)
  • Multi-company comparison panel
  • Forecasting & anomaly detection (local AI augment)
  • Optional cloud sync layer (opt-in)

Contributions welcome - especially localization or advanced financial models.


Lessons Learned

  • On-device AI drastically lowers friction (no keys, instant trust)
  • Blazor AOT is now fast enough for real-time ratio computation
  • Strong typing across financial models prevents subtle column mapping errors
  • PWA + offline + privacy is a compelling trio for sensitive domains (finance, health, legal)

How You Can Help

  • ⭐ Star the repo if you find it useful
  • 🐛 Open issues for incorrect ratio definitions or edge cases
  • 🌍 Add new language translations
  • 📊 Contribute advanced metrics or sector benchmarks
  • 🤖 Improve AI prompts for financial diagnostics

Final Thoughts

This project shows what’s now possible entirely in the browser: serious domain analysis + AI guidance without surrendering data or paying API bills. If you’re building privacy-first analytical tools, combining Blazor WebAssembly with on-device AI is absolutely worth exploring.

Explore the demo, inspect the code, and feel free to fork.

👉 Demo: https://whitewaw.github.io/Assessment-of-Ukrainian-financial-statements/

👉 Code: https://github.com/whitewAw/Assessment-of-Ukrainian-financial-statements


Questions?

Drop them in the comments or open a GitHub Discussion.

Made with ❤️ + .NET + WebAssembly + On-Device AI.

Top comments (0)