In this post i want to introduce SmileTable architecture, how It looks like how it works for now and how it going to work in future.
I’ve got serveral problems with design good division for SmileTable. I like doing things right. Is it good? I think yes but in other side it can be very tired. Why ?
It’s hard to create good architecture for person who learn how codding from two years. I have readed a lot’s of tutorial I have watched a lot of videos how to create good, well thinked aplications and It’s not easy to say which solution is the best and which solution will fit to actual project. I have still many question, but I believe that there is only one way to learn that, to fill how to do things right. That way is coding coding coding!
SmileTable is my first example of application based on service oriented architecture.
Firstly I decided to create some main folders.
Then I created solutions for that folderers what is ilustrated by picture
In Business folder I’ve three solutions: Contracts, Entities and Services
In ST.Business.Contracts I put contracts, so we’ve Data Contracts – class which are returned from WCF to client application and Service Contracts.
ST.Business.Entities – I don’t know if will be better to name It DTO because I use that classes like DTO for my Entity Framework, but for now It stay in this way. So basically in Entities I got classes which are mapped by EF to Tables (I am using code first approach).
In ST.Business.Services I put WCF Services. Also I keep connection string there in App.config. That is it.
In Client folder I have two solutions. ST.Client.Proxies which allow client application to access services methods.
What is important Proxy class requires configuration (endpoints) which are defined by me in ST.SmileTableClient Web.Config
I also have my Presentation Layer which is ASP.NET MVC 5 solution. There is no need to introduce I think 🙂
In Hosting folder I have just one Console Application Solution with Host class which is hosting my WCF service. That allow to connect to that services. In App.config I put configurations for WCF services.
Folder Resource Access is just place where I get access to data from database.
In ST.Data solution I have temporary repositories. Why temporary ? I say more about that in summary.
I also have Migrations – folder created by EF during adding migrations from package manager console. Most important I have EFDataContext class where I connect my entities with EF using DbSet, I also specified behavior my database by overide OnModelCreating method
In ST.DataContracts I just keep contract for my repositories.
That is all I have created to now. It is not my best It’s very simple architecture. I am not happy about that and for sure I will use Dependency Injection and I swap my repositories to one generic repository connected with DI. Why I don’t do It now ? That is because I have never created Service Oriented Archiecture and I think that my code will be a little different that in Object Oriented Architecture. For now I don’t have time to handle that but if SmileTable will have some UI and of course will work I will refractore that!