BEOpenSourceCollabs / EventManagementCore

Event management system collaboration project for the Backend Engineering discord.
Apache License 2.0
2 stars 1 forks source link

Event Management System

User management - login / sign up / roles assigned to users ( organisers, admins and normal users)

Setup

git clone https://github.com/BEOpenSourceCollabs/EventManagementCore
cd EventManagementCore

Postgres Docker Configuration

Application Configuration

Setup the application environment and add the database configuration.

Run

To run the application and all required services within docker.

docker compose up

Useful addresses

Name Address
Server Base http://localhost:8081
Documentation http://localhost:8081/swagger
PGAdmin https://localhost:8888/

To login to the PGAdmin dashboard use the email and password set in PGADMIN_DEFAULT_EMAIL and PGADMIN_DEFAULT_PASSWORD

Run Standalone

This runs the application without docker.

You will need to ensure you have a postgres database setup, and run the migrations.
You may need to do that manually.

make run

Run Tests

make test

# or 

make test.unit

Development

Running the application for development

Best practice for running the application is as follows.
After completing prerequisit steps to setup and configure the application the docker compose can be used to run the development environment.

docker compose watch

Using watch will automatically syncronize changes to the running container and restart the application.

Advanced

This section shows example usage of the docker-dev.sh script, which builds only the event-mgmt-core image and runs it in a container. You will have to setup and configure the database before running.

This is akin to running make run but within a docker container instead.

  ./docker-dev.sh

If you want to run the database from docker-compose.yml and use that you can do the following:

  # start only db
  docker compose up db

  # optionally you could start both the db and pgadmin
  docker compose up db pgadmin

Note: the database containers name 'event-mgmt-postgres' can be used as the host in your .env file when using one of the above commands to run postgres within a container.

Then run the application:

  ./docker-dev.sh

Database Migrations

CLI

To work with database migrations, golang-migrate cli needs to be installed and working.

Working with migrations

The init.sql file is responsible for creating an empty database. This file is automatically executed by docker-compose during the first run. After the initial setup, database migrations handle subsequent changes to the database schema.

Each migration is versioned and follows a sequential numbering format, starting with 000001.

Each migration consists of two files -

To apply all the migrations from first, all the way to the latest

    $ make migrate.all.up

To view current version of database (current version means current migration # it is at),

  $ make migrate.version

To create a new migration,

  $ make migrate.create NAME=name_of_your_migration

To goto a specific version of database ,

  $ make migrate.goto V=version_you_want_to_goto

Example: make migrate.goto V=4

To undo all the migrations and go to initial state,

  $ make migrate.all.down