3

Is it possible to build a realtime app using AngularJs with a mysql database?

I've been reading thousands of tutorials, but they are all focused on express, nodejs, etc.. didn't found any documentation on wheter it's possible or not. I tried to take a look at the socket.io docs, but still didn't found anything relevant to this question.

I didn't tried anything yet because of this. I use a webApp based on AngularJs on a apache server (local).

  • Where should i start to be able to build a real time app using these tools i have?
  • Do i really need to use a node/express server?
  • What are the main consideration i need to do before taking this step?
  • Is there any documentation i should read?

I need to do this real time because it involves product orders, call center, ticket system, etc.. So everytime there is a new ticket is opened/changed, new order arrives, etc.. I need to make the user aware of this, without the need to refresh the page.

Or if someone could give me a further explanation of this concept and how to get started, it will be great.

0

    3 Answers 3

    1

    You can run angular on top of any backend, although most examples push towards REST. If you want your app to feel like a real time application, using WebSockets is a likely improvement.

    WebSockets play nice with Angular, look at https://github.com/wilk/ng-websocket for example. A back-end in Node will work, but many other backend techs will do equally well.

    Here is a decent tutorial using MySQL, NodeJS, and Angular: https://codeforgeek.com/2015/03/real-time-app-socket-io/

    I recommend that you keep using a webserver like Apache (my personal preference is Nginx). You can proxy API and socket requests to Node, and serve static resources for the app from a folder.

    Check out https://httpd.apache.org/docs/2.4/mod/mod_proxy_wstunnel.html if you stay with Apache. Check out http://nginx.org/en/docs/http/websocket.html is you go for nginx.

    Without a webserver, you'll have to either:

    • serve your static resources with Node (polluting your server project with client code), or
    • work with different ports, risking the app becomes unusable in client environments, or
    • work with different domains, giving you a CORS head-ache.
    2
    • Yes, I'm kind of pending to NodeJs. But will it run normally when i send it to an online host? Or the online service need to have a proper nodejs server as well?CommentedNov 9, 2015 at 22:46
    • you should run it on virtual iron, like Digital Ocean. many hosting parties support PHP or something, but that's not a good idea to get stuck on.
      – iwein
      CommentedNov 18, 2015 at 20:41
    0

    Although I don't have much experience with Node, MySQL with Node.js should help you out a bit.

    You'll want to move away from Apache if you want to do websocket stuff with Socket.io

    4
    • But is this a limitation of the whole process? I mean, the only way to achieve this result is to run a server like node or express? If so, do you have any recomendation any reading about node? It seems to be the most popular, also i already have, since I'm using npm, etc..CommentedNov 9, 2015 at 19:43
    • No, there are websocket (server -> client push) implementations for various technologies, but Socket.io on NodeJS seems to be the most preferred. I personally have been using the MS ASP.NET technologies and have been using SignalR, so I can't recommend much on further reading for you.CommentedNov 9, 2015 at 19:46
    • But do you know any of these services to use with Apache? If don't, I think I'll move with Node, at least i've already found a lot of tutorials explaning how to use node + angular + socket. But the question is: When it goes to an online server, how to proceed?CommentedNov 9, 2015 at 19:51
    • You should definitely put the node server behind some kind of web server. My personal preference is nginx, but Apache should work fine too.
      – iwein
      CommentedDec 9, 2015 at 7:37
    0

    Yes, it is possible to create a software with AngularJS in the front end and any other server side language that speaks to MySQL. Few months back I worked on a software with Java Spring Framework in the backend with MySQL database and AngularJS with bootstrap in the front end. You could start by following the MVC pattern, where your views can be served as AngularJS and your Controller can be in any server side code, with MySQL database.

    2
    • The whole app is working with pure AngularJs frontend and apache+mysql backend. I understood this concept now, there is nothing to do with MySql, but with the server instead. The only problem now is to create the better guide for my situation. I think I'll be moving from apache to node. Any recomendation?CommentedNov 9, 2015 at 19:48
    • @CelsomTrindade exactly, AngularJS has no dependency on the backend, whetever you are using. LAMP stack vs MEAN stack, for example, has aways been a hot topic for debate. Personally I prefer Apache, rather than a Node.js server, But that is just my choice. You could google for better choice but i also like this post (rclayton.silvrback.com/means-great-but-then-you-grow-up). But there is always the concept of what is best for your needs. That should be chosen.CommentedNov 9, 2015 at 19:59

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.