惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园_首页
云风的 BLOG
云风的 BLOG
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
C
Check Point Blog
Y
Y Combinator Blog
GbyAI
GbyAI
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
The Hacker News
The Hacker News
S
Securelist
F
Full Disclosure
大猫的无限游戏
大猫的无限游戏
Cyberwarzone
Cyberwarzone
AWS News Blog
AWS News Blog
雷峰网
雷峰网
M
MIT News - Artificial intelligence
C
CERT Recently Published Vulnerability Notes
S
Security @ Cisco Blogs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
N
News and Events Feed by Topic
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Cloudbric
Cloudbric
P
Palo Alto Networks Blog
Latest news
Latest news
V
V2EX
量子位
T
Tor Project blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
L
LINUX DO - 热门话题
Stack Overflow Blog
Stack Overflow Blog
Hacker News: Ask HN
Hacker News: Ask HN
D
Darknet – Hacking Tools, Hacker News & Cyber Security
博客园 - 叶小钗
H
Hackread – Cybersecurity News, Data Breaches, AI and More
J
Java Code Geeks
Webroot Blog
Webroot Blog
I
InfoQ
N
News | PayPal Newsroom
NISL@THU
NISL@THU
N
News and Events Feed by Topic
Cisco Talos Blog
Cisco Talos Blog
T
The Blog of Author Tim Ferriss
aimingoo的专栏
aimingoo的专栏
Scott Helme
Scott Helme
B
Blog RSS Feed
Google Online Security Blog
Google Online Security Blog
T
Troy Hunt's Blog
MyScale Blog
MyScale Blog
IT之家
IT之家
P
Privacy & Cybersecurity Law Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Building Spatial Memory: Why I Built a "Pinterest for the Physical World" and What I Learned
KevinTen · 2026-06-25 · via DEV Community

Building Spatial Memory: Why I Built a "Pinterest for the Physical World" and What I Learned

Honestly, I've had this idea in the back of my head for years.

What if you could leave notes, photos, and stories for people to find only when they physically stand where you stood? Like digital geocaching, but more social, more personal. A "spatial memory network" where memories are anchored to the real world.

I finally built it after three months of late nights, and today I want to share what I learned, what went wrong, and what I'd do differently if I started over.

If you're curious, the code is open source here: https://github.com/kevinten10/spatial-memory


The Idea That Wouldn't Die

I was hiking last year, stopped at this incredible viewpoint, and thought to myself: "I wish I could read what other people thought about this place before I got here. And I wish I could leave something for the next person."

Most photo apps let you geotag, but that's not the same. Everything is still in your feed, discoverable by anyone anywhere. The magic is in the proximity — you have to be here to unlock what people left here.

So here's the core concept:

  • Pin memories (photos, videos, text, voice) to GPS coordinates
  • Only people within ~50 meters can actually see the full content
  • Progressive privacy: Private → Friends-only → Public
  • Think of it as "location-based time capsules" that humanity collectively fills

It sounded simple enough. Spoiler: it was not that simple.


The Tech Stack I Ended Up With

So here's the thing about spatial apps — you need specialized tooling that most backend projects don't. Let me walk you through what I picked and why.

1. Database: PostgreSQL + PostGIS was a no-brainer

If you need to do proximity searches ("find all memories within 50 meters of me"), you need spatial indexes. Sure, you could store lat/lng as floats and do haversine calculations in application code, but that's insanity at any scale.

PostGIS gives you:

  • Spatial indexing with R-tree
  • Built-in distance calculations
  • Proximity queries out of the box
  • It's just PostgreSQL — you already know it

Here's what the table looks like:

