I'm staring new project, cross-platform. I want to use onion architecture there. It will be a simple game (tic tac toe), just for education purposes. This app will be client-server type.

Now, I read a lot about onion architecture, but I'm still not exactly sure how to deal with it in client-server.

Should I create two different repositories(1) for server and for client? Or should I keep them both in single solution(2) (since many class/interfaces in Core/Domain are the same for both)?

  • (1) - source code repositories (on bitbucket or sth like that)
  • (2) - Visual Studio Solution


It will be cross-platform app (C# via xamarin) with single server also in C#. Communication via WCF. Server will just store user accounts, watch every move, save history of games - not important, it's just for education.

Answering @Kasper, how do I see OA in client-server app:

I thought, I could share as much code as possible in Core of Onion - like Entities, Helpers, Logger(?), Interfaces... Then, I will have another layer - project for Client API (Application and Domain services) and Server API (Application services - consuming and sending messages from/to clients), then Interface layers. Separated for Clients and for Server.

So, single VS solution, two apps, single Core. I know it's technically possible - but is that a good practice?

  • 1
    Can you describe how you see your client server tic-tac-toe in an onion architecture? Commented Sep 22, 2015 at 16:22
  • @KaspervandenBerg I've edited my question with quick description how would I see it Commented Sep 22, 2015 at 16:52

1 Answer 1


It is not clear what you mean by "repositories". Do you mean Source Code Repositories ? In this case, definitely use only one repository.

Also, it is not clear what you mean by "solution". You are using C#, so presumably Visual Studio, and in visual studio "Solution" is a container of all your projects. So, definitely use one solution. This solution would contain multiple projects.

So, your "Tic Tac Toe" solution would contain:

  • One "Client" project for your client (perhaps of type WinForms application ?)
  • One "Server" project for your server (perhaps of type Console application ?)
  • One "TicTacToe" project with all code that is common for both (of type Class Library.)

The "Client" project will depend on (make use of) your "TicTacToe" project, and your "Server" project will also depend on (make use of) your "TicTacToe" project.

Furthermore, even though your client project does not directly invoke (cannot make use of, at the source code level) your server project, you should still define the client as depending on the server, because every time you want to run the client, you want Visual Studio to make sure that the server is up to date. (Has been compiled.) Then, you could have a mechanism in place which automatically restarts the server each time it gets recompiled, but that's beyond the scope of this question.

So, the TicTacToe Class Library project can be thought of as the center of your onion, the Server Application project can be thought of as a middle layer of your onion, and the Client Application project can be thought of as the outer layer of your onion.

  • Thanks! In my case it will be more the one clinet. I'm planning to build it for every possible platform using Xamarin Oh, and about your last paragraph. Even though client and server are in the same VS solution I imaged this as two onions with the same core. Commented Sep 22, 2015 at 15:12
  • From the little that I know about Xamarin, I would imagine that the whole point behind it is that you write all your client code once, and it will take care of creating one executable for each platform out there. So, I would think that you would still only have one client project. If Xamarin needs some kind of project per platform, the general idea still applies: all the common code would still be in a separate class library project.
    – Mike Nakis
    Commented Sep 22, 2015 at 15:59
  • In any case, if you found this answer helpful, do not forget to upvote, and once it seems like there will be no more answers, do not forget to "accept" the best. (If it was helpful enough.)
    – Mike Nakis
    Commented Sep 22, 2015 at 16:00
  • Thanks, unfortunately because of my little reputation I can't upvote yet. As soon as I have no more doubts I will accept an answer Commented Sep 22, 2015 at 16:55
  • where do you suggest to put my ILogger interface? In most examples it's placed in Infrastructure.Logging. In my case, I could use it on the server and in clients. Should I put it in Core ? Commented Sep 22, 2015 at 18:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.