architecture – Using rest services or python modules directly?

Imagine you’re in a Python setup, with all of the projects you’re working on. Now, as a base line, you have a Python module that is the backbone (backbone.py) to everything when it comes to getting data from a datasource. There is also a FastAPI implementation of this this backbone (backbone-api.py), offering a handy way of getting the data out.

Now, there is another project emerging, which needs to use the data of the backbone. Also implemented with python and FastAPI (different-angle.py). Pretty much just a different angle of the data.

There appear to be two options:

Option A:
Importing the backbone module directly into the new project, to allow direct access to the data and best performance.

Option B:
Using the FastAPI implementation of the backbone, to simplify the process, but at the cost of latency.

To my mind, Option A seems to be slightly better. This is mostly as this will increase performance and leverages Python modules better. Option B has the advantage of being an easy setup, as you don’t need to install the backbone module and its configuration. This is probably also fine for smaller operations, but Option B would probably have some disadvantages when it comes to returning larger amounts of data.

enter image description here

architecture – Should 2 different MySql databases from 2 different applications be joined together if the 2 apps are merging into 1?

This is a question about software architecture, not databases.

I currently have 2 completely separate web applications, call them A and B for simplicity. They are on their own machines, with their own databases and web servers. My job is to integrate these 2 applications together (how I’m doing that from the front/backend is irrelevant here).

My scenario when it comes to the database is this: previously apps A and B were separate, but now B is being treated as a module, and will be used inside of A. To the user, it will seem like there is only one application. Behind the scenes though, is it best practice to keep the databases separate, or is it best for app A’s database to completely absorb the tables from app B’s database and just create one, very large database?

The data isn’t related between the two applications, so to me it makes sense to keep the 2 databases separate since B is acting as it’s own module still, regardless of whether it’s a part of app A or not. What do companies that have a large application do? Do they create a new database for every large component of their software or do they keep it all in one place?

design – Building a Microservices App — Can you give feedback on architecture?

I did some googling, and I was directed to Software Engineering to ask architecture questions. If you know of a different forum that could help me, please direct me to it

I recently started learning about microservices, and would like to build an experimental app (the backend) just for practice. I’ll explain the app requirements, and after that outline my microservices-based solutions (and some doubts/questions I have). I’d love to get your feedback, or your approach to building this app using microservices.

Please note: I am a beginner when it comes to microservices, and still learning. My solution might not be good, so I’d like to learn from you.

The App (Silly App):

The purpose of this app is to make sure users eat carrots four times a week. App admins create a carrot eating competition that starts on day x and ends 8 weeks after day x. Users can choose whether or not to participate in the competition. When a user joins the competition, they need to post a picture of themselves eating a carrot. The admin approves/rejects the picture. If approved, the carrot eating session counts towards the weekly goal, otherwise it does not. At the end of each week, participating users are billed $10 for each carrot eating session they missed (for example, if they only eat carrots two times that week, they’re billed $20). That $20 goes into a “money bucket”. At the end of two months, users who successfully ate carrots four times a week every single week divide the money in the bucket among themselves. For example, assume we have users A, B, C. User A missed all carrot eating sessions for two months (puts $40 a week in the money bucket, so $320 by the end of two months). Users B and C eat their carrots four times a week consistently for two months. So users B and C take home $320/2 = $160.

Simplification:
I wanted to start simple. Forget about money. Forget about admin approval. We can add that later. For now, let’s focus on a very simplified version of the app.

  • User can signup/login/logout to app
  • When a user signs up, they are automatically enrolled into the next carrot eating competition
  • Users can post an image of him/herself eating a carrot
  • Users can see a feed of other users images (similar to instagram, except all pics are of people eating carrots)
  • Users can access their profile – a page that displays how they’re doing in the competition: I.e,for each week, how many carrots they ate. And which weeks they failed at.
  • At any point in time, users can access a page that shows who the current winners are (i.e, users who did not miss a carrot eating session yet).

Is this an appropriate simplification to start with?

Thinking Microservices – Asynchronous Approach:

Auth Service: Responsible for Authenticating User

Database:

  • User Table: id, username, email, password

Routes:

  • POST /users/new : signup
  • POST /users/login: login
  • POST /users/signout: signout

Events:

Image Service: Responsible for Saving Images (upload to Amazon S3)

Database:

  • User Table: userId, username
  • Image Table: imageId, userId, dateUploaded, imageUrl

Routes:

  • POST /users/:userId/images: Post new image
  • GET /users/:userId/image/:imageId: Return a specific image
  • GET /images: Return all images (Feed)

Events:

  • Publishes:
    • Image:created (userId, imageId, imageUrl, dateUploaded)

Competition Service: Responsible for managing competition

Database:

  • Competition table: id, startDate, duration
  • User table: id, username, competitionId, results (see below)

Routes:

  • POST /competition: create a competition
  • GET /competition/:competitionId/users/:userId: get results for a specific user
  • GET /competition/:competitionId/users: get a list of users participating in competition (see below)
  • GET /competition/:competitionId: get a list of winners, and for each looser how many workouts they missed

