Database Refactoring and Service Health Monitoring System

July 05, 2025 v1.4.2 #database #monitoring #security #performance #bugfix #infrastructure

Hello, athletes!

Today we're releasing an important update that significantly improves the stability and reliability of the Peakline service. We've completely reworked the database system and added modern monitoring tools. This release solves critical performance issues and makes the service more resilient to load.

🗄️ Complete Database Work Refactoring

Problem solved: The service was suffering from database connection leaks and "Cannot operate on a closed database" errors, leading to unstable operation.

What changed: * Database Context Manager: Replaced all direct sqlite3.connect() calls with a safe context manager with get_db() as conn: * Automatic Connection Management: All connections now automatically open and close, eliminating memory leaks * Removed Middleware: Deleted outdated middleware that incorrectly managed database connections * Timeouts to Prevent Deadlocks: Added timeout settings to avoid operation hanging * Unified Approach: All system components now use the same database work pattern

Areas of changes: * Main application file * Token management system * Authentication modules * Telegram integration * Database abstraction layer

🏥 Service Health Monitoring System

New monitoring endpoints: * /api/health - basic health check for service status * /api/health/db - detailed database status check (protected by secret key)

Monitoring capabilities: * Database Connection Check: Automatic diagnosis of database availability and status * Service Information: Status, version, uptime * Security: Detailed information available only with correct secret key * Uptime Kuma Integration: Ready instructions for external monitoring setup

🔒 Security Improvements

Monitoring Protection: * Detailed database status information hidden from regular users * Secret key for access to extended diagnostics * Recommendations for secure external monitoring system setup

Security Audit: * Complete audit of all database-related components * Eliminated all potential vulnerabilities in user data handling * Verified correctness of all imports and dependencies

🚀 Performance and Stability

Before update: * Frequent "Cannot operate on a closed database" errors * Database connection leaks * Unstable operation under high load * No service status monitoring

After update: * Stable operation without database errors * Automatic resource management * Real-time monitoring capability * Quick problem identification and resolution

🛠️ Technical Details

Architectural Changes: * Implemented Repository pattern for data work * Context manager ensures RAII (Resource Acquisition Is Initialization) * Unified database error handling across all components

Monitoring: * RESTful API for health checks * JSON responses with detailed information * HTTP status codes for automatic monitoring * Support for various monitoring systems

📊 Impact on Users

Direct improvements: * Service became significantly more stable * Eliminated random data operation errors * Faster page loading due to database optimization * More reliable integration work (Telegram, Strava)

For administrators: * Ability to monitor service status * Quick problem identification * Diagnostic tools * Easy integration with external monitoring systems

🔄 Migration and Compatibility

Backward compatibility: * All existing API endpoints work without changes * User data remains untouched * Settings and configurations are preserved

Automatic update: * Update occurs automatically on service restart * No manual data migration required * All changes applied transparently

📋 What's Next

In future versions we plan to: * Add performance metrics to health check * Expand monitoring system for user activity tracking * Implement automatic alerts for critical issues * Add admin dashboard with service status visualization

🙏 Acknowledgments

Thank you to everyone who reported service stability issues! Your reports helped us identify and fix critical database problems.

P.S. If you notice any service operation issues - we now have reliable tools for quick diagnosis and problem resolution!

Major Security and Stability Overhaul

July 05, 2025 v1.4.0 #Security #Stability #Update

Hello, athletes!

Over the past few days, we have carried out a large-scale effort to strengthen the security and improve the stability of our platform. These changes affect the core of the system and make using Peakline even more reliable and secure for everyone.

✨ What's new and what we've fixed:

1. Completely Reworked Session System

We have implemented a new, modern session management system. Previously, the user's ID was stored in a cookie, which was potentially insecure.

  • Now: The cookie only stores a unique, cryptographically random, and short-lived token. This token is linked to your session on the server, completely eliminating the possibility of session hijacking or ID enumeration.

2. Enhanced Protection for Login and Registration Forms

