Deploying PurelyManage: systemd, nginx, and S3 Frontend

Part of the PurelyManage series. This is the end-to-end deployment guide for PurelyManage. The backend runs as a Node.js process managed by systemd. The frontend is a static React build served from S3 via CloudFront. nginx handles TLS termination and reverse proxying for the backend. Both repos are on GitHub: Backend: github.com/sagarnayak/purelymanageBackend-public Frontend: github.com/sagarnayak/purelymanageFrontend-public Prerequisites Ubuntu (or any Linux with systemd) Node.js 18 or later PostgreSQL (any recent version, local or remote) nginx certbot (for TLS) imapsync (only if you need the migration feature, see the previous post) Backend Setup Clone the repo and install dependencies: ...

January 26, 2026 · 4 min · 751 words · Sagar Nayak

Mount AWS S3 as a Windows Drive with rclone

What rclone can mount an S3 bucket as a Windows drive letter, making it appear in File Explorer like a local drive. This guide covers configuring one S3 remote, writing a mount batch file, and optionally starting it at sign-in. You need an AWS account with an S3 bucket and IAM user, rclone for Windows, and WinFSP installed (required for rclone mount on Windows). Why Faster access: Browse S3 in File Explorer without separate apps or consoles. Simplicity: Open, copy, rename like a normal drive letter. Integrations: Any Windows app that works with drive letters can work with S3. How Step 1: Install rclone + WinFSP ...

October 15, 2025 · 3 min · 616 words · Sagar Nayak

FolderSync + AWS S3: Private Android Photo Backup

What FolderSync is an Android app that syncs local folders to S3-compatible storage. This guide sets up a private S3 bucket with a scoped IAM user and maps it to your device’s camera folder for automatic, private photo backup. You need an AWS account to start. Why Own your data: No Big Tech gallery lock-in. Reliability: S3 durability + Intelligent-Tiering for cost control. Simplicity: No self-hosted NAS, static IP, RAID, or server maintenance. How Step 1: Create S3 bucket (Region: us-east-1 recommended) ...

October 12, 2025 · 2 min · 347 words · Sagar Nayak

Expense Tracker (Part 3/5): AWS Setup

Series links: Part 1/5 - Introduction Part 2/5 - Database Planning Part 3/5 - AWS Setup (you are here) Part 4/5 - Backend APIs Part 5/5 - Frontend What A light AWS setup to hold two things: your files (bills) and your data (transactions). Why S3 is reliable and affordable for documents/photos. RDS PostgreSQL gives you a managed database without running servers. How S3 bucket for web hosting (public read) Create a bucket for the static site (e.g., my-expenses-web). Make it public-read so the HTML/CSS/JS can be fetched by browsers. Optionally use CloudFront in front; with OAC you can keep the bucket private and still serve publicly via the CDN. Alternative hosts: Netlify, Vercel, or any simple web server. S3 bucket for documents (private) ...

June 6, 2025 · 2 min · 341 words · Sagar Nayak

Multi-Region EC2 Routing with Session Pinning and JWT

What We are designing a system where clients are routed to regional servers to reduce latency, while maintaining session consistency during multi-step API calls. Key components: Regional servers in different geographies Central discovery server tracking server heartbeat and load JWT tokens for authentication: Primary token expiry: 1-5 minutes Refresh token expiry: 7-30 days Client-server locking: ensures multi-step requests stay on the same server Load balancing and failover via Route 53 geo-proximity with health checks Why Simple geo-proximity DNS (Route 53) is insufficient for multi-step API workflows Multi-step POST requests can fail if a client jumps servers due to geo routing This happens because even with active-active database replication, there’s latency in the replication process When clients hit different servers too frequently, there’s a high chance that a server might not have the latest data required This data inconsistency leads to request failures, as the server processing a request might be working with stale data Need to lock clients to a server during critical operations Need flexibility to load balance or move clients across regions safely when not performing critical tasks Health checks in Route 53 ensure traffic isn’t routed to servers that are down How 1. Central Discovery Server Each regional server sends heartbeat with its unique ID, region code, and public URL Optionally collect telemetry/load data from each server (either directly from regional servers or via a central telemetry system) Discovery server maintains the active server list, their public URLs, and load information 2. DNS Setup Each regional server gets its own URL Central URL uses Route 53 geo-proximity with health checks to route clients to nearest healthy server 3. Client Login & Locking Client hits the central geo-proximity URL Login request routed to nearest server Server returns: JWT token Its own server URL → marks the client lock All further requests from this client use the locked server URL 4. Server Discovery Sync Regional servers periodically pull the active server list (with public URLs) + load information from discovery server (load data can originate from a central telemetry system or directly from servers) Enables load balancing within regions and global awareness 5. Refresh Token API & Closest Server Before sending a refresh token request, client calls /closestToMe on central geo URL Returns closest server identifier Payload includes: closestServerId criticalTaskInProgress (boolean) 6. Refresh Token Handling If criticalTaskInProgress = true: Do not switch servers Refresh token and maintain lock with current server If criticalTaskInProgress = false: Check closest server and region: Same region → pick server with lowest load, update token with new server URL Different region → switch client to that server and update token Ensures safe cross-region movement while maintaining active tasks 7. Load Balancing Regional servers use closest server identifier + server load to redistribute clients Maintains even load distribution while keeping active sessions safe 8. Frontend Considerations Detect if primary server URL changed in token response Show user-friendly message: “Your primary server has changed. Any missing data will be synced within 5 minutes.” Ensures users are aware but do not panic over temporary replication delays 9. Handling Server Failures If a server goes down, client will receive a 500-series error Client should wait 30 seconds with a timer: “Reconnecting…” During this time, discovery server confirms the server stopped sending heartbeats and updates its registry of available servers and their public URLs After the wait, attempt a refresh token request again Request will now hit the closest healthy server Refresh token response will include the new server URL

March 14, 2025 · 3 min · 581 words · Sagar Nayak