Events:

  • Listens:
    • User:created
    • Image:created

In the database, user table, Results is the JSON equivalent of

results = {
   week1: {
       date: 'oct 20 2020 - oct 27 2020',
       results: ('mon oct 20 2020', 'tue oct 21 2020', 'thur oct 23 2020'),
   },
   week2: {
       date: 'oct 28 2020 - nov4 2020',
       results: ('somedate', 'somedate', 'somedate', 'somedate'),
   },
   week3: {
       date: 'nov 5 2020 - nov 12 2020',
       results: (),
   },
   ...
}

Better ideas on how to store this data appreciated

GET /competition/:competitionId returns

const results: {
 winners: ({ userId: 'jkjl'; username: 'jkljkl' }, { userId: 'jkjl'; username: 'jkljkl' });
 loosers: (
   { userId: 'kffjl'; username: 'klj'; carrotDaysMissed: 3 },
   { userId: 'kl'; username: 'kdddfj'; carrotDaysMissed: 2 }
 );
};

What do you think of this? How would you improve it? Or would you approach this from an entirely different way?

architecture – Synchronizing clients – Game Development Stack Exchange

I have a server-client setup where each client has a number of screens attached, and the screens together form the display. As such, the visuals displayed by each client needs to be roughly in sync. Luckily the domain is not high speed, so I don’t have to have them all perfectly in sync, but obviously more in sync is better.

I am targeting a 100ms lead time between receiving states and acting upon them, I’m operating in a LAN so that is plenty, packets are sent out at 100Hz and interpolation is handled through a buffer which automatically selects the right packets. So I don’t have to worry about that. Visuals are running at 60 FPS so there is minimal difference frame to frame.

Right now there are two basic solutions: 1. have each client sync with a time server over the internet or locally, or 2. emulate the same logic in the code and do the synchronization as part of establishing connection. What would be the best way to synchronize time?

I’m concerned that I’m running into an XY problem here assuming that synchronizing time this way is a good idea at all.

I have noticed that existing questions on this topic are about 1 server connecting to several clients, each showing their own visuals. I think this problem of requiring sync between clients to maintain visual continuity is a bit different, so maybe there will be different approaches. I am aware of other questions that discuss the more common situation though.

c# – EF Migrations on Microservices architecture

I’m starting get into in microservices architecture and I want to know where is the right place for EF migrations files?
I’m working like this:

introducir la descripción de la imagen aquí

I have seen the EF Migrations files inside of API service, but I really do not know where should I put them…
Which are the best practices to do this?

architecture – Instantiating GameObjects in Custom Game Engine

So,i’m having a bit of an issue with instantiating my gameobjects into to universe(My Scene object).

I can create an empty object from scratch and populate it from there with ease,my problem starts when i try to clone the gameobject which i just created.

My steps are

  1. I create an empty gameobject (GAMEOBJECT A)
  2. I add an component to it (COMPONENT A)
  3. Now i create a gameobject B from A
  4. GameObject B created,and the component A is in the component list of the gameobject B
  5. I try to get the component using inheritance but nullptr returns

It seems when i try to clone components,it returns only the base class pointer.There i try to recreate the derived class and add it to new gameobject’s component list but obviously i fail.

  • If i cant solve this with inheritance how can i solve it ?
  • is there better way to implement such a desing ?
  • or i just fail to use inheritance in c++.If it’s, can you guys point out what am i doing wrong here

This is my GameObject AKA RGameElement

enter image description here

This is my Component AKA RElementComponent

enter image description here

and this my Instantiate via gameobject ref function

enter image description here

Clean Architecture Gateway layer depends on outer layer

Looking at the clean architecture layers and flow diagrams, and implemented it my self in my applications, I’ve always wondered which layer is supposed to contain the DB, or any 3rd Party service or SDK.

Looking at both of these images raises the question if there isn’t violation in the outer layers.

enter image description here

enter image description here

I’ve imagined the layers division like this:

enter image description here

But this means that there is a violation of the dependancy rule. Since the gateway always knows about both the external service, and the application it self, the entities.

Is there a correct way to draw these layers? I’ve read a couple of resources asking this question, but didn’t really get a full answers to what I need. For example: https://groups.google.com/g/clean-code-discussion/c/oUrgGi2r3Fk?pli=1, Doesn’t repository pattern in clean architecture violate Dependency inversion principle?

I get it that the meaning of clean architecture is kept, and the inner layers, the entities and the use case, aren’t affected by a change in the DB and the gateway, but was just wondering if maybe this is more accurate:

enter image description here

webservice – Learning Web applications and network architecture. Newbie questions on how many tiers?

I’m in school right now and having a debate about web applications and flat networks. There is a debate ongoing right now in a class/group about a network diagram we are looking at. The network is flat with zero network segmentation and there are numerous web applications within the network. Everything is in that “network”, all servers/db. The web applications are each on their own server and there is one database within that network for all the data being stored. There is also all the user computers within that network. Clients can log into the web application and look at their information, so there is that aspect as well.

So we’re all having a debate about the exact architecture of the applications and I think we’re getting tripped up on how we interpret the wording.

One group is saying that the architecture is single tier for the applications because the network is flat and there is no true segmentation except for the various servers and the database.
One person is saying it’s two tier because it’s a flat network but there is the presentation layer outside of the network in the form of the clients (client) computers.

Other people saying it’s three tier architecture, just in a flat network with no segmentation.

My take is that it is three tier application architecture because the presentation layer is split out from the business logic on the web app and the database. Even though the user computers are inside the network, they’re still separate from the web application and the db. It’s just in a poorly segmented network.

I know this seems pretty simple, but there are a few people that are confused by this due to the lack of segmentation and what their understanding of what a tier is.

Any input is highly appreciated.

Thank you all.

Multitenancy – Get tenant in microservices architecture

In a multi-tenant architecture where each tenant has its own database, what would be the best way for each of the microservices to obtain information about the tenant (such as which database to connect to)?

We are still in the modeling phase of the application. We are having difficulty to come up with the best design. We are currently thinking about doing this:

  1. The user logs in to the application. Our authentication server
    (IdentityServer 4) returns the user’s information along with the
    tenant_id he belongs to (this information is in a claim).

  2. The application directs the user to a specific tentant subdomain.

  3. The frontend communicates with an API Gateway. Through a Claim,
    the API Gateway knows the tenant through the claim of the logged user.

  4. The API Gateway calls each of the microservices calling the
    tenant_id as a parameter in the endpoint.

  5. The microservice receives tenant_id as a parameter and executes a
    query in Redis to obtain the connection string from the database.

We don’t know if this is the best solution. We think it is being a lot of work to have to inform tenant_id as parameter in all endpoints of all microservices. We appreciate all the help and suggestions.

api – WebApp architecture with multiple client

I’m investigating how I could achieve a project I’ve been thinking of for a while. Let me explain the project (I will not go into too much details, but I think what I’ll write will be enough).

So, I am planning a WebApplication that, once opens, allow the user one of two options:

  • Creating a room (Host);
  • Joining a room (Player);

Suppose the host creates a room with its setting; at the end of the setting form, a screen with something like:

Room uniqueRoomID has been created. n Players are connected, wait for others.

Now, the players kick in. Suppose n players join the room:

  • The host will now have a different screen, showing information about the room;
  • Each player will have its own screen, with its own information;

From now on, you can think of a poker game: any player can make a call, based on the previous one, until everyone leaves. The first “match” has finished, so it starts the second and so on, until a total match of x have been played.


Hoping I’ve explained enough what I need to achieve, here what I think:

  • I need a server running somewhere (let’s say a node.js server, so I use JavaScript even for the server). Suppose I have the server running on 123.456.789.123;
  • When the host creates a room, it communicates with the server, for example by fetching the URL 123.456.789.123/API/create-room; at this point, I was thinking of adopting PubSub pattern: the call let the server creates a new topic TOPIC_RoomNameId, and return OK to the host;
  • Now, all the clients must execute the fect 123.456.678.123/API/join-room/RoomNameId: this will lead them to subscribe to the topic created from the host. Question here: I think the subscription should be executed from the player itself, and not the server, right?
    I mean, the fetch on API/join-room should return OK if the room exists, and then on the OK response I execute the subscription from the player… Right?
  • At this point, whenever a player makes a call, it sends a message to the server, which then will publish something new on the topic, alerting all the players about the new call;

So, if you have reached this point of the question, here’s what I was thinking to use:

  • Ionic and REACT, so that the WebApp can be published in mobile stores, besides being used on Desktop and browsers;
  • Using Node.js for the server. Then, I should host it somewhere. I’d like to use AWS or Google Cloud, but maybe they are an overkill;
  • Using Socket.IO (https://socket.io/docs/rooms/) for the PubSub pattern;

Of course, I still don’t have any code to show, I’m planning the architecture of the WebApp. But now, after have written all you need (or at least, I hope this is enough), here’s some questions:

  • The idea of using PubSub pattern is ok? Because I can see that I could also have a client-client connections, making the clients communicate between them.. But I honestly don’t understand how could I know the addresses to which send the messages. Without a Server, I don’t see how this could work.
    Notice that the players are different devices, thus different people in different locations;
  • Again, any idea to where I could host a server like the one I would need?
  • I’m afraid I’m missing something like keeping the state of the room. Suppose a player closes the browser: it loses everything he has done so far, and can’t recover that! So, it seems to me some kind of storage is needed.
    I don’t know if I could store everything in the server like having arrays (I mean, if the application will be used by me and my few friends I suppose this is OK), or adding a Database that will store any kind of information about the room/player/anything else;
  • Regarding the point above, I guess I would also need some kind of logic for each player, otherwise even if I save the data in the database.. How could I link data to players? 🙂

Thanks.