To combat bots, spam, and brute-force attempts, we have integrated the advanced Cloudflare Turnstile system.

  • What this means for you: In most cases, you won't notice any changes. The check is performed automatically and invisibly. It's a smart CAPTCHA that doesn't require you to solve puzzles but effectively blocks malicious activity.

3. Added Rate Limiting

To protect the platform from abuse and ensure its stable operation for everyone, we've added rate limits to key operations such as login attempts, file uploads, and API calls.

4. Secure File Uploads

Previously, the system only checked the extension of uploaded files (e.g., .gpx). We have now implemented a deep MIME type check that analyzes the file's content. This ensures that only genuine and correct workout files can be uploaded to the server.

5. Fixed Critical Authentication Flaw

We identified and fixed several logical errors in the code that, in rare cases, could lead to incorrect authentication behavior, especially in the Telegram bot.

These updates are our priority in ensuring the security of your data and the stability of the service. Thank you for being with us!

— Your Peakline Team

Homepage UX Enhancements and Language Detection Fix

June 26, 2025 v1.3.2 #ux #improvement #language #animation #bugfix #mobile

Hello, athletes!

Today we're releasing an update that significantly improves the user experience on the homepage and fixes an important language detection issue. This release is based on your feedback!

🌍 Language Detection Fix

Problem solved: Some users from Russia were getting the Ukrainian version of the site by default due to browser behavior quirks.

What changed: * Priority language logic: System now checks popular languages first (Russian, German, French, Slovak) * Removed auto-conversion: Code uk is no longer automatically converted to ua * English as default: If there's no clear match with supported languages, English version is shown * Ukrainian only by choice: Ukrainian language is available only through explicit selection via language switcher

✨ Animations for Better UX

Mobile user problem: Many didn't understand that the homepage could be scrolled down to view additional content.

New animations: * Scroll Progress Bar: Thin orange stripe at the top shows page scroll progress * Bounce arrow animation: Bouncing arrow below hero section with "Scroll Down" text * Floating Scroll Hint: Round orange button on the bottom right for navigation to next section * Wave effect: Animated line "runs" across sections when they appear on screen * Enhanced transitions: Elements smoothly appear from bottom with beautiful timing functions

🎨 Contrast Fixes

Readability problem: In light theme, text on cards was poorly visible on the rainbow gradient background when hovering.

What's fixed: * White text on gradient: All text in cards becomes white on hover * Shadows for readability: Added shadow for better contrast on any background * Theme adaptation: Different shadow intensities for light and dark themes * Perfect readability: Now all elements (headers, icons, descriptions) are clearly visible

📱 Mobile Improvements

Responsive design: * Scroll hint adapts to screen size (50px on mobile, 60px on desktop) * Reduced sizes of animation elements for mobile devices * Optimized spacing and positioning for touch screens

🛠️ Technical Details

Performance: * All animations work through CSS transitions and transforms for maximum performance * Using cubic-bezier for natural transitions * Minimal impact on page loading speed

Compatibility: * Support for all modern browsers * Graceful degradation for older browsers * Full support for touch devices

🎯 Impact on Users

Before update: * Users could get wrong language * Non-obvious content scrolling * Poor readability when hovering on cards

After update: * Correct language detection for all regions * Intuitive page navigation * Excellent readability of all interface elements * Modern, smooth animations

📋 What's Next

In upcoming versions we plan to: * Add more languages based on community requests * Expand animation system to other pages * Create animation settings for users * Add more complex micro-interactions

Thank you for your feedback! It's precisely because of your reports that we could identify and fix these issues.

P.S. If you notice other problems with languages or UX - please let us know! We're always ready to improve Peakline based on your needs.

Smart Notifications and Stability Control System

June 23, 2025 v1.3.1 #new_feature #ux #maintenance #notification #improvement

Hello, athletes!

We're launching a new notification system that will help us better communicate with the community and inform you about important changes in service operation. This system was created in response to your requests for more transparent communication!

🔔 New Notification System

Smart Modal Windows: Now when you visit the site, you may see important notifications about maintenance, updates, or temporary feature limitations.

