I am giving here complete details of my Linked in post related to using co pilot in generating code and making change quickly.
Ref:
- User requests / User actions like "like content" "commentcontent" will be queued and processed.
- The path of processing will be different from the regular API request/ response used for application.
- Objective is to achieve scalable processing architecture and also possible to prioritise processing user requests and enabling realtime updates to clients .
- Generating 90% of the code using co pilot and using other tools in design and development.
Use case:
- Azure portal
- Objective: create resource for service bus. app services will host front end and back and and fucntion app to process messages on service bus.
- Create service bus in azure and queue.
- Create function app which has trigger to ready service bus.
- signal r uses websockets, make sure server api configuration websockets are enabled.
- Web app and Api already deployed to azure as app services.\
- UI changes:
Objective: UI will display likes for content and also will show real time updates from other users. Here image on talash.azurewebsites.com is one examples above infrastructure common to other apps using Talash platform.
Objective: It is BFF layer which can consume all calls from front end and updating user actions like likes is an mutation operation. which basically writes back to service bus where other services can pick up data and process.
Loosly coupled system design basically to address queueing and able to process request at different priorities and also can handle high input requests without increasing hardware proportionally with number of user requests. It is a common infrastructure for the apps using Talash back end services.so integration to the system will be more generic dont tie up with any of the apps .
- Add mutation UpdaeUserAction in Bff api code.
- Data on service bus will have application id , so the like could be for any data from other clients like talash video app or talash pdf drive. (http://talashlogs.z26.web.core.windows.net/) so the infrastructure is to process for all above app which are build on Talash api.
- This feature can work on any web apps which are using BFF.
- BFF code write to the service bus.
- Here Strategy pattern used for prioritizing processing of queue content and also some additional processing required for analytics and sales data.
- Function app
- Function app with trigger to read data from service bus and write to MongoDB.
- Api with signal R Hub.
Objective : To enable real time updates to all the users browsing Conent signal R used. The system can be further improved with azure cache using Radis as in-memory db instead of directly reading and writing to DB. This layer will be further improved with a better cache design.
- Changes to like count will be send back to client using signal R.
- so all web apps which are Browsing this content will show csame like count. still query is cached at graphql server level so any new web client will get data from cached query not from mongo db. Even though the images served same with in the given cache expiry time, still the like count will be shown real time.
- Only small mismatch will be if web app opened after like action with the existing query count. That can be rectified by cache invalidations. But otherwise real time updates achieved at the same time mongo db not hit with in the cache expiry time. This solution can be further tweaked.
- Add show error details in verbose while creating signal R service on server which helps to understand if any issue connecting to Hub.
- Design of cache: above data integrity issue can be addressed with azure cache / radis where writing and reading happens from cache.
- Cache design:
- Combination of Apollo graphql client cache, signal R and radis should make the following use case as most efficient design.
Objective: User update like should be notified to other users. in real time.User should be able to refresh and get same count and also other user connected after like action should also get same count.
- Hitting mongo db for each fetch is not at all efficient.
- real time update works perfectly with signal R. apollo client has option to fetch option as no cache. which means messages are processed real time and other users connected will be getting latest data.
- Next level of optimization is always hit Radis connected to back end.
- Right now I am measuring the scalability of above permutations and combinations.
- TODO:list
- Improving function app functionality to extend any user action processing and saving to DB. Either user action can be saved to DB or can be send to other api for more business logic.
- Cache management:
- As mentioned above cache should ideally have radis so that all clients can get updated data.
- or mutation should invalidate cache. mutation invalidation quite complex compared to using radis.
- Analytics and logging. Build basic analytic db out of individual user action to display in reports. It could be just building trends data instead of querying and processing every time when data needed. ex last 1 days likes or aggregating day wise data.
- Updating UI with Notifications.
- Testing:
Objective: apps using above feature should show real time notifications .
- Above website will have image data which is two way binding to home page.
- New updated likes will be shown to all client which are browsing home page.
- All unit tests are generated using copilot.
- Debugging and trouble shooting
AI Search & Prompts:
Entities. DB and Analytics
Build and deploy Use cases:
please write the terraform config for a lambda function
please allow the lambda function to access sns topics and sqs queues
write me a list of variables to use