Code Monkey home page Code Monkey logo

goedu's Introduction

GoEdu - educational reference project

This is educational and reference project created to demonstrate how can we implement business applications in Go.

Table of contents

1. Introduction

  1.1 Purpose of this Repository

2. How to Run

  2.1 Running the application from scratch

  2.2 Make Binary

  2.3 Build Docker image

  2.4 Run Tests

  2.5 Tools Used

3. Inspirations

1. Introduction

Hexagonal Architecture

1.1 Purpose of this Repository

This is a list of the main goals of this repository:

  • Get experience of implementing a monolith in a modular way in Go
  • Applying software engineering best practices (Clean Architecture, Design Patterns, Testable Design etc)
  • Keeping design artifacts alongside with the source code: C4 Model, OpenAPI spec, ADR

2. How to Run

2.1 Running the application from scratch:

make run

2.2 Make binary

make build

2.3 Build Docker image

make docker-image

2.4 Run tests

make test

2.5 Tools Used

3. Inspirations and Recommendations

goedu's People

Contributors

nalkhovikleverx avatar aliaksei-kosyrau-leverx avatar

Watchers

 avatar  avatar

goedu's Issues

Extract API module from registration module.

We need to extract public API of the registration module into the separate package which other modules can depend on. To do it we need to define a facade interface with collection of operation that module supports with appropriate input and output parameters. It would serve as public contract of this module.

type RegistrationService interface {
        RegisterNewUser(context.Context, RegisterNewUserCommand) (RegisterNewUserCommandResult, error)
        ...
}

We have to duplicate types that lay down in application layer into this separate module because the may change by the different reasons. All types in the registration module is considered as implementation specific.

Originally posted by @nalkhovikleverx in #10 (comment)

Implement basic functionality of UserAccess module - CreateUser and Login

Discussed in #7

Originally posted by nalkhovikleverx April 21, 2024

Problem

After successful registration confirmation, users are unable to log in with their registered password and email. To enable this functionality, we need to support it in our system.

Analysis

  1. After successful registration, the user must be created in the UserAccess module. Currently, the UserAccess module lacks the command to create a user. This command needs to be implemented. Later, we will link the UserRegistration events with this command.
  2. The Login command should also be implemented. It should accept the user's email and password as input and return the UserClaims object. For now, the fields of this object should include at least the following information:
    • UserID
    • Email

Possible Solution

We should focus on implementing only the application logic for now, without dwelling on infrastructure details. Examples provided here:

UserRegistration seems not properly encapsulated.

Discussed in #5

Originally posted by nalkhovikleverx April 19, 2024

Problem

The invariants are meaningless in conditions of poor encapsulation. Right now you can edit the state of UserRegistration model from the lowest layers. It puts the model into an invalid state where model invariants aren't controlled.

Analysis

The question is how to maintain the encapsulation of UserRegistration in Go when we need its internal state to form a database query, or vice versa, when we need to restore the state of the UserRegistration from the database.

Possible Solution

To keep things simple we can use some sort of DTO which crosses not a network boundaries, but a logical boundaries of a model. We can use this DTO to populate the database state. Also we can use it to restore the model from the database as well.

The similar example we can see in:

Other solution is demonstrated in following projects:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.