database design – Creating B2B Architecture proposal

Which are the steps to start to create a B2B architecture proposal?

Hi there, I’m beginner in my own project business about software So one of my clients required me propose a B2B architecture on Magento 2 OnPremise, bassed in their own sellers, servers and requirements of them.

I have no clue where start, so I figure I need to know check about recurring customers, visitors per day, concurrent visitors, orders, etcetera…

Finally; also purposing him which kind of servers hardware requirements we will need it.

Thank you in advance!

swift – iOS: Combine and Clean Architecture

I’m learning a lot of from Combine thanks to an amazing book in raywenderlich.
Currently i’m writing an app and following the clean MVVM architecture.

Then I have the following layers:

  • Domain(UseCases and RepositoryProtocols)
  • Data(RepositoryImplementations)
  • Presentation(ViewController and ViewModels)

So this is what I have by now:

LoginUseCase.swift

import Foundation
import Combine
public enum LoginState {
    case idle
    case inProgress
    case success
    case emailValidationPending
    case wrongPassword
    case invalidEmail
    case invalidPassword
    case error
}
public protocol LoginUseCase {
    func login(email: String, password: String) -> AnyPublisher<LoginState, Never>
}
public class LoginUseCaseImp: LoginUseCase {
    let repository: RegistroRepository
    public init(repository: RegistroRepository) {
        self.repository = repository
    }
    public func login(email: String, password: String) -> AnyPublisher<LoginState, Never> {
        return Future<LoginState, Never> { (weak self) promise in
            self?.repository.login(email: email, password: password) { (result: Result<Bool, LoginRepositoryError>) in
                switch result {
                case .success(_):
                    return promise(.success(.success))
                case .failure(let error):
                    switch error {
                    case .wrongPassword:
                        return promise(.success(.wrongPassword))
                    case .userNotExist:
                        return promise(.success(.error))
                    case .emailValidationPending:
                        return promise(.success(.emailValidationPending))
                    }
                }
                
            }
        }.eraseToAnyPublisher()
    }
}

LoginViewModel.swift

import Foundation
import DomainRadarAir
import Combine

public final class LoginViewModel: ObservableObject {
    private let loginUseCase: LoginUseCase
        
    public init(loginUseCase: LoginUseCase) {
        self.loginUseCase = loginUseCase
    }
    
    public func login(email: String?, password: String?) -> AnyPublisher<LoginState, Never> {
        guard let email=email, !email.isEmpty else {
            return Just<LoginState>(.invalidEmail).eraseToAnyPublisher()
        }
        guard let password=password, !password.isEmpty else {
            return Just<LoginState>(.invalidPassword).eraseToAnyPublisher()
        }
        
        return loginUseCase.login(email: email, password: password)
    }
}