CREATE TABLE public_memories (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    location GEOGRAPHY(POINT, 4326) NOT NULL,
    title VARCHAR(255) NOT NULL,
    description TEXT,
    media_urls TEXT[] NOT NULL DEFAULT '{}',
    visibility VARCHAR(20) NOT NULL DEFAULT 'private',
    created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
    updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

-- Create spatial index for proximity queries
CREATE INDEX idx_public_memories_location ON public_memories USING GIST (location);

And here's how you actually do the proximity query in Go:

package repository

import (
    "context"
    "fmt"
    "github.com/jackc/pgx/v5/pgxpool"
    "github.com/kevinten10/spatial-memory/internal/models"
)

func (r *MemoryRepository) FindNearby(
    ctx context.Context,
    lat float64,
    lng float64,
    radiusMetres float64,
    limit int,
) ([]models.PublicMemory, error) {
    // PostGIS makes this SO clean
    query := `
        SELECT id, title, description, media_urls, visibility, created_at,
               ST_X(location::geometry) AS lat, ST_Y(location::geometry) AS lng,
               ST_Distance(location, ST_SetSRID(ST_MakePoint($1, $2), 4326)) AS distance
        FROM public_memories
        WHERE visibility = 'public'
        AND ST_DWithin(location, ST_SetSRID(ST_MakePoint($1, $2), 4326), $3)
        ORDER BY distance ASC
        LIMIT $4;
    `

    rows, err := r.pool.Query(ctx, query, lng, lat, radiusMetres, limit)
    if err != nil {
        return nil, fmt.Errorf("find nearby: %w", err)
    }
    defer rows.Close()

    var memories []models.PublicMemory
    for rows.Next() {
        var m models.PublicMemory
        err := rows.Scan(
            &m.ID, &m.Title, &m.Description, &m.MediaURLs,
            &m.Visibility, &m.CreatedAt, &m.Lat, &m.Lng, &m.Distance,
        )
        if err != nil {
            return nil, err
        }
        memories = append(memories, m)
    }

    return memories, nil
}

That's it. That's your entire proximity search. PostGIS does all the heavy lifting.

2. Caching: Redis GEO for Hot Zones

Here's a problem I didn't anticipate: popular tourist spots get hammered with proximity queries all the time. You don't want to hit PostGIS for the same query every 2 seconds.

Redis has native GEO commands built in since version 3.2. I use it to cache memory IDs in popular areas:

package cache

import (
    "context"
    "github.com/redis/go-redis/v9"
)

type SpatialCache struct {
    rdb *redis.Client
}

func (c *SpatialCache) AddMemory(ctx context.Context, id string, lat float64, lng float64) error {
    // Add to Redis GEO
    return c.rdb.GeoAdd(ctx, "spatial:memories", &redis.GeoLocation{
        Name:      id,
        Longitude: lng,
        Latitude:  lat,
    }).Err()
}

func (c *SpatialCache) GetNearbyIDs(ctx context.Context, lat float64, lng float64, radiusMetres float64) ([]string, error) {
    // Get nearby memory IDs within radius
    res, err := c.rdb.GeoRadius(ctx, "spatial:memories", lng, lat, &redis.GeoRadiusQuery{
        Radius: radiusMetres,
        Unit:   "m",
        Count:  50,
        Sort:   "ASC",
    }).Result()

    if err != nil {
        return nil, err
    }

    ids := make([]string, len(res))
    for i, loc := range res {
        ids[i] = loc.Name
    }

    return ids, nil
}

Pro tip: Don't cache the entire memory object in Redis, just the IDs. You still go to PostgreSQL for the actual data. This keeps Redis memory usage tiny while still cutting down query time from ~20ms to ~2ms.

3. Object Storage: Cloudflare R2 was the right call

Uploading user photos and videos — if you proxy them through your backend API, your server gets crushed instantly.

I went with the two-phase upload pattern:

  1. Client asks server for a pre-signed URL
  2. Server signs and returns a direct R2 upload URL
  3. Client uploads directly to R2 (never touches your API)
  4. Client confirms to server that upload is complete

This is how you do it with the S3-compatible API in Go:

package storage

import (
    "context"
    "fmt"
    "github.com/aws/aws-sdk-go-v2/aws"
    "github.com/aws/aws-sdk-go-v2/credentials"
    "github.com/aws/aws-sdk-go-v2/service/s3"
    "time"
)

type R2Storage struct {
    client   *s3.Client
    bucket   string
    publicURL string
}

func (r *R2Storage) GetUploadURL(ctx context.Context, fileName string, contentType string, expiresIn int) (string, error) {
    req, err := r.client.PutObjectRequest(ctx, &s3.PutObjectInput{
        Bucket:      aws.String(r.bucket),
        Key:         aws.String(fmt.Sprintf("uploads/%s", fileName)),
        ContentType: aws.String(contentType),
    })

    if err != nil {
        return "", err
    }

    url, _, err := req.Presign(time.Duration(expiresIn) * time.Second)
    if err != nil {
        return "", err
    }

    return url, nil
}

func (r *R2Storage) GetPublicURL(key string) string {
    return fmt.Sprintf("%s/%s", r.publicURL, key)
}

Why R2 instead of S3? No egress fees. That's it. For an app with user-uploaded media, egress fees can eat your lunch. R2 gives you zero egress and S3 compatibility. Win-win.

4. AI Moderation: GLM-4V for Image Content

Since this is a public app with user-uploaded images, you need moderation. I went with GLM-4V from ZhipuAI because it's cheap and good enough for this use case.

The prompt I use is straightforward:

prompt := `
Please check if this image contains any inappropriate content:
- Illegal activities
- Nudity or sexual content
- Violence or graphic injury
- Hate speech or harassment
- Dangerous goods or regulated substances

If everything is safe, respond only with "SAFE". If it's not safe, respond only with "UNSAFE: reason".
`

So far, it's caught 98% of the bad stuff I've thrown at it. Is it perfect? No. But it's good enough for a side project.


The Surprising Hard Parts

Let me be honest — I underestimated how many weird edge cases you hit when building a location-based app.

1. Coordinate Precision is Tricky

GPS coordinates can be accurate to 10+ decimal places, but do you need that precision? Turns out:

  • 6 decimal places ≈ 10 centimeters precision
  • 5 decimal places ≈ 1 meter
  • 4 decimal places ≈ 10 meters

I store full double-precision in PostGIS (it just works), but when caching in Redis, I round to 6 decimals. No point wasting space on precision you can't actually use.

2. Privacy is More Complex Than You Think

When you pin a memory to GPS coordinates, that's data about a physical place. If people start pinning memories to their homes, you have to be careful. That's why I added three visibility levels:

  • Private: Only you can see it
  • Circle: Only friends in your circle can see it
  • Public: Anyone within 50 meters can see it

Progressive visibility solves most privacy issues. People can choose how exposed they want to be.

3. Authentication for Mobile Apps is Annoying

I wanted to support both SMS login and WeChat OAuth for the Chinese market. That means you need to handle multiple auth methods. I ended up with JWT tokens supporting both:

package auth

import (
    "time"
    "github.com/golang-jwt/jwt/v5"
)

type Claims struct {
    UserID   string `json:"user_id"`
    AuthType string `json:"auth_type"` // "sms" or "wechat"
    jwt.RegisteredClaims
}

func GenerateToken(userID string, authType string, secret string, ttlHours int) (string, error) {
    claims := Claims{
        UserID:   userID,
        AuthType: authType,
        RegisteredClaims: jwt.RegisteredClaims{
            ExpiresAt: jwt.NewNumericDate(time.Now().Add(time.Duration(ttlHours) * time.Hour)),
            IssuedAt:  jwt.NewNumericDate(time.Now()),
        },
    }

    token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
    return token.SignedString([]byte(secret))
}

Not rocket science, but it adds up. Mobile apps expect smooth auth, and third-party OAuth always has surprises.


Pros and Cons: Honest Review

I learned the hard way, so let me save you some time. Here's what's good and what's not about this approach.

✅ Pros

  1. PostGIS + Redis GEO is a killer combo — You get spatial queries that are actually fast, and both are mature tools you probably already know. No weird specialized databases needed.

  2. Direct-to-R2 uploads scales like crazy — My backend can handle 100x more traffic because it never touches the actual file bytes. This pattern is underrated.

  3. Go + Gin is perfect for this — Compiles to a single binary, low memory usage, fast HTTP responses. All you want for a backend API.

  4. Progressive visibility solves privacy concerns — Users get control, you get less compliance headache. Everyone wins.

  5. Open source stack has no vendor lock-in — All components are self-hostable. You can run this on your own VPS for a few dollars a month.

❌ Cons

  1. GPS accuracy is still inconsistent — Urban canyons (tall buildings) mess with GPS. Sometimes people have to walk 10 meters away from where they're supposed to be to unlock a memory. Not much you can do about it.

  2. Cold start problem is real — The app is useless until there are enough memories in enough places. Chicken and egg. You need a critical mass before it's actually fun to use.

  3. Moderation is never "done" — Even with AI, you still need human review for edge cases. This is ongoing work, not a set-it-and-forget-it feature.

  4. Mobile clients are half the battle — I built the backend, but building a good mobile AR experience that actually finds your location reliably is way more work than the backend. If you're thinking of forking this, be prepared.


Would I Do It Again?

Absolutely. It's a side project that scratches an itch I've had for years. Does it have product-market fit? I honestly don't know. Most people I tell the idea to think it's cool, but that doesn't mean they'll actually use it every day.

But that's okay. That's what side projects are for. I learned a ton about spatial databases, which I'd never really used professionally before. That alone was worth the three months of late nights.

The biggest lesson I walked away with? Physical location is an underrated dimension for social apps. Everything is in your feed now, everything is global. There's something magical about tying digital content to actual places. It makes the world feel layered, story-rich, more connected.

I've already left memories at my favorite hiking spots and coffee shops. One day, I hope someone stumbles across them and smiles. That's the whole point.


Your Turn

Have you ever built anything location-based? Ever had an idea for "pinning digital content to physical places"? Do you think this is something you'd actually use when you travel or hike? I'm genuinely curious to hear what you think — drop a comment below!

The code is all open source if you want to play with it or fork it: https://github.com/kevinten10/spatial-memory

Happy building 🗺️