<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Beril Tezcan</title>
    <description>The latest articles on DEV Community by Beril Tezcan (@beril_tezcan).</description>
    <link>https://dev.to/beril_tezcan</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3117337%2Fef620660-a8ab-4dc2-9940-a4ea9d294e5e.jpeg</url>
      <title>DEV Community: Beril Tezcan</title>
      <link>https://dev.to/beril_tezcan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/beril_tezcan"/>
    <language>en</language>
    <item>
      <title>Strava Heatmap</title>
      <dc:creator>Beril Tezcan</dc:creator>
      <pubDate>Fri, 04 Dec 2026 17:52:15 +0000</pubDate>
      <link>https://dev.to/beril_tezcan/strava-heatmap-jie</link>
      <guid>https://dev.to/beril_tezcan/strava-heatmap-jie</guid>
      <description>&lt;p&gt;I wanted a simple, privacy-first way to see all of my Strava GPS activities in one place — both as individual routes and as a combined heatmap — without sending my location history to another third-party web app.&lt;/p&gt;

&lt;p&gt;So I built &lt;strong&gt;StravaHeatmap&lt;/strong&gt;: a self-hosted web application that connects to your Strava account via OAuth 2.0, stores your activities locally in SQLite, and renders interactive routes and heatmaps on OpenStreetMap.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fika430tab11drlkvinha.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fika430tab11drlkvinha.png" alt=" " width="799" height="346"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;GitHub Repository:&lt;/strong&gt; &lt;a href="https://github.com/beriltzcn/strava-heatmap" rel="noopener noreferrer"&gt;beriltzcn/strava-heatmap&lt;/a&gt; (MIT License)&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Why Self-Hosted?
&lt;/h2&gt;

&lt;p&gt;Strava restricts new API applications to a single athlete by default, which actually fits the self-hosted model really well: &lt;strong&gt;your own instance, your own API credentials, and your own SQLite database.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once activities are synced, the map loads directly from your local database without hitting Strava on every page load.&lt;/p&gt;




