wfgilman

wfgilman

I’ve got a design question for you guys. I’m building a service in Elixir which requires inputs from users (a web interface) and also sends and receives JSON requests from third-party APIs (webhooks). We want this service available to users through a website and mobile app. Phoenix seems to be the natural choice for the former with it’s browser and api pipelines. However, when interfacing with a mobile app, it seems like creating a RESTful API using Plug is most suitable. My question: is it necessary to build a Phoenix web framework and Plug API separately with redundant functionality, or just build a RESTful API in Plug, or is there a better way to accomplish both?

Thanks!

Showing Posts 1 to 9

OvermindDL1

OvermindDL1

I personally have been doing something like this (unsure how ‘standard’ it is, but these forums do it and it is natively supported in Phoenix):

https://mysite/ -> Returns the index html
https://mysite/?_format=json -> Returns the data of the index page in json format

And so forth (although more data like ‘v’ for version arguments are accepted or latest if unspecified).
I’ve actually been looking at that GraphQL(sp?) or whatever it was lately, it looks interesting for when the client wants only specific things…

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

The HTTP oriented parts of Phoenix are all 100% just plugs themselves. Phoenix works very well for JSOn apis, and gives you a number of conveniences you’re gonna miss by just using Plug.

wfgilman

wfgilman OP

Gotcha. I was thinking along those lines. Is there anything out there on making Elixir applications with a mobile app front end using iOS or Android? Would these mobile apps interface with the Elixir application using a standard HTTP API? I’m wondering how Phoenix and Plug might fit in here.

OvermindDL1

OvermindDL1

Standard rest api’s are fine. Could use websockets if you need the speed (though what a hit to battery if constantly on). Depends on your uses? For example:

Is it just a website front-end? Just make a mobile website then.
Is it extra functionality? If Notifications then use a notification service for the given platform (web calls are battery unfriendly for those). If just for a better interface but is otherwise sporadically used then REST or websockets depending on need.
Etc…

Either way, phoenix can host it all.

wfgilman

wfgilman OP

The interest in a mobile app over a mobile website is to improve the user experience along with sending push notifications. I’m a little unclear on what the endpoint of my application should be if I want to have a mobile app be the user interface (with the aforementioned functionality). I’m also a bit of a newb :wink:

OvermindDL1

OvermindDL1

Well a pure json ‘API’ path would be the more usual (code should not be duplicated in any case between it and controllers, if it is then you need to move more code into lib and call those from the controllers). GraphQL would allow the mobile app to only request what it actually needs at that second so might make a better endpoint?

wfgilman

wfgilman OP

Thanks for the info! I’ll look into this more.

swennemans

swennemans

I’m working on one, and using a plain old ‘boring’ HTTP API :wink: As @benwilson512 mentions, Phoenix offers a number of handy conveniences you can utilize.

wfgilman

wfgilman OP

Nice, as an interface for a mobile app?

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
ryanwinchester
apply_graft/2 doesn’t rewrite an add_many sub-workflow’s deps on an add step. Grafted jobs cancel with “upstream job was deleted” Version...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews