{"id":26426632,"url":"https://github.com/yarlson/go-react-auth-template","last_synced_at":"2026-04-10T07:05:43.887Z","repository":{"id":255803258,"uuid":"845863266","full_name":"yarlson/go-react-auth-template","owner":"yarlson","description":"Go backend + React frontend template with Google OAuth, cookie-based auth, and refresh tokens. Quick start for secure web apps.","archived":false,"fork":false,"pushed_at":"2024-09-12T16:10:44.000Z","size":563,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-09-13T06:18:46.465Z","etag":null,"topics":["go","golang","google-auth","gorm","react","reactjs","shadcn-ui","sqlite3","tailwindcss","vite"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/yarlson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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-08-22T04:29:55.000Z","updated_at":"2024-09-12T16:10:47.000Z","dependencies_parsed_at":"2024-09-12T01:55:18.486Z","dependency_job_id":null,"html_url":"https://github.com/yarlson/go-react-auth-template","commit_stats":null,"previous_names":["yarlson/goauth"],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yarlson%2Fgo-react-auth-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yarlson%2Fgo-react-auth-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yarlson%2Fgo-react-auth-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yarlson%2Fgo-react-auth-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yarlson","download_url":"https://codeload.github.com/yarlson/go-react-auth-template/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244152390,"owners_count":20406980,"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":["go","golang","google-auth","gorm","react","reactjs","shadcn-ui","sqlite3","tailwindcss","vite"],"created_at":"2025-03-18T03:34:09.471Z","updated_at":"2026-04-10T07:05:43.857Z","avatar_url":"https://github.com/yarlson.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Go-React Auth Template\n\nA template for building web applications with a Go backend and a React frontend. It includes cookie-based Google authentication with refresh token functionality and uses Tailwind CSS and shadcn/ui for styling. The project integrates Traefik for reverse proxy management and automatic SSL certificates with Let's Encrypt for production deployments. Docker Compose is used for containerization in production. The monorepo structure uses Turborepo for efficient project management and builds.\n\n## 📋 Table of Contents\n\n- [Features](#-features)\n- [Getting Started](#-getting-started)\n- [Prerequisites](#-prerequisites)\n- [Configuration](#-configuration)\n- [Usage](#-usage)\n- [Production Deployment with Docker Compose](#-production-deployment-with-docker-compose)\n- [API Documentation](#-api-documentation)\n- [Project Structure](#-project-structure)\n- [Contributing](#-contributing)\n- [License](#-license)\n\n## ✨ Features\n\n- Go backend using Gin framework\n- React frontend with TypeScript\n- Tailwind CSS and shadcn/ui for styling\n- Cookie-based Google OAuth authentication with refresh token support\n- Traefik reverse proxy with automatic Let's Encrypt SSL certificates (production)\n- Docker Compose setup for containerized production deployment\n- Monorepo structure managed with Turborepo\n\n## 🚀 Getting Started\n\nTo use this template:\n\n1. **Use the Template:**\n\n   - Click the \"Use this template\" button at the top of this repository.\n   - Name your new repository and set its visibility.\n   - Click \"Create repository from template\".\n\n2. **Clone the Repository:**\n\n   ```bash\n   git clone https://github.com/yourusername/your-repo-name.git\n   cd your-repo-name\n   ```\n\n## 📋 Prerequisites\n\n- **Node.js** (v20 or later)\n- **Go** (v1.23 or later)\n- **Google Cloud Platform Account** (for OAuth credentials)\n- **Docker \u0026 Docker Compose** (for production deployment)\n- **Domain Name** (pointing to your server's IP address for production)\n- **Valid Email Address** (for Let's Encrypt SSL certificate registration in production)\n\n## 🔧 Configuration\n\n### Backend Configuration\n\nCreate a `.env` file in the `services/backend/` directory with the following variables:\n\n```env\nGOOGLE_CLIENT_ID=your_google_client_id\nGOOGLE_CLIENT_SECRET=your_google_client_secret\nGOOGLE_HOSTED_DOMAIN=\nGOOGLE_REDIRECT_URL=http://localhost:5173/callback\nJWT_SECRET=your_jwt_secret\nHASH_KEY=your_hash_key\nBLOCK_KEY=your_block_key\n```\n\n- For local development, set `GOOGLE_REDIRECT_URL` to `http://localhost:5173/callback`.\n- Replace the placeholder values with your actual configuration.\n\n### Root Configuration (Production Only)\n\nFor production deployment, create a `.env` file in the **project root directory** with:\n\n```env\nACME_EMAIL=your_email@example.com\nDOMAIN_NAME=yourdomain.com\n```\n\n- Replace `your_email@example.com` with your email.\n- Replace `yourdomain.com` with your domain.\n\n### DNS Configuration (Production Only)\n\nEnsure your domain name points to your server's IP address for SSL certificate validation.\n\n## 🚀 Usage\n\n### Local Development\n\n1. **Install Dependencies:**\n\n   ```bash\n   npm install\n   ```\n\n2. **Start Backend Server:**\n\n   Navigate to the backend service directory and run the server:\n\n   ```bash\n   cd services/backend\n   go run main.go\n   ```\n\n   The backend server will start on port `8080` by default.\n\n3. **Start Frontend Development Server:**\n\n   Open a new terminal window, navigate to the frontend service directory, and start the development server:\n\n   ```bash\n   cd services/frontend\n   npm install\n   npm run dev\n   ```\n\n   The frontend development server will start on `http://localhost:5173`.\n\n4. **Run Tests:**\n\n   ```bash\n   npm run test\n   ```\n\n5. **Build the Project:**\n\n   ```bash\n   npm run build\n   ```\n\n6. **Lint Code:**\n\n   ```bash\n   npm run lint\n   ```\n\n7. **Format Code:**\n\n   ```bash\n   npm run format\n   ```\n\n### Notes\n\n- The backend server expects the frontend to be running on `http://localhost:5173`.\n- Ensure that the `GOOGLE_REDIRECT_URL` in your backend `.env` file matches the frontend URL.\n\n## 🐳 Production Deployment with Docker Compose\n\nFor production deployment, use Docker Compose to build and run the application with Traefik for reverse proxy and automatic SSL.\n\n### Prerequisites\n\n- Ensure you have a domain name pointing to your server's IP address.\n- Ports `80` and `443` should be open and accessible.\n\n### Configuration\n\n- Set up the `.env` file in the project root with your production domain and email.\n- Update the `GOOGLE_REDIRECT_URL` in `services/backend/.env` to `https://yourdomain.com/callback`.\n\n### Building and Running\n\n1. **Build and Start Containers:**\n\n   ```bash\n   docker-compose up --build -d\n   ```\n\n2. **Access the Application:**\n\n   - Frontend: `https://yourdomain.com`\n   - Backend API: `https://yourdomain.com/api`\n\n### Services Overview\n\n- **Traefik Service:**\n  - Reverse proxy and SSL management with Let's Encrypt.\n- **Frontend Service:**\n  - Serves the React application.\n- **Backend Service:**\n  - Provides the API endpoints and authentication.\n\n### Environment Variables\n\nEnsure all required environment variables are set in your `.env` files as per the configuration steps.\n\n### Volumes\n\n- `sqlite_data`: Persists the SQLite database.\n- `letsencrypt`: Stores SSL certificates.\n\n### Common Commands\n\n- **Stop Containers:**\n\n  ```bash\n  docker-compose down\n  ```\n\n- **Stop and Remove Volumes:**\n\n  ```bash\n  docker-compose down -v\n  ```\n\n- **View Logs:**\n\n  ```bash\n  docker-compose logs\n  ```\n\n- **Rebuild Images:**\n\n  ```bash\n  docker-compose build\n  ```\n\n### Troubleshooting\n\n- **Check Logs for Errors:**\n\n  ```bash\n  docker-compose logs\n  ```\n\n- **Verify Environment Variables:**\n\n  Ensure all variables are correctly set.\n\n- **Confirm Domain DNS:**\n\n  Your domain should point to your server's IP.\n\n- **Check Open Ports:**\n\n  Ports 80 and 443 should be accessible.\n\n## 📖 API Documentation\n\n### Authentication Endpoints\n\n- `GET /auth/google`: Initiate Google OAuth login.\n- `GET /auth/google/callback`: Handle OAuth callback.\n- `POST /auth/refresh`: Refresh user session.\n- `GET /auth/logout`: Log out user.\n\n### Protected Endpoints\n\n- `GET /api/user/profile`: Get authenticated user profile.\n\n_Note: Protected endpoints require a valid session cookie._\n\n## 🗂 Project Structure\n\n```\n.\n├── services/\n│   ├── backend/\n│   │   ├── auth/\n│   │   ├── model/\n│   │   ├── repository/\n│   │   ├── main.go\n│   │   └── ...\n│   └── frontend/\n│       ├── src/\n│       ├── public/\n│       └── ...\n├── package.json\n├── turbo.json\n├── docker-compose.yml\n├── .env           # (Production environment variables)\n└── README.md\n```\n\n## 🤝 Contributing\n\nContributions are welcome.\n\n1. **Fork the Repository**\n2. **Create a Branch**\n\n   ```bash\n   git checkout -b feature/your-feature\n   ```\n\n3. **Make Changes**\n4. **Commit Changes**\n\n   ```bash\n   git commit -m 'Add your feature'\n   ```\n\n5. **Push to Branch**\n\n   ```bash\n   git push origin feature/your-feature\n   ```\n\n6. **Open a Pull Request**\n\n## 📄 License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n---\n\nFor support or more information, please open an issue on this repository.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyarlson%2Fgo-react-auth-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyarlson%2Fgo-react-auth-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyarlson%2Fgo-react-auth-template/lists"}