&lt;h2&gt;
  
  
  Tech Stack
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Backend:&lt;/strong&gt; ASP.NET Core (.NET 10), Entity Framework Core, SQLite&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Frontend:&lt;/strong&gt; React 19, TypeScript, Vite, Leaflet (&lt;code&gt;react-leaflet&lt;/code&gt; + &lt;code&gt;leaflet.heat&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Maps &amp;amp; Geocoding:&lt;/strong&gt; OpenStreetMap tiles + Nominatim reverse geocoding&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Deployment &amp;amp; CI:&lt;/strong&gt; Multi-stage Docker + Docker Compose, GitHub Actions (&lt;code&gt;.NET&lt;/code&gt; build/test + ESLint + Vite build)&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Key Features &amp;amp; Architecture
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Strava OAuth 2.0 &amp;amp; Concurrency-Safe Token Refresh
&lt;/h3&gt;

&lt;p&gt;The backend handles the full OAuth 2.0 flow:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;/api/strava/connect&lt;/code&gt; generates a random CSRF &lt;code&gt;state&lt;/code&gt; token stored in the ASP.NET Core session and redirects to Strava.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/api/strava/callback&lt;/code&gt; validates &lt;code&gt;state&lt;/code&gt;, exchanges the authorization code for access and refresh tokens, persists them in SQLite, and redirects cleanly back to the React app.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/api/strava/status&lt;/code&gt; lets the frontend display the connected athlete badge and disable syncing when disconnected.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Because Strava access tokens expire every 6 hours, &lt;code&gt;StravaConnectionService&lt;/code&gt; checks expiry with a 5-minute buffer before any Strava API call and guards refresh requests with a &lt;code&gt;SemaphoreSlim&lt;/code&gt; lock (reloading the entity inside the lock) so concurrent requests never race to refresh the same token.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. N+1-Free Activity Sync
&lt;/h3&gt;

&lt;p&gt;When you click &lt;strong&gt;Sync&lt;/strong&gt;, &lt;code&gt;StravaSyncService&lt;/code&gt; fetches pages of activities from &lt;code&gt;/api/v3/athlete/activities&lt;/code&gt;. Instead of querying SQLite one activity at a time inside the loop, it fetches all matching &lt;code&gt;StravaActivityId&lt;/code&gt;s for the current page in a single &lt;code&gt;ToDictionaryAsync&lt;/code&gt; query and either inserts or updates them in batch.&lt;/p&gt;

&lt;p&gt;Network timeouts, upstream &lt;code&gt;5xx&lt;/code&gt; errors, and Strava &lt;code&gt;429&lt;/code&gt; rate limits are mapped cleanly via a shared HTTP helper so the UI gets actionable feedback.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Decoding Polylines &amp;amp; Rendering Maps in React
&lt;/h3&gt;

&lt;p&gt;Strava returns compressed route geometry as Google-encoded &lt;code&gt;summary_polyline&lt;/code&gt; strings. The frontend decodes those 5-bit delta-encoded coordinates in TypeScript (&lt;code&gt;decodePolyline&lt;/code&gt;) and renders two views:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Routes view:&lt;/strong&gt; Interactive Leaflet &lt;code&gt;&amp;lt;Polyline&amp;gt;&lt;/code&gt; layers with hover tooltips and click-to-select highlighting.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Heatmap view:&lt;/strong&gt; A &lt;code&gt;leaflet.heat&lt;/code&gt; density canvas layer projecting all filtered GPS points.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. Interactive Sidebar, Filters &amp;amp; Instant Search
&lt;/h3&gt;

&lt;p&gt;When your activities span multiple cities or countries, zooming out to fit everything makes individual walks tiny. To solve that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Server &amp;amp; client filtering:&lt;/strong&gt; Filter by sport type (&lt;code&gt;Run&lt;/code&gt;, &lt;code&gt;Walk&lt;/code&gt;, &lt;code&gt;Hike&lt;/code&gt;, &lt;code&gt;Ride&lt;/code&gt;, etc.) and date range (&lt;code&gt;From&lt;/code&gt; / &lt;code&gt;To&lt;/code&gt;), or search instantly by activity name, sport, or location.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Click-to-zoom sidebar:&lt;/strong&gt; Clicking any activity in the left sidebar (or directly on the map) highlights it and automatically zooms the Leaflet viewport right onto that route.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SQLite &lt;code&gt;DateTimeOffset&lt;/code&gt; quirk:&lt;/strong&gt; EF Core cannot translate &lt;code&gt;ORDER BY&lt;/code&gt; or range comparisons on &lt;code&gt;DateTimeOffset&lt;/code&gt; columns in SQLite, so &lt;code&gt;ActivitiesController&lt;/code&gt; applies &lt;code&gt;SportType&lt;/code&gt; and &lt;code&gt;SummaryPolyline&lt;/code&gt; filters in SQL first, then runs date filtering, sorting, and &lt;code&gt;limit&lt;/code&gt; in memory.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  5. Background Reverse Geocoding (with Polite Rate Limiting)
&lt;/h3&gt;

&lt;p&gt;Summary activities from Strava don't reliably include city/country names, even though we already have the route's GPS start point.&lt;/p&gt;

&lt;p&gt;A background &lt;code&gt;BackgroundService&lt;/code&gt; (&lt;code&gt;LocationEnrichmentService&lt;/code&gt;) decodes the first coordinate of each new route and resolves a clean &lt;code&gt;City, COUNTRY&lt;/code&gt; label (like &lt;code&gt;Quedlinburg, DE&lt;/code&gt; or &lt;code&gt;Berlin, DE&lt;/code&gt;) using OpenStreetMap Nominatim:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Respects Nominatim's &lt;strong&gt;1 request/second&lt;/strong&gt; policy (&lt;code&gt;1100ms&lt;/code&gt; spacing) and custom &lt;code&gt;User-Agent&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Caches resolved locations in a rounded &lt;code&gt;~1 km&lt;/code&gt; coordinate grid before calling Nominatim, so multiple walks starting in the same neighborhood trigger zero extra API calls.&lt;/li&gt;
&lt;li&gt;Persists &lt;code&gt;Activity.Location&lt;/code&gt; in SQLite so lookups only happen once per area.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  6. Single-Container Docker Setup
&lt;/h3&gt;

&lt;p&gt;In production, the multi-stage &lt;code&gt;Dockerfile&lt;/code&gt; builds the Vite frontend into &lt;code&gt;wwwroot&lt;/code&gt; inside the ASP.NET Core image:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Single container, single origin, &lt;strong&gt;no CORS configuration needed&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;SQLite database and ASP.NET Core DataProtection keys live on a mounted &lt;code&gt;/data&lt;/code&gt; volume so OAuth sessions and data survive container restarts.&lt;/li&gt;
&lt;li&gt;Pending EF Core migrations run automatically at startup (&lt;code&gt;Database.MigrateAsync()&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Try It Yourself
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/beriltzcn/strava-heatmap.git
&lt;span class="nb"&gt;cd&lt;/span&gt; strava-heatmap
cp .env.example .env
&lt;span class="c"&gt;# Add your Strava Client ID &amp;amp; Client Secret to .env&lt;/span&gt;
docker compose up --build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then open &lt;code&gt;http://localhost:8080&lt;/code&gt;, click &lt;strong&gt;Connect Strava&lt;/strong&gt;, and hit &lt;strong&gt;Sync&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  What's Next?
&lt;/h2&gt;

&lt;p&gt;I'm planning to add:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A statistics panel (total distance, elevation gain, moving time, and breakdowns per sport/month)&lt;/li&gt;
&lt;li&gt;Automated unit &amp;amp; integration tests for the sync and token refresh logic&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Feedback, ideas, and PRs are always welcome on &lt;a href="https://github.com/beriltzcn/strava-heatmap" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;!&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>dotnet</category>
      <category>react</category>
      <category>oauth</category>
    </item>
    <item>
      <title>Building a Full-Stack Habit Tracker with .NET 10 Minimal APIs, EF Core SQLite, Scalar, xUnit &amp; React</title>
      <dc:creator>Beril Tezcan</dc:creator>
      <pubDate>Fri, 04 Dec 2026 13:59:08 +0000</pubDate>
      <link>https://dev.to/beril_tezcan/building-a-full-stack-habit-tracker-with-net-10-minimal-apis-ef-core-sqlite-scalar-xunit-react-44ln</link>
      <guid>https://dev.to/beril_tezcan/building-a-full-stack-habit-tracker-with-net-10-minimal-apis-ef-core-sqlite-scalar-xunit-react-44ln</guid>
      <description>&lt;p&gt;I recently built HabitTrackerApi, a clean full-stack habit tracking project to practice modern .NET 10 Minimal APIs alongside a React + TypeScript frontend, automated integration tests, and CI.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkgk03xeo6yfn1wdrzz1q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkgk03xeo6yfn1wdrzz1q.png" alt=" "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Tech Stack
&lt;/h2&gt;

&lt;p&gt;Backend: ASP.NET Core (.NET 10) Minimal APIs + built-in AddValidation()&lt;br&gt;
Database: Entity Framework Core 10 + SQLite&lt;br&gt;
API Docs &amp;amp; Testing UI: Built-in OpenAPI + Scalar (Scalar.AspNetCore)&lt;br&gt;
Automated Tests: xUnit + WebApplicationFactory (Unit &amp;amp; Integration tests)&lt;br&gt;
Frontend: React + TypeScript + Vite&lt;br&gt;
CI: GitHub Actions (.github/workflows/dotnet.yml)&lt;/p&gt;
&lt;h2&gt;
  
  
  Project Architecture
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HabitTrackerApi/
├── HabitTracker.Api/
│   ├── Contracts/      # Request &amp;amp; Response DTOs with DataAnnotations
│   ├── Data/           # AppDbContext &amp;amp; Fluent API schema rules
│   ├── Domain/         # Habit &amp;amp; HabitCompletion entities
│   ├── Endpoints/      # Minimal API route group (/api/habits)
│   └── Migrations/     # EF Core SQLite migrations
├── HabitTracker.Tests/ # Domain unit tests &amp;amp; API integration tests
└── habit-tracker-ui/   # React + TypeScript frontend
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Key Highlights
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Encapsulated Domain Models&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Instead of exposing public setters everywhere, Habit and HabitCompletion expose factory methods (Create) and domain methods (Update) that keep data clean (trimming whitespace, converting blank descriptions/notes to null) and protect navigation collections with IReadOnlyCollection.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Database-Level Guardrails with EF Core &amp;amp; SQLite&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;One core rule of the app is that a habit can only be completed once per day.&lt;br&gt;
In AppDbContext, I enforced this both at the API layer (409 Conflict) and at the database schema level using a composite unique index:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="n"&gt;entity&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;HasIndex&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;HabitId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;CompletedAtUtc&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;IsUnique&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Deleting a habit also cascades cleanly to its completion history (DeleteBehavior.Cascade).&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Clean Minimal APIs with .NET 10 AddValidation()&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In .NET 10, builder.Services.AddValidation() automatically validates request DTOs decorated with DataAnnotations ([Required], [StringLength], [Range]) and returns a standardized 400 Bad Request ValidationProblem before the endpoint handler even runs.&lt;/p&gt;

&lt;p&gt;Here are the endpoints exposed under /api/habits:&lt;/p&gt;

&lt;p&gt;GET /api/habits — List habits with totalCompletions and isCompletedToday&lt;/p&gt;

&lt;p&gt;GET /api/habits/{id} — Get habit details and completion history&lt;/p&gt;

&lt;p&gt;POST /api/habits — Create a new habit&lt;/p&gt;

&lt;p&gt;PUT /api/habits/{id} — Update a habit&lt;/p&gt;

&lt;p&gt;DELETE /api/habits/{id} — Delete a habit&lt;/p&gt;

&lt;p&gt;POST /api/habits/{id}/completions — Mark a habit completed for a date (409 if duplicate)&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Interactive API Docs with Scalar&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Instead of Swagger UI, the API uses .NET 10 OpenAPI + Scalar (/scalar/v1) for testing endpoints directly in the browser during development.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Isolated Integration Tests with xUnit&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In HabitTracker.Tests, HabitTests verifies domain logic while HabitEndpointsTests spins up the real Minimal API in memory using WebApplicationFactory.&lt;br&gt;
To avoid touching the local development database, HabitApiFixture points ConnectionStrings:DefaultConnection to a temporary SQLite file in the OS temp folder, runs MigrateAsync(), executes the HTTP tests (400, 201, 200, 409), and deletes the temp database afterward.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;React + TypeScript Frontend &amp;amp; GitHub Actions CI&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The habit-tracker-ui app connects to the API via CORS, lets users create/complete/delete habits, and uses the backend's isCompletedToday flag to turn completed buttons green and disabled for the day.&lt;br&gt;
Every push to main triggers .github/workflows/dotnet.yml to restore, build in Release mode, and run all xUnit tests automatically.&lt;/p&gt;
&lt;h2&gt;
  
  
  Try It Locally
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/beriltzcn/HabitTrackerApi.git
&lt;span class="nb"&gt;cd&lt;/span&gt; HabitTrackerApi
&lt;span class="c"&gt;# Apply database migrations &amp;amp; run tests&lt;/span&gt;
dotnet ef database update --project HabitTracker.Api
dotnet &lt;span class="nb"&gt;test&lt;/span&gt;
&lt;span class="c"&gt;# Start the API (http://localhost:5198)&lt;/span&gt;
&lt;span class="nb"&gt;cd&lt;/span&gt; HabitTracker.Api
dotnet run --launch-profile http
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;In a second terminal, start the React app (&lt;a href="http://localhost:5173):" rel="noopener noreferrer"&gt;http://localhost:5173):&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; habit-tracker-ui
npm install
npm run dev

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This mini project was a great hands-on way for me to learn and connect modern tools together—especially .NET 10 Minimal APIs, built-in AddValidation(), Scalar, xUnit integration testing, and a React + TypeScript frontend.&lt;/p&gt;

&lt;p&gt;I would love for you to check out the repository, explore the code, and share any feedback, suggestions, or improvements in the comments!&lt;/p&gt;

&lt;p&gt;🔗 GitHub Repository: &lt;a href="https://github.com/beriltzcn/HabitTrackerApi" rel="noopener noreferrer"&gt;https://github.com/beriltzcn/HabitTrackerApi&lt;/a&gt;&lt;/p&gt;

</description>
      <category>dotnet</category>
      <category>csharp</category>
      <category>react</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
