This Go application demonstrates OAuth authentication using Google as the provider. Below is the architectural overview of the application components and their interactions.
- main.go: The main application entry point that configures and starts the HTTP server
- Makefile: Provides convenient commands for running database migrations
- docker-compose.yaml: Orchestrates the PostgreSQL database container
- PostgreSQL Database: Stores user data and OAuth identities
- cmd/migrate/migrations/: Contains database migration files managed by golang-migrate
- SQLC Generated Code: Type-safe Go code generated from SQL queries
- Goth Library: Handles OAuth provider integration (Google)
- Gorilla Sessions: Manages cookie-based user sessions
- Authentication Handlers: Process OAuth login, callback, and logout requests
- Chi Router: HTTP request routing and middleware
- Middleware: Request processing (logging, CORS, etc.)
- Page Handlers: Business logic for rendering pages
- Templ Templates: Type-safe HTML template generation
- Goth: Multi-provider OAuth library for Go
- Gorilla Sessions: HTTP session management
- golang-migrate: Database migration tool
- SQLC: Generates type-safe Go code from SQL
- Chi Router: Lightweight HTTP router
- Templ: Type-safe Go templating language
- Database Setup: Use
docker-compose upto start PostgreSQL - Migrations: Run
make upto apply database migrations - Code Generation: SQLC generates Go code from SQL queries
- Authentication: Goth handles OAuth flow with Google
- Session Management: Gorilla Sessions maintain user state
- Request Handling: Chi router processes HTTP requests and renders responses
