I am working on a ticketing system based on Laravel and VueJS. I would have a foundation question, where I would like to get your opinion on.
Scenario
Via my API I can get all tickets in a database table to process them dynamically in my frontent. Every ticket can have a different status. The user will get a summary in numbers displayed on a dashboard (20 tickets open, 40 closed etc.)
Question
I would be interested in the setup of the business logic. Where would I do the calculation of the summaries? Would I create an API Request that will return all this information, which then is calcuated on server side? Or is the way to do it, getting all the data from the table and working it out on the front end side (filters etc.)
What is a best practice here?
You can return some properties in your calls where these calculations can happen. Like Instagram or Facebook that have properties with pagination info, number of medias, etc...
Related
I'm working on a project using React 18 with Firebase Authentication and Realtime Database.
The project is a real-time chat between two users, I wan't this project to be very secure and protect messages/conversations. I have the following "cases" or "rules" to specify this chat functions:
User with profile Volunteer can chat with maximum 10 users with the simple-user profile.
Volunteer can see previous messages or the "history" with a registered simple-user but simple-user can't see previous messages. I need to protect chats for simple-user.
All the active "chats" between one volunteer and maximum 10 simple-users have to be seen just for the Volunteer profile. The simple-user just send and receive messages with a random Volunteer.
I search on the Internet which database fit better with my project model and Realtime Database looks like the better option. But now I would like to have your opinions about how can I handle the database to get the data and connection that I need according to the previous rules I wrote.
I know Firebase is a No-SQL database, but I create this diagram to know if the data structure for this chat could work.
If I store different information like the image above, could I get the information I need from each chat?
Turn is the working shift time that "volunteer" is working on the chat platform.
Session is the information of the turn of that volunteer and simple-users that they talk.
Chat is the "conversation" or the instance to generate messages between two different users.
My questions are:
Do I need a backend project such as nodejs? This backend would be for store the endpoints to firestore and apply some logic rules for queries this way I can have a React project without logic
If I structure my database like the image above, can I be able to get the information to achieve the "rules" that I need?
Do you have any suggestion to build a chat like this? In the future this project could be huge with a lot of data store and multiple users chatting with each other. Right now I have just the UI code and firebase connection. No other code yet.
Thanks for your contributions!
We are a using a micro-service based pattern for our project where we have Users and their Orders. Users personal information (name, email, mobile) is stored in User table in relational database while we are storing Orders data of users in Orders collection in NoSql database. We want to develop an API to get a paginated list of all the orders placed with order details along with finer details of user associated like - user name, mobile, email along with each order. We are storing userId in Orders collection.
The problem is how do we get User details for each order in this list since both the resources are in different databases. We also thought of storing user name, email and mobile in Orders collection only but what if a user updates their profile, the Orders collection will have stale user data.
What is the best approach to address this issue?
You can use API gateway pattern, UI will call to API gateway endpoint and the Endpoint will call the both the API/services to get the result and aggregate it then returns aggregated response to the UI (caller)
https://microservices.io/patterns/apigateway.html
Well it mostly depends on scalability needs in terms of data size and number of requests. You may go with the API gateway if you don't have too much data and you don't get many requests to that service.
Otherwise if you really need something scalable then you should implement your own thought with an event based communication.
I already provided an answer for a similar situation you can take a look
https://stackoverflow.com/a/63957775/3719412
You have two services Orders and Users. You are requesting Orders service to get all Orders. It will return a response data which will contains ID of Users (each Order contains ID of User). Then, you will make a request to a Users service to get an information regarding User by ID which you got before. And finally, you can aggregate those results (if it is needed).
As guys mention, good solution will be to implement API Gateway here. As a client, you will send a request to a single port with endpoint (to a Gateway) and Gateway should create logic which I have described before.
Okay so I’m need guidance on where to start.
What I want to do is upon clicking a button in my web app which will be labelled “search” the web app will connect to my realism database and search the data base for the “search criteria” and the once found all matching cases it will create div blocks with the information inside it, in a list view and assign the ID of the div to the UID it gets back from the database.
database:
Users
--> Country
---->State
----->City
------>Post/ZipCode
------->UID
--------> Users informantion
Welcome to StackOverflow!
A great place to get started is the Firebase Realtime Database doocumentation or searching for Firecasts on YouTube (linked below).
As requested, here are some questions to ask yourself to get started and help scope out and define your new Firebase project.
What language are you going to use?
Are you planning on using any frameworks/libraries? e.g. For Javascript, these would include things like jQuery, Polymer, and React
What information are you storing in your database? e.g. user profiles, private user data/settings, public indexes, username lists, etc.
How is your database structured?
What data is being searched? The entire database? Values in a certain location?
What data needs to be displayed in your view?
Is the data accessible for just the current user or is it a public database that anyone can use?
What search criteria will be used? Is it just one filter at a time or many?
The answers to these questions aren't set in stone, but are to help you start thinking about the future of your project. They can be changed at any time as this isn't SQL where everything has to have its own schema.
If you intend on using "advanced searches" where you'll filter by multiple parameters at the same time, consider using Cloud Firestore instead.
I recommend looking at some Firecasts to help guide you through these questions. Here are some links to them:
Firebase YouTube Channel
Video: Getting Started with the Firebase Realtime Database on the Web
Playlist: Firebase on the Web
I'm creating a SPA application with AngularJS at the client side and ASP.NET Web API as backend. My database is SQL Server 2012. There will be users which have a favourite sports team and a simple icon in the UI displaying the number of new articles/news/comments added or whatever connected to their favourite teams.
What I'd like to achieve is the following: Whenever a record about their team is inserted (record with TeamID column value for example equal to the user's favourite team ID), that notifications count icon should be updated immediately (just like Facebook's notifications - it's updated when a friend has posted on your wall or has tagged you and so on). How can I best achieve this?
What I'm thinking of for now is just setting an interval function in AngularJS to check every 30 seconds, let's say, if there are new records in the database making a request to a Web API controller. Of course this suggests a lot of checking for when the user is logging out - when was the last check, what will be the date to check against next time he/she logs in and so on.
You can use signalR for this. It's a framework for real time communication. Check out this to get if you want to get started. It can easily be used together with angularJS.
What you are looking for is push
Sadly i never used it so i don't know much about it, but i think you should use technologies like pusher
I am building a web app that will use an auto-complete/suggestions for the end user as they type their information in. This will be specifically for entering Country, Province, City information.
Do a wild card search on the database on each keystroke:
SELECT CityName
FROM City
WHERE CityName LIKE '%#CityName%'
Return a list of all Cities to a given Province to the client and have the client do the matching:
SELECT CityName
FROM City
WHERE ProvinceID = #ProvinceID
These would be returned to the client as a JSON string via an ajax call to a web service. My thoughts are that javascript would be able to handle the list of 100+ entries via JSON faster than the database would be able to do a wildcard search, but I'd like the communities input.
In the past, I have used both techniques. If you are talking about 100 or so entries, and assuming each entry is very small, it will likely be faster to do the autocomplete filter on the client side. That will provide you with better response time (although probably negligible) and will reduce the load on your server.
Google actually does a live search while the user is typing, and it seems to be pretty responsive from the user's point of view. This is an example where the query must be executed server-side because the dataset is far too large to transfer to the client.
One thing you might do is wait until the user types two keystrokes before fetching the list from the server, thus narrowing down the results initially. Of course, that adds complexity - you would then need to refresh the list if the user changes either of the first two keystrokes.
We have implemented same functionality using ajax auto complete control we wait the user type three keystroke before fetching the list from server we have not done any coding at client side we just assigned web services method which return list to ajax control and its start working
In the end user's interest, it is always better to handle this client-side.
The Telerik Autocomplete controller allows for both ways.
Of course under load client-side autocomplete is likely to make the application crawl.