How melkeydev/yappr works
Project type and purpose
• This is a full-stack, real-time, ephemeral chat application (“Yappr”).
• Frontend: React + TypeScript + Vite + Tailwind CSS
• Backend: Go (Chi router, Gorilla WebSocket) + PostgreSQL
• Key features: ephemeral rooms (24-hour auto-expiration), daily pinned topics (via HackerNews/Reddit), user accounts & anonymous chat, WebSocket messaging, achievement tracking.
File structure
• Top-level:
• docker-compose.yml / docker-compose-prod.yml
• client/ (React app)
• server/ (Go service)
• client/:
• src/pages, components, hooks, context, api (auth, rooms, stats), assets
• Vite config, environment, Dockerfiles (dev & prod)
• server/:
• internal/
– api/handler (core, user, stats) & model
– repo (room, user, stats)
– service (user, stats, pinnedrooms, topics)
– ws (client management, core pub/sub)
– filter (profanity)
• router/router.go, middleware (auth), util (env, cookies, response)
• db migrations + db.go to apply them
• Dockerfiles (dev & prod), main.go, go.mod
README for additional insights
• Tech stack callouts and environment variables for JWT, API base, WebSocket URL.
• Quick-start using Docker Compose for local dev.
• Daily pinned room topics fetched from external services (Reddit & HackerNews).
a. Main components
• Browser Client (React SPA)
• API Gateway / HTTP Server (Chi router + middleware)
• WebSocket Hub (Gorilla WebSocket core + client manager)
• Business-Logic Services (User, Stats, Topics, PinnedRooms)
• Data Access Layer / Repositories (User, Room, Stats)
• PostgreSQL Database
• External Topic Providers (Reddit API, HackerNews API)
• (Optional) Reverse Proxy / Load Balancer if scaling (Nginx, ALB)
b. Relationships & interactions
1. Client → HTTP REST calls → API Gateway (login, signup, fetch rooms, stats) → Services → Repositories → Database
2. Client ↔ WebSocket → WebSocket Hub → Core service broadcasts to other clients
3. PinnedTopics service (cron or startup) → fetch external APIs → populate pinned rooms in DB
4. Migrations apply via migrate.go on startup → ensure schema up-to-date
c. Architectural patterns & design principles
• Layered architecture (handlers → services → repositories → DB)
• Dependency injection via internal package separation
• CQRS-style separation: REST for CRUD, WebSocket for real-time updates
• Ephemeral data: TTL logic in service or scheduled cleanup for 24-hour room expiry
• External integration: “Topics” service decouples fetching pinned topics
d. Key technologies/frameworks
• Go + Chi router + Gorilla WebSocket
• React + Vite + TypeScript + Tailwind
• PostgreSQL (with Go migrations)
• Docker / Docker Compose for containerization
Essential details to capture
• Separation of concerns: show handlers → services → repos → DB
• WebSocket client registration and broadcast path
• Data TTL/cleanup for ephemeral rooms
• External topic fetch schedule or trigger
• Migration step before DB use