Skip to content

A sample project in Go that tries to follow CLEAN architecture, SOLID principle, and 12 factor methodology

Notifications You must be signed in to change notification settings

aniskhan001/university

Repository files navigation

University [WIP] 🎓

A sample project in Go that tries to follow:

This application offers to manage entities(departments, clubs, teachers, students, etc.) in a university by providing a REST API.

Project Structure

The project is separated into different layers. Outside layers can be dependant on the inner layers. But the inner layers should not know the implementation details of outer layers. The flow of data can be bidirectional, but this does not mean that the inner layers are dependant on the outer layers.

clean architecture

Fig: CLEAN architecture way of representing this application

Models (domain centric)

Models

Use cases (domain centric)

Use cases

Repositories (database)

Repositories

Presenters

Presenters

Infrastructure

Infrastructure

Delivery

Delivery

Configuration

  • This project uses .editorconfig
  • This project uses a separate dev.Dockerfile for hot reload
  • This project uses a Relational Database (MySQL) to store data & information
  • This project uses infrasctructure/config/config.local.yml to load application configuration

Development

make run

This will boot up application dependencies (DB, cache, etc.) in the background with docker-compose, and then run the application container in the foreground so we can watch the logs. The default Dockerfile is for production use, while dev.Dockerfile is being used for local development.

Hot Reload

To pick up the changes in the running container, this project uses CompileDaemon. It accepts the go build command as an argument.

ENTRYPOINT ["CompileDaemon", "--build=go build -mod=mod"]

Whenever changes are detected, it tries to run the build command again so that it can restart the server. To detect the changes, a volume is attached to the server container, which mounts host files to that volume.

volumes:
    - ./:/project

TO-DO

  • Authentication
  • Caching mechanism
  • Deployment configuration
  • Detail presentation of data (actual value instead of IDs) in API response
  • Unit tests

About

A sample project in Go that tries to follow CLEAN architecture, SOLID principle, and 12 factor methodology

Topics

Resources

Stars

Watchers

Forks