Skip to main content

Backend

Code: https://github.com/VILLASframework/web-backend

Description​

The backend of VILLASweb uses the programming language Go and a PostgreSQL database.

Requirements​

Setup and Running​

  • git clone https://github.com/VILLASframework/web-backend.git to copy the project on your computer
  • cd web-backend
  • go mod tidy
  • go run start.go [params]

To obtain a list of available parameters use go run start.go --help. To run the tests use go test $(go list ./... ) -p 1 in the top-level folder of the repo.

Running the backend will only work if the PostgreSQL database is setup properly. Otherwise, you will get error messages.

If you want to use test data (including some test users), you can start the backend with the parameter -mode=test. Please check the repository of the VILLASweb-backend to find information on the test user login names and passwords. The testing mode is NOT intended for production deployments.

Auto-generate the API documentation​

The documentation of the VILLASweb API in the OpenAPI format can be auto-generated from the source code documentation using the tool swag. To do this run the following in the top-level folder of the repo:

  • go mod tidy
  • go install github.com/swaggo/swag/cmd/swag
  • swag init -p pascalcase -g "start.go" -o "./doc/api/"

The .yaml and .json files in OpenAPI swagger format are created in the output folder doc/api.

PostgreSQL database setup​

Please check the Readme file in the backend repository for some useful hints on the local setup of the PostreSQL database.