This is a Go-based backend for a blog app featuring authentication with Google, GraphQL API, and user management. The project uses the following stack:
- Gin: A web framework to handle HTTP requests
- Gqlgen: GraphQL implementation in Go
- GORM: ORM library for Go
- Go Migrate: Database migrations for PostgreSQL
- Google OAuth2 authentication
- GraphQL API (with playground)
- User creation and management
- PostgreSQL database integration
Before setting up the project, ensure you have the following installed:
- Go 1.19+
- PostgreSQL
- Gqlgen
- Go Migrate
-
Clone the repository:
git clone https://github.com/antares-jeet/write-stream-go.git cd write-stream-go -
Install dependencies:
go mod download
-
Create a
.envfile based on.env.example:cp .env.example .env
-
Update the
.envfile with your environment variables, such as database credentials, OAuth client IDs, and secrets. -
Apply database migrations:
migrate -database "postgres://<DB_USER>:<DB_PASSWORD>@<DB_HOST>:<DB_PORT>/<DB_NAME>?sslmode=require" -path ./migrations up -
Generate the GraphQL schema using Gqlgen:
go run -mod=mod github.com/99designs/gqlgen generate
-
Run the application:
go run ./main.go
The server will be up at http://localhost:8080.
For production, switch to release mode by setting the following environment variable:
export GIN_MODE=releaseYou can also check development.md for more detailed information on setting up the project and its development environment.
This project is licensed under the MIT License.