Skip to content

jamesyang124/webauthn-example

Repository files navigation

WebAuthn Example

Go React TypeScript PostgreSQL Redis

A WebAuthn passwordless authentication demo built with Go backend and React frontend. Features functional programming patterns with try monads for robust error handling.

Stack: Go + FastHTTP, React + TypeScript + Vite, PostgreSQL, Redis

Getting Started

# 1. Copy environment configuration  
cp .env.example .env

# 2. Start all services with hot reload
docker-compose up --watch

Access:

  • Frontend: http://localhost:5173 (Vite dev server with hot reload)
  • Backend API: http://localhost:8080 (Go with hot reload)
  • Database: localhost:5555 (PostgreSQL)

Hot Reload: Both frontend and backend automatically reload on file changes.

Environment Variables

Copy .env.example to .env and adjust values as needed:

cp .env.example .env

Note: Remove user: 501:501 in docker-compose.yml if using mount volumes.

Architecture

Functional Programming Approach: Uses IBM/fp-go inspired try monad pattern for clean error handling and functional composition.

Key Features:

  • Custom try monad implementation in types/try_monad.go
  • Centralized error system in internal/weberror/
  • Functional composition in handlers and utilities
  • Clean separation between business logic and HTTP concerns

Development Commands:

  • make run - Run Go app locally
  • make build - Build binary
  • make docker-up - Start all services
  • cd views && npm run dev - Frontend dev server

TODOs

  • UI and persist display name
  • persist credentials table for 1 to many relationship with user table.

Reference

About

webauthn-example with go, ts, react, vite, and copilot

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published