What this provides: * Transparency: We can promptly inform about system instability or planned work * Multilingual Support: Notifications automatically display in your language (Russian and English supported) * Smart Display Logic: Each notification is shown only once per day to avoid being annoying * Flexibility: System works through configuration file, allowing quick activation/deactivation of notifications

🎯 How It Works

For Users: 1. When entering the homepage or dashboard, a stylish modal window appears with important information 2. Two buttons to choose from: "Continue" (remember for the day) or "Return Later" (don't remember) 3. Ability to close with Escape key or clicking on background 4. Responsive design for all devices

For Administrator: * Simple management through JSON configuration * Enable/disable mode with one line * Text configuration for different languages * Instant application of changes after service restart

🛠️ Technical Details

Integration: System seamlessly integrates with existing site architecture, using established CSS classes and JavaScript patterns.

Performance: Minimal impact on page loading speed - all logic works asynchronously.

Compatibility: Full support for all modern browsers and mobile devices.

🎨 Why This Matters

This system emerged in response to our community growth. As practice showed after the Habr publication, user count can multiply within hours. The new system allows us to:

  • Warn in advance about server loads
  • Inform about experimental features
  • Communicate temporary API limitations
  • Announce major updates

📋 What's Next

In upcoming versions we plan to: * Add notification types (info, warning, critical error) * Integrate with changelog system to show new features * Create administrative interface for managing notifications * Add delayed notification display capability

Thank you for your understanding! This system will help us be even more open and responsive in our communication with you.

P.S. If you notice that notifications are showing too frequently or there are other issues - please let us know!

Security Patch, New Features, and Numerous UX Improvements

June 22, 2025 v1.3.0 #security #new_feature #improvement #bugfix #ux

Hello, athletes!

We continue to improve Peakline every day. This release is one of our most packed yet. We've bolstered security, added long-awaited features, and fixed many minor issues you've reported. Thank you for your engagement!

🛡️ Security & Reliability

  • Security Hardening: Following a discussion on Habr about a potential vulnerability (Stored XSS), we conducted an audit and proactively strengthened our security. All user-generated content displayed on pages now undergoes additional sanitization. The security of your data is our top priority.
  • Reliable API Rate Limits: To ensure service stability for everyone, we have introduced and configured a system of rate limits for all key functions, including track downloads, AI analysis, and activity uploads.

🚀 Improvements & UX

  • Peakline Manifesto on Homepage: We've added a new block to the homepage outlining our key principles: security, privacy, and community trust.
  • Consistent Segment Links: We've unified the logic. Now, clicking on a segment anywhere on the site (dashboard, activity page, starred list) always leads to its detailed page within Peakline.
  • SEO and FAQ Enhancements: We have worked on optimizing the site for search engines. We also started creating an extensive FAQ section to help new users easily find answers and discover our site.
  • Clearer Link Input Fields: Improved placeholder text for fields where links are expected, clarifying that an activity or segment URL is required.
  • Consistent Footer: The site footer is now displayed on all pages, including the gear detail view, for consistent navigation. Links to important informational pages have also been added.

🐛 Bug Fixes

  • Fixed element highlighting on hover on the homepage.
  • Corrected icons on the "About" page and in the "Why Peakline?" section.
  • Fixed the incorrect background on the language switcher button on secondary pages.
  • Numerous minor layout fixes and localization improvements for the Russian language.

Patch: Reliable Weather, UI Improvements, and Community Growth!

June 21, 2025 v1.2.1 #improvement #bugfix #ux #community

Hello, athletes!

Just one day after the major weather release, we are rolling out an important service update. Thank you for your quick feedback — it helped us to quickly find and fix several issues, as well as add a couple of nice improvements for the usability of Peakline.

What's new and what's fixed:

1. "Rock-Solid" Weather

We have completely redesigned the logic for obtaining weather data to make it work reliably for absolutely all workouts, both old and new.

  • What was wrong? For some workouts (especially very old ones or in remote locations), hourly weather data was unavailable, which caused the weather block not to be displayed.
  • What we did? Now, if the system does not find exact hourly data, it automatically makes a second request and receives daily average data (minimum/maximum temperature, wind gusts) for the day of the workout.
  • Result: No more "blank spots"! You will get weather context for every single one of your activities.

2. Improved Navigation: Segments within the Site

Analyzing workouts has become even more convenient. Previously, to view segment details from the list in a workout, you had to go to Strava.

  • New feature: Now the names of all segments in the "Segments" tab on the workout analysis page are clickable links.
  • What it gives you? By clicking on a segment, you will be instantly taken to its detailed page within Peakline, where you can view the profile, statistics, and download the track.

3. Explanations in Settings

We have listened to your questions and made the heart rate zone setup more understandable.

  • What's added? In the "Profile Settings" section, under the "Custom Heart Rate Zones" heading, there is now a tooltip: "For each zone, specify its UPPER boundary. For example, the value for Zone 2 is the maximum heart rate of that zone."
  • Result: This will help avoid confusion and allow you to set up your zones as accurately as possible from the first try.

4. Minor UI Fixes

  • Element overlap: Fixed a small layout bug on the homepage where the "Download GPX" button for the demo segment could overlap the map at certain screen resolutions.
  • Improved error handling: We have added more detailed logging and error handling when interacting with external APIs, which increases the overall stability of the service.

P.S. We are growing!

We want to share some joyful news: after publishing an article about our project on Habr (here is the link if you missed it: habr.com/ru/articles/920402/), our community grew from 5 to 21 users in just 5 hours!

This is incredibly motivating. Thank you for being with us! I'll keep working.

Peakline Can Now Be Installed as an App! Plus a Homepage Refresh

June 21, 2025 v1.2.2 #new_feature #ux #pwa #improvement

Hello, athletes!

We are not slowing down! While you were testing yesterday's fixes, we prepared another update focused on usability and the first impression of Peakline.

What's new:

1. Install Peakline on Your Phone or Computer (PWA)

This is a big and important new feature! Peakline can now be installed as a full-fledged application.

  • What it gives you?
    • On your phone: You can add the Peakline icon directly to your home screen, just like any other app.
    • On your computer: The app will launch in its own window, without extra browser tabs and panels.
  • How to install? Just visit the website. Modern browsers (Chrome, Edge, Safari) will prompt you to install the application via an icon in the address bar or a menu item.
  • Why is it needed? It's faster, more convenient, and gives the feeling of working with a native application. We have also added basic offline support — if the internet is lost, you will see a special page, not the standard browser error.

2. Updated Feature Showcase on the Homepage

We realized that the "Why Peakline?" section on the homepage was outdated and did not reflect all the cool features that have appeared recently. We have completely redesigned it!

  • What's added: We've added cards that talk about "Weather Context" (historical data and forecast) and "Pro-Level Tools" (custom zones and racing with a goal in FIT files).
  • Result: Now new users can immediately see the full power of our service, not just the basic features.

3. Final Touches to the UI

Thank you for your attention to detail! We have fixed a couple more small things that you noticed:

  • Button centering: On the homepage, the buttons in the last block ("Go to Dashboard" and "Connect with Strava") are now perfectly centered.
  • Background on the stats block: Removed the extra background color from the "Our Community in Numbers" block, it now looks more organic.

We continue to work on your suggestions. Next up are even deeper analytical metrics. Thanks for helping make Peakline better!

Weather in Every Workout and Next-Level AI Analysis

June 20, 2025 v1.2.0 #new_feature #improvement #ai #weather #roadmap

Hello, athletes! Summer is in full swing, and we're rolling out an update that adds context to your workouts and makes our AI assistant a true expert. We've carefully studied your suggestions and implemented the most anticipated features.

What's new:

1. Weather in Your Activities: Past and Future!

We are launching a major weather integration that will change your approach to analysis and planning.

  • Historical summary (available now!): For all newly uploaded workouts, the system now automatically pulls weather data (temperature, wind speed, and direction) at the start time. Analyze how a headwind affected your speed or how the heat affected your heart rate. No more guesswork — just facts!

  • Announcement: Forecast for Planning (coming soon!): This is just the beginning! In future updates, we will add a weather forecast for your favorite routes. You will be able to select the date and time of a future ride, and the system will show not only the expected temperature but also visualize the wind direction directly on the track map. Plan your efforts and choose the best time for records!

2. AI Coach Got Smarter: Analysis by Heart Rate Zones

We have dramatically improved our AI analyzer. Before, it only saw general numbers; now, it understands the structure of your workout.

  • New context: We added information about the time spent in each of your heart rate zones to the AI prompt.
  • Quality of conclusions: Instead of general phrases like "you had a high average heart rate," the AI now gives specific recommendations.
    • Example: "Great tempo work! You spent 40% of the time in HR zone 3, which is ideal for developing endurance. However, note that 10% of the time in zone 5 might have been excessive for this goal."

3. Improved Charts: Now with Units

A small but important fix for ease of analysis. We have put the units of measurement back on the Y-axis in the detailed analysis charts.

  • What's fixed: Instead of "150," you will now see "150 W" or "150 bpm."
  • Result: The charts have become more informative and professional. No more guessing what the values mean.

4. Updated Dashboard and Homepage

We have completely refactored the homepage and the dashboard. Although the external changes may not be immediately noticeable, you will definitely feel the result.

  • What it gives you? Pages load faster, the interface is more responsive, especially on mobile devices. We have laid a solid foundation for future innovations!

We continue to work to make Peakline your best training partner. The weather forecast for routes feature is our next priority. As always, we look forward to your feedback!

PRO Level: Custom Zones and Race Against a Goal!

June 16, 2025 v1.1.0 #new_feature #improvement #pro

Hello, athletes! Today we're rolling out a major update that turns Peakline into an even more powerful tool for serious training. We've listened carefully to your feedback and added features that give you full control over your analysis and preparation.

What's new:

1. Custom Training Zones

Now you are the head coach! In the new "Profile Settings" section (accessible from your dashboard), you can manually set the boundaries for all your power and heart rate zones.

  • How it works? Simply enter the threshold values for each zone.
  • What it gives you? The analysis of your workouts on the activity page will now use your personal zones, not the standard percentages of FTP/Max HR. This ensures maximum accuracy and relevance of the data.
  • Smart fallback: If you haven't set your zones, the system will, as before, use standard calculations or data from your Strava subscription.

2. Pro-Level FIT Generator: Race with a Goal

Just downloading a segment track is good. But downloading it to compete against a specific goal is even better! We have completely redesigned the FIT file download.

  • Interactive window: Now, when you click the FIT file download button, a modal window appears.
  • Choose your opponent: You can generate a file to race against:
    • KOM/QOM: Challenge the segment leader.
    • Your PR: Try to beat yourself.
    • Custom goal: Set any target time (e.g., 5m30s or 330) and compete against it.

3. Visual GPX Fixer

We don't just fix "teleports" in your tracks, we now show you how we do it.

  • Visual comparison: After uploading a file on the GPX Fixer page, a map appears where the original, "broken" track is shown in red, and the corrected one in green.
  • Statistics: You can immediately see how many extra points were removed and how many kilometers the distance was shortened.

4. Interactive Map-Chart Linking

Workout analysis has become even more exciting. Now the chart and map on the activity page are fully synchronized.

  • Just hover over any point on the chart (speed, elevation, heart rate).
  • A marker will immediately appear on the map, showing your exact location at that moment. Explore every meter of your track!

We are confident that these innovations will help you train even more effectively and with greater pleasure. As always, we look forward to your feedback and suggestions!

Peakline Grand Launch!

June 15, 2025 v1.0.0 #new_feature #release

Hello everyone! We are excited to announce the launch of Peakline — your new assistant in the world of Strava.

What's available now:

  • Dashboard with full statistics and recent activities.
  • Segment analysis with an interactive map and elevation profile.
  • Download FIT and GPX files for your Garmin devices.
  • GPX Fixer to correct "teleports" in your tracks.
  • Segment Hunter to find new challenges on the map.

We are just beginning our journey and would love to hear your feedback!