# App architecture advice wanted. :) - \*\*improved question \*\*

**URL:** <https://discourse.processing.org/t/app-architecture-advice-wanted-improved-question/44573>\
**Category:** p5.js\
**Created:** [June 10, 2024, 10:49pm UTC](https://discourse.processing.org/t/app-architecture-advice-wanted-improved-question/44573 "2024-06-10T22:49:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![vkbr](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/vkbr/32/16844_2.png) [@vkbr](https://discourse.processing.org/u/vkbr)\
**Post date:** [June 10, 2024, 10:49pm UTC](https://discourse.processing.org/t/app-architecture-advice-wanted-improved-question/44573/1 "2024-06-10T22:49:38Z")

</div>

Ok, I managed to build my view logic.  
Sorry, let me start over.

I’m making a visualization of Brasil’s congress.

There is the server, which querys the api, get and store data, process pictures and serve all of this. In server I have a Deputy class, that hold and processe all this data. We serve initially a subset of the data to the…

The client gets data and build a local `object` called CsDeputy (Client SideDeputy) that holds the data locally.

CsDeputy would have a display method, but… I’m willing to use forces to drive the display. Roughly, each deputy will be a ‘badge’ and also there is a Party class that attracts all deputies of that party (we have like 15 of those). Basically is this.

I built the visualization in a separated sketch to help me understand and test everything.

Turned out that the visualization is based on `particle life` as @scudly has pointed me to this amazing direction [here in this other topic](https://discourse.processing.org/t/help-thinking-out-an-attraction-behavior/44537/8).

This is built by a class of nodes that directly interact with the global array holding themselves to calc all forces between them.

Parties are also a node, a different `type`.

So now how to integrate all?

I thought of making a `Node` for each CsDeputy, and Party.  
So, Deputy John Doe will have node of type deputy as a member field. And also Party DEM will have a Node as a member.

Than I’ll have a global `nodes[]` with all them.

Is this a good idea?  
Or should I have a NodesBoard class to handle all this in a more OOP approach.  
I’m gonna have around 600 bodies, speed is a concern.  
Below is a picture of the testing arena, in the future each small circle will be a Deputy and the bigger ones parties, just to give an idea:

**edit:** Let me see if i can mak ethis a better question: I have already a deputies array, and a Parties one also. But they need to interact, should I make a nodes array and push the deputy node and the party node to it?  
Like: I instantiate a node from the CsDeputy constructor, and add it to the array?  
Or I just make nodes logic separated from and give each node an ID that will link it to each deputy or party?

I will always need to get a node from a dep or the other way around.

```auto
class CsDep(){
constructor(){
// blah
this.node = new Node{//blah}
//global array nodes
nodes.push(this)
}

```

or

```auto
class CsDep(){
constructor(){
// blah
this.id = 22
}
class Node(){
constructor(){
// blah
this.deputyId = 22
}
}

```

Id is already a field of `CsDeputy`, it’s actually providede from API.  
In fact I’m wondering if instead of an array I should use an object to store them, so I can use the `ID` field as index, like `deputies['13224455'].display`  
well.  
I"ll keep going, ANY input is appreciated.  
thanks

 ![sample](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/9/9/99f664369477694983451bfb1edd511dd8d92f5f.jpeg)
