How ypathan/blog works
This is a Go web application for publishing and administering blog posts. A browser reaches the app through the HTTP router: public requests render or fetch blog content, while admin requests use login-issued cookies and protected routes for management pages and CRUD actions. Handlers delegate persistence to repositories backed by PostgreSQL; authentication handlers also use password hashing and token utilities. The source excerpts show routing and handler-to-repository calls, but do not establish how the browser’s JavaScript consumes every API response, so those links are omitted.
Main entry points: main.go HTTP router · blogHandlers.go Blog handlers · authHandlers.go Auth handlers · blogRepository.go Blog repository
Components 17
HTTP runtime
- HTTP router
main.go - Database setup
database/dbconn.go - PostgreSQL store
Blog content
- Blog handlers
handlers/blogHandlers.go - Blog repository
repository/blogRepository.go - Blog data types
types/blog.go - Admin handlers
handlers/adminHandlers.go
Admin identity
- Auth handlers
handlers/authHandlers.go - Auth repository
repository/authRepository.go - Password and tokens
auth/authUtils.go - User data types
types/auth.go
Web presentation
- Blog index view
static/index.gohtml - Blog detail view
static/blog.gohtml - Admin login view
static/adminLogin.gohtml - Admin management views
static - Static assets
static
Other components
- Browser user
Connections 21
- Browser user → HTTP router: sends requests
main.go - HTTP router → Database setup: opens database
main.go - Database setup → PostgreSQL store: connects and initializes
database/dbconn.go - HTTP router → Blog handlers: routes blog requests
main.go - HTTP router → Auth handlers: routes auth requests
main.go - HTTP router → Admin handlers: routes admin pages
main.go - Blog handlers → Blog repository: reads and changes posts
handlers/blogHandlers.go - Admin handlers → Blog repository: loads admin posts
handlers/adminHandlers.go - Blog repository → PostgreSQL store: queries posts
repository/blogRepository.go - Auth handlers → Auth repository: reads and updates users
handlers/authHandlers.go - Auth handlers → Password and tokens: hashes and verifies credentials
handlers/authHandlers.go - Auth repository → PostgreSQL store: queries user records
repository/authRepository.go - Blog handlers → Blog index view: renders index
handlers/blogHandlers.go - Blog handlers → Blog detail view: renders post detail
handlers/blogHandlers.go - Auth handlers → Admin login view: renders login
handlers/authHandlers.go - Admin handlers → Admin management views: renders admin pages
handlers/adminHandlers.go - HTTP router → Static assets: serves static files
main.go - Blog handlers → Blog data types: uses post data
handlers/blogHandlers.go - Blog repository → Blog data types: stores post data
repository/blogRepository.go - Auth handlers → User data types: decodes user data
handlers/authHandlers.go - Auth repository → User data types: stores user data
repository/authRepository.go