This project is build using the following:
- gqlgen for the graphql server.
- gorm for the ORM.
- qor admin for the admin panel.
- Dep for the package manager
- PostrgeSQL for the database.
- Redis for session caching.
- Install go
- Install PostrgeSQL
- Install redis
- Install Dep
- Clone project into
$GOPATH/src/github.com/ossn/ossn-backend
and go into that directory - Install dependencies by running
dep ensure
- Set the environment variables defined in the .env.example file to your machine
- Build and run the application
go run .
You can also use the docker file in this project to build the app but you still need to pass the environment variables to the container and connect the container to a PostgreSQL and to a Redis.
The master branch of this project is automatically deployed to heroku and is used as the production server.
The instructions on "Setting up a machine" can be used to deploy this app to an alternative environment.
- Whenever a model is update this server is responsible for rebuilding the frontend website, in order for the server to achieve this the environment variable
REBUILD_URL
should be set to the rebuild hook of the frontend - Heroku has an issue with qor's static assets (the static assets of the admin panel), so whenever qor is update the static assets from inside the vendor folder should be placed inside the folder "app"
- Once you've updated the schema.graphql file don't forget to run
go generate ./...
in order for your changes to be reflected in the go code
- app -> Static assets of the admin panel (see development notes for more info)
- controllers -> The controller for the OpenID connect endpoints
- helpers -> Small functions that are used across the project
- main -> Main server configuration including routes and middleware declaration
- middlewares -> Middleware definition
- models -> Database models and database connection
- resolvers -> Graphql models, Graphql mutation and query resolvers
- scripts -> Allows to run generate command
- Procfile -> Heroku's run command
- gqlgen.yml -> Gqlgen configuration
- schema.graphql -> Graphql definition