/microservice-course

Sumé LMS Course Microservice

Primary LanguageGoApache License 2.0Apache-2.0

Sumé LMS

goreportcard github action codecov GitHub Discord

About Sumé LMS

Note: This repository contains the course microservice of the Sumé LMS. If you are looking for more information about the application, we strongly recommend you to check the documentation.

Sumé LMS is a modern and open-source learning management system that uses modern technologies to deliver performance and scalability to your learning environment.

  • Compatible with SCORM and xAPI (TinCan)
  • Flexible and modular
  • Open-source and Free
  • Fast and modern
  • Easy to install and run
  • Designed for microservices
  • REST API based application
  • and more.

Table of Contents

Prerequisites

  • Go >= 1.21
  • PostgreSQL >= 16.0

Prepare

Clone the repository

$ git clone git@github.com:sumelms/microservice-course.git

Access the project folder, and download the Go dependencies

$ go get ./...

It may take a while to download all the dependencies, then you are ready to build.

Building

There are two ways that you can use to build this microservice. The first one will build it using your own machine, while the second one will build it using a container runtime. Also, you can build the container image to use it with Docker or Podman, but it is up to you.

Here are the following instructions for each available option:

Local build

It should be pretty simple, once all the dependencies are download just run the following command:

$ make build

It will generate an executable file at the /bin directory inside the project folder, and probably you want to know how to run it.

Container build

At this point, I'll assume that you have installed and configure the container runtime (Docker or Podman) in your system.

$ make container-build

If everything works, you can now run the microservice using the container image.

Local database

You can have your local database running the following command:

$ docker-compose up -d postgres

And then you could run the migrations using

$ make migration-up

Note You will have to install the golang-migrate tool It uses the same environment variables from the configuration section.

Running

OK! Now you build it you need to run the microservice. That should also be pretty easy.

Local run

If you want to run the microservice locally, you may need to have a Postgres instance running and accessible from your machine, and you may need to first configure it. Then you can run it, you just need to execute the following command:

$ make run

Once it is running you can test it: http://localhost:8080/health

Container run

If you want to run the microservice using a container runtime, the easiest way to do it is using the docker-composer or podman-compose.

All that you need to do is, execute the command:

$ make compose-up

It should create 2 containers, one that runs the microservice and another that runs the Postgres. If you already have your own Postgres instance you can only run the microservice container:

$ make container-run

Keep in mind that, in both cases, it will load the config/config.yml file from the project. If you want to change some configurations you can set the environment variables in your docker-compose.yml file, or edit the configuration file.

Once you have the IP address you can now access the endpoint: http://localhost:8080/health

Configuring

You can easily configure the application editing the config/config.yml file or using environment variables. We do strongly recommend that you use the configuration file instead of the environment variables. Again, it is up to you to decide. If you want to use the variables, be sure to prefix it all with SUMELMS_.

The list of the environment variables and it's default values:

SUMELMS_SERVER_HTTP_PORT = 8080
SUMELMS_DATABASE_DRIVER = postgres
SUMELMS_DATABASE_HOST = localhost
SUMELMS_DATABASE_PORT = 5432
SUMELMS_DATABASE_USER = postgres
SUMELMS_DATABASE_PASSWORD = password
SUMELMS_DATABASE_DATABASE = sumelms_course

We are using configuro to manage the configuration, so the precedence order to configuration is: Environment variables > .env > Config File > Value set in Struct before loading.

Testing

You can run all the tests with one single command:

$ make test

Documentation

The complete Sumé LMS documentation can be found in our official website.

API

This project uses Swagger to generate the API documentation and API mockup, the files can be found swagger directory.

Sometimes, a microservice can cover more than one domain boundary, in this case, the API scheme should be stored in the same directory indicated above, but following the following filename convention: <domain-name>-api.yaml

The best way to edit the API scheme is by using the Swagger Editor.

Contributing

Thank you for considering contributing to the project. In order to ensure that the Sumé LMS community is welcome to all make sure to read our Contributor Guideline.

Code of Conduct

Would you like to contribute and participate in our communities? Please read our Code of Conduct.

Contributors

contributors

Made with contrib.rocks.

Support

Discussion

You can reach us or get community support in our Discord server. This is the best way to find help and get in touch with the community.

Bugs or feature requests

If you found a bug or have a feature request, the best way to do it is opening an issue.

License

This project licensed by the Apache License 2.0. For more information check the LICENSE file.