{"id":15157912,"url":"https://github.com/mmvergara/react-golang-postgresql-auth-template","last_synced_at":"2026-02-02T13:40:01.308Z","repository":{"id":255941622,"uuid":"853940219","full_name":"mmvergara/react-golang-postgresql-auth-template","owner":"mmvergara","description":"Minimalistic boilerplate or Template for React, Go/Golang, PostgreSQL with JWT Authentication. Client and Server Protected Routes","archived":false,"fork":false,"pushed_at":"2024-09-08T03:05:36.000Z","size":56,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-13T17:19:09.392Z","etag":null,"topics":["boilerplate","boilerplate-template","go","golang","postgres","postgresql","react","template"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mmvergara.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.MD","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-08T00:46:01.000Z","updated_at":"2024-09-09T01:39:45.000Z","dependencies_parsed_at":"2024-09-08T01:43:41.668Z","dependency_job_id":"57149f4b-9459-4f2f-8709-aa9e337e8459","html_url":"https://github.com/mmvergara/react-golang-postgresql-auth-template","commit_stats":{"total_commits":5,"total_committers":1,"mean_commits":5.0,"dds":0.0,"last_synced_commit":"f4cb9f4f63107d4489bd9d5c73c8694c4ea397e8"},"previous_names":["mmvergara/react-golang-postgresql-auth-template"],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmvergara%2Freact-golang-postgresql-auth-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmvergara%2Freact-golang-postgresql-auth-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmvergara%2Freact-golang-postgresql-auth-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmvergara%2Freact-golang-postgresql-auth-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mmvergara","download_url":"https://codeload.github.com/mmvergara/react-golang-postgresql-auth-template/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247675631,"owners_count":20977376,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["boilerplate","boilerplate-template","go","golang","postgres","postgresql","react","template"],"created_at":"2024-09-26T20:20:33.270Z","updated_at":"2026-02-02T13:40:01.262Z","avatar_url":"https://github.com/mmvergara.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n\u003ch1 align=\"center\"\u003eReact Go PostgreSQL Auth Template\u003c/h1\u003e\n\u003c/p\u003e\n\nMinimalistic boilerplate for React, Go, PostgreSQL.\n\n## Features\n\n- 🚀 Client and Server Protected Routes\n- 🚀 User Authentication\n- 🚀 Go stdlib `net/http`\n- 🚀 PostgreSQL no orm\n- 🚀 Clean Architecture\n- 🚀 Docker\n\n---\n\n## Setup\n\n### Frontend\n\n#### 1. Run Vite\n\n```bash\nnpm install\nnpm run dev\n```\n\n### Backend\n\n#### 1. Set your Environment Variables\n\n```py\n# Here is an example .env file\nPORT=8080\nJWT_TOKEN_DURATION_HOURS=24\nJWT_SECRET=meow\n\nDB_HOST=localhost\nDB_PORT=5432\nDB_DATABASE=gpa # database name\nDB_USERNAME=root\nDB_PASSWORD=password\nDB_SCHEMA=public\n```\n\n#### 2. Change makefile to match your database name\n\n```makefile\ndb:\n\tdocker compose up -d;\n  # default is \"gpa\" as specified in .env\n\tpsql -h localhost -p 5432 -U root -d gpa;\n\n```\n\n#### 3. Set up database schema\n\nconnect to db\n\n```bash\nmake db\n```\n\nexecute this sql query`./internal/database/schema.sql` in your database\n\n```sql\nCREATE EXTENSION IF NOT EXISTS \"uuid-ossp\";\nDROP TABLE IF EXISTS users;\nCREATE TABLE users (\n    user_id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),\n    email VARCHAR(254) UNIQUE NOT NULL,\n    password_hash VARCHAR(255) NOT NULL,\n    created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP\n);\n\n```\n\n#### 4. Run Server\n\n```bash\n# run db\nmake db\n\n# run server\ngo run cmd/api/main.go\n\n# or use air for hot reload\nair\n```\n\n---\n\n## What you need to know\n\n### Frontend-Backend Communication\n\n#### Success:\n\n- Backend: `sendJson(w, response, http.StatusOK)`\n  - `sendJson` is just util function that just sends a JSON response to the client\n- Frontend: `response.json()`\n\n#### Error:\n\n- Backend: `http.Error(w, \"Invalid Request\", http.StatusBadRequest)`\n- Frontend: `response.text()`\n\n### Frontend Stuff\n\n- `/router/index.tsx` is where you declare and manage your routes\n- `/context/AuthContext.tsx` is where you can find the `useAuth` hook\n  - This hook gives you access to the `user` object from the backend\n  - Manages the expiration of the JWT token\n- `/Providers.tsx` is where you can add more `providers` or `wrappers`\n\n---\n\n### Inspired By:\n\n[go-blueprint](https://github.com/Melkeydev/go-blueprint) \u003cbr\u003e\n[How I write HTTP services in Go after 13 years](https://grafana.com/blog/2024/02/09/how-i-write-http-services-in-go-after-13-years/#an-opportunity-to-hide-the-requestresponse-types-away)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmmvergara%2Freact-golang-postgresql-auth-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmmvergara%2Freact-golang-postgresql-auth-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmmvergara%2Freact-golang-postgresql-auth-template/lists"}