I am a .net server side developer wish to make web application with the following logic:
User registeration (CRUD)
Activity registeration (CRUD): What, Where, When
User can create activitiy item, for example:
Soccer game, rose stadium, Portland, Oregon, 10/12/2016, 20:00.
CRUD for User/Activity can be implemented via rest API and save all the json to noSQL.
My question is, when designing apps (Client can be Web/Phone app/more), what happens when I want to add additional logic ?
When the user adds activity, I want to do the following:
1. Create a list of users that might be intereseted in that activity
2. Send them suggestion on that activity.

So I assume I need a SuggestionService component, Where do i combine it ?

From what I know the flow is usually like this (RestAPI):

ActivityController.AddNewActivity(data) -> Take json and build class  
ActivityService.AddNewActivity(data) -> Validate class data   
ActivityRepository.AddNewActivity(data) -> add data to mongoDB/Redis

Where the new logic should be ? ActivityService.AddNewActivity implementation should be (pseudo code):

public void ActivityService.AddNewActivity(data)  
if (!data.IsValid()) throw new Exception(..);  
var relUsers = SuggestionService.GetRelevantUsersForActivity(data.Id);
UserService.SendActivityToUsers(data.Id, relUsers);  

Or should I just do ActivityRepository.AddNewActivity(data);
And to have a state machine status on the Activity object, 1=created, 2=suggested, 3=inprogress, 4=completed
And then to make a jobs/logic service that poll activities from mongoDB, and according to their state do different behaviors.
For example every 1 minute it will check, if new activity was made, get relevant users and send them suggestions.

The jobs/logic service is not related by any mean to the CRUD operations, it only manipulates data on mongo and users the REST API to do operations (get relevant users, send activity to users) etc, It can be written in C#, and the CRUD API in java.

I am not certain about architecture of complex apps, What I try to do is seperate the logic of the jobs from the logic of the regular CRUD REST API. Am i doing it right ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.