I can not come up with a good architecture for my card game. I need help to understand how games usually are designed.First, I will describe game rules.Game RulesSetupThere are four players, each two player form a team.Each player gets 12 shuffled cardsThere are 4 blinded cards on table(river)Players order are like this BettingEach player can pass or select a number greater than current bet between 100 to 160Betting starts from first player and circles until a team passOnce a player pass they can't bet anymoreThe team that wins the betting round should at least collect points equal to their bet in order to win the gameThe team that lost the betting round should not allow the their team achieve their goalIf the team that won betting round gets all the points the other team will get negative points equal to their betif the team that lost the betting round collects all the points the other team will get double negative pointsGame flow and collecting pointsPlayer that won betting round (the king) gets four remaining cards on the table. Then she/he can save a set of four cards in their team cards bank without even playing them.The king will pick a suit as the ruler suit and let others know thatKing starts the game by putting a card from his/her hand on table. Each other player should play in this orderif they have the same suit of that card in their hand, they have to play one of those cardsif they don't have it, they can play any other suitAfter all other players played their hands, winner of the round will be:The one who has highest card if all cards are the sameThe one who has highest ruler card if there is anyWinner of the round will collect cards and put it in their bankPlayer who won previous round will start the next roundThis will continue until everybody's hand is emptyCounting pointsWinning each round has 5 points. This means every 4 cards has at least 5 points.Having Ace, 10 or 5 in bank each adds 5 pointsMy DesignClassesclass Card {   string suit;   string rank}class Deck {  List cards = [];  List suits = ['S', 'H', 'D', 'C'];  List ranks = ['1', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A'];  private void init(){..}  void shuffle(){...}}class Game{  Deck deck = new Deck();  Player player1;  Player player2;  Player player3;  Player player4;  int _isOn = 0;  Game(this.player1, this.player2, this.player3, this.player4){    deck.makeCards();    deck.shuffle();    start();  }  void start(){    player1.cards.addAll( deck.cards.getRange(0, 12) );    player2.cards.addAll( deck.cards.getRange(12, 24) );    player3.cards.addAll( deck.cards.getRange(24, 36) );    player4.cards.addAll( deck.cards.getRange(36, 48) );    deck.cards.removeRange(0, 48);  }  String toJson(){  }  String toString(){  }}class Player{  String name;  int points;  List cards = [];  Player(this.name, {this.points});  String toJson(){}  String toString(){}}My ProblemNow that I've defined all these classes I don't know how to bind this definitions to a database (like Mongo) and control the game flow.Where should all that logic go?How should I keep state in a server/client scenario?Note:I'm using Dart to program this but I don't necessary want answers be written in Dart.
How do I design a card game?
architecture
You're making a classic mistake here.  Someone told you to make a web application for a card game, and you're trying to determine how to make all of it at once.  This approach confuses even the best programmers, since studies have shown that you can only retain 7 pieces of information readily available in your mind at one time.  Trying to juggle with more requires intense concentration and you cannot expect to keep that up.Rather, try to focus more on writing a card game library like someone were going to call your library in order to play your card game.  You seem to have an excellent start on your model.  That is good, but you need to make Game the interface by which callers can use make moves and so forth.  So I would expect Game would have several new methods like:getPlayers()        // Get all player infogetCurrentPlayer()  // Get information about the active player in his turn (hand, money to bet with, etc.)fold()              // Current player folds and current player changesbet(float amount)   // Current player bets and current player changesIn short, everything you need to know in order to run the game, you can do so using your object Game.  Only once you have this do you proceed to step 2.Write a separate class whose sole purpose is to receive incoming requests, apply them to Game and send the output back to the user.  If you want to convert Game output to JSON, you do it outside of Game since that is not the purpose of Game!  In order to persist this information, you could create another class which provides an interface to MongoDB.  This class would not know of the existence of Game and neither would Game know of the existence of this class.  In short, focus on the individual components, and you'll be fine.  You start to go wrong when you're trying to take too many aspects into consideration when writing your program.  As a wise professor once told me, Know and embrace the fact that the first program you write for a project will be rewritten in its entirety by the end.