Then in the LoginViewController.swift

    @IBAction func loginClick(_ sender: Any) {
            viewModel.login(email: emailTF.text, password: passwordTF.text)
                .print("State: ")
                .sink { (weak self) state in
                    guard let self = self else { return }
                    switch state {
                    // handle all cases
                    }
                .store(in: &cancellables)
    }

What do you think of this approach, passing AnyPublisher object from UseCase to ViewController through ViewModel?

Thanks in advance for your opinions.

architecture – How much should a react frontend application be automated tested?

I’m backend developer working on a very backend heavy application. So most of the business logic is writen in the backend. In our project we are considering a full rewrite of the frontend. Currently the frontend code is extremely messy and refactoring stuff takes forever. There are no tests.

I’m not a frontend developer eventhough I have made some contributions to the code and have a good overview on how the current code looks like. In the backend we have really good experience with writing test driven development. So I naturally through the some should be true for frontend development. But looking at from the perspective that the frontend is mainly visualizing data and calling rest api’s to invoke business logic. I’m considered if a strict test driven approach would be very cumbersome, with a lot of mock objects and allot testing overhead.

What are your experiences how much should you test? What do you do in your daily job and how does it work for you?

architecture – Best way to share code of micro-services written in the server-less framework

The microservices are going to be owned by a specific team. These microservices each will have their own resources such as DB, API Gateway, queue e.t.c. Other teams will have their individual instances(/deployments) of that microservice.

  1. What’s the best way to share code in this situation?

  2. Should we have just one shared repo or repo per shared service?

  3. If we use separate repo for shared service(s), how and where do we test them?

  4. Can we use the npm registry to deploy our shared services to projects? (this is my ‘crazy’ idea: option 3)

  5. Is git submodule the right way to do it instead?

  6. Can we use npm registry to deploy our shared services to projects?

php – Is there a canonical definition of SPA – or is SPA a broadly agreed-on architecture with fuzzy edges?

Question:

Is there a canonical definition of SPA which would exclude the software architecture model described below?


I’m working on an app with a new web-architecture model (new to me, at any rate) which has features which differentiate it from a Single Page Application (SPA) as the term is conventionally understood.

Since the model uses server-side and client-side variables which always automatically mirror each other, I would like, at least provisionally, to give the model a label something like Reflective SPA (or veSPA for short) but I’m concerned that due to its reliance on server-side processes, it may not qualify as an SPA at all and, as such, this name would be misleading and / or nonsensical.

Towards the end of the Wikipedia entry on Single Page Applications there is a statement:

A SPA is fully loaded in the initial page load and then page regions
are replaced or updated with new page fragments loaded from the server
on demand. To avoid excessive downloading of unused features, a SPA
will often progressively download more features as they become
required, either small fragments of the page, or complete screen
modules.

I’d strongly subscribe to this as a conventional definition of an SPA. This is absolutely what I think of when I read the acronym SPA.


What differentiates veSPA is that instead of:

page regions are replaced or updated with new page fragments loaded from the server on demand

veSPA repeatedly responds to user interactions by updating the queryString, either via:

1. Updating the URL (including the queryString), using:

  • window.history.pushState({}, document.title, 'https://example.com/' + queryString); (Javascript)

2. Reloading the URL (using a new queryString), using:

  • window.location.href = 'https://example.com/?' + queryString; (Javascript)

3. Redirecting the URL Request (using a new queryString) at server level, using:

  • header('Location: https://example.com/'.$Query_String); (PHP)

When the page is actually reloaded, various custom-data attributes in the root HTML element are populated from the queryString, using the super global variable $_GET in PHP.

When the URL queryString is updated, the same custom-data attributes in the root HTML element are populated from the queryString, using new URLSearchParams(window.location.search) in Javascript.

Either way – and this is the most important culmination of everything described above – the app-view is then rendered via CSS from the values in the custom-data attributes in the root HTML element.


Question:

Does this use of page-reloads and PHP (described above) mean this model is too differentiated from SPA (as conventionally understood) to have the term SPA meaningfully applied to it (or to use SPA in its name)?

Is there a canonical definition of SPA which would exclude the model described above?

API-based Architecture Pattern – Software Engineering Stack Exchange

After studying some basics about n-layer architecture, I face to a new proyect where my database is an ERP and the way to connect with it is via API calls. I can perform queries to obtain data but the only way to insert and update is using the API.

I have to write two applications, a website and a web service. Obviously I cannot just public my ERP API as webservice because a I need to make some restrictions. I’d like to share most of the code, so I have thought writting two presentation layers, using MVC pattern with their own model each one. Functionality might be different, but having shared procedures.

Since bussines logic is mainly done at ERP level, but I still need to implement very simple restrictions, and that persistance layer is based on an API and not directly to a database, what kind of architecture should I use?

Having a domain layer with that very simple business logic seems to overkill for me, and I dont know how if we should implement a data access layer since I don’t really have a typical database. All my thoughts are about creating just one layer for this business and data access, but I’d like to know if this is a common pattern I could read or study about.

P.S: I work in a very little team. I still want to separate concepts and make a clean use of layers, but I don’t want too much extra work for such a little team. We all will probably work at every layer.

procedural generation – How can we generate 3D architecture in a racing game’s background procedurally with respect/similar to the real world?

AFAIK they achieve this by

Parameterized Procedural Placement

They create a workflow where you create a handful assets in this case building floors and they procedurally tweak the parameters such as Floor count,size,tint and custom props such as air conditioning outside of the buildings.

I once a saw a video about ubisoft creating a procedural assasins creed city.They premade a bunch of houses and spread them randomly.

You should desing a workflow where you control how your building floors are stacked on each other and how each floor has its own specific unique props.

This is what i would do

  • I would decide what a building floor means to me.These would be my parameters: IsGroundFloor?, width and height of the floor, how many windows, a balcony?, general tint color of the floor material and unique set of models.(Such as vegatation, flowers, air conditioning or a satallite dish perhaps?).
  • I would decide how many floors should a building has.Define the minimum and the maximum
  • I would decide what will be the floor independent objects such as fire escape ladder which starts from ground to the top of the building, some garden? or fences?

with these parameters one can create wide range of different buildings considering you feed your procedural workflow with enough assets

models – How can we generate 3D architecture in the background procedurally with respect/similar to the real world?

AFAIK they achieve this by

Parameterized Procedural Placement

They create a workflow where you create a handful assets in this case building floors and they procedurally tweak the parameters such as Floor count,size,tint and custom props such as air conditioning outside of the buildings.

I once a saw a video about ubisoft creating a procedural assasins creed city.They premade a bunch of houses and spread them randomly.

You should desing a workflow where you control how your building floors are stacked on each other and how each floor has its own specific unique props.

This is what i would do

  • I would decide what a building floor means to me.These would be my parameters: IsGroundFloor?, width and height of the floor, how many windows, a balcony?, general tint color of the floor material and unique set of models.(Such as vegatation, flowers, air conditioning or a satallite dish perhaps?).
  • I would decide how many floors should a building has.Define the minimum and the maximum
  • I would decide what will be the floor independent objects such as fire escape ladder which starts from ground to the top of the building, some garden? or fences?

with these parameters one can create wide range of different buildings considering you feed your procedural workflow with enough assets

architecture – How to deal with data that needs to be accessed by all objects?

I have a World class that currently only has one instance. It has data and methods that need to be accessed by all other game objects. Right now I’m hardcoding a reference to the global variable world in all of my methods, and this doesn’t seem to be the right approach.

Another idea I tried was a dependency-injection-esque approach, where each object stores its own reference to the world object, but this clutters memory with unnecessary references, so I don’t think this is the right approach either.

Another approach I tried was passing world as an argument directly into the method call, but this led to repetitive code as I was constantly passing world into any function that needed it.

A bit of research hasn’t worked for me because it’s hard to summarise my problem into a few words that can return Google search results. It seems this isn’t a problem in the majority of applications, so I’m wondering if this is mainly a gamedev situation.

What is the best way to solve this problem?

design – Doing the same tasks from multiple places when using Clean Architecture and CQS?

I’m working on some tooling that will help speed up the process of setting up a new computer for new developers. I want the user to be able to execute many tasks either as one task or grouped together with other tasks. For example, setting up the server might consist of the tasks A, B, C and D. Let’s say that A is installing IIS as an optional windows feature and D is adding our Web Applications to an IIS site. I want the user to be able to perform D individually as well, we might add or remove an application and then we don’t want to force the user to go through A-C just to do D.

The tool is built using Clean Architecture. If we invoke the tool with

> my-tool D

the presentation layer will simply invoke DCommandHandler by passing DCommand to a mediator. DCommandHandler contains the code to perform task D.

Now to my problem, how do I orchestrate invoking task A-D?

> my-tool setup-everything

My first thought where to let CompositeCommandHandler do the work:

Handle()
{
    _mediator.Send(new ACommand);
    _mediator.Send(new BCommand);
    _mediator.Send(new CCommand);
    _mediator.Send(new DCommand);
}

This feels ok-ish for this use case but generally I don’t like the idea of invoking other handlers from a handler. I could move the code from CompositeCommandHandler to the presentation layer but the tasks must be invoked in order so I really think Application should own that logic.

I could move the logic for performing Task X into a separate class that can be invoked from multiple places:

ACommandHandler:
Handle()
{
    _taskA.Execute();
}

CompositeCommandHandler:
Handle()
{
    _taskA.Execute();
    _taskB.Execute();
    _taskC.Execute();
    _taskD.Execute();
}

However now all handlers will just invoke Task X and that starts to smell like lasagna code… I need task A-D to be invoked in the correct order so I can’t use events/notifications either. I’m not sure what would be the best way to solve this problem, any ideas?