DOWGO / dowgo-one

dApp to swap Dowgo Tokens
https://dowgo-dapp.vercel.app
GNU General Public License v3.0
0 stars 1 forks source link

Discuss Tech Stack for Beta #24

Open antoine-dowgo opened 1 year ago

antoine-dowgo commented 1 year ago

FE/BE Sync

Use GraphQL:

GraphQL is a query language for APIs and a runtime for fulfilling those queries with your existing data. GraphQL provides a complete and understandable description of the data in your API, gives clients the power to ask for exactly what they need and nothing more, makes it easier to evolve APIs over time, and enables powerful developer tools.

Back End: https://github.com/boazdejong/serverless-graphql-api Front End: https://github.com/apollographql/apollo-client

React state management

React context + useReduce React saga, thunk

Design system

Ant Design

antoine-dowgo commented 1 year ago

After meeting with @Tris92 we decided to postpone GraphQL to later and that it might be worth it to implement Saga for state manegement

antoine-dowgo commented 1 year ago

Actually a dev friend argued to me that the sooner we migrate to GraphQL, the easiest the migration... So I'm considering implementing GraphQL from the start... In the mean time I'll start with state management on the FE

antoine-dowgo commented 1 year ago

I tried asking ChatGPT for advice ^^

To make a React based webapp and to handle local state, do you recommend I use React context and useReducer hook or just use Redux Saga?

Both React context and useReducer hook, as well as Redux Saga, can be used to handle local state in a React-based web app, and the choice ultimately depends on the specific needs of your application and personal preferences.

React context and useReducer hook are built into React and provide a way to manage state in a more lightweight and straightforward manner. The context API allows you to pass data through the component tree without having to manually pass props down through every level. useReducer is a hook that allows you to manage state and provides a predictable way to update the state with reducers.

Redux Saga is a popular library for managing application state that allows for more advanced use cases such as asynchronous data fetching, handling complex side effects, and handling complex state transitions. Redux Saga uses a pattern called "generator functions" to handle these complex scenarios.

If you have a relatively simple application and prefer to avoid the added complexity of using an external library, React context and useReducer hook can be a good choice. However, if you anticipate needing more advanced state management functionality, such as managing complex side effects or handling complex state transitions, Redux Saga can be a powerful tool to accomplish these tasks.

Ultimately, the choice between these options depends on the specific requirements and goals of your application, so it's important to consider your needs and make an informed decision based on your specific circumstances.

=> Since the state is not that complex and implementing context and reducer is something I understand well, I think it should be enough for now

When is it worth it to implement GraphQL in a WebApp using an API?

GraphQL is a query language for APIs that allows clients to request only the data they need, which can lead to improved performance and reduced over-fetching and under-fetching of data. It can be worth implementing GraphQL in a web app using an API in a variety of situations, including:

When you have a large, complex API with many endpoints: GraphQL can help simplify your API by allowing you to consolidate many endpoints into a single endpoint that can be queried for the specific data that is needed.

When you have a diverse set of clients that need different data: GraphQL allows clients to request only the data they need, which can be particularly helpful when you have diverse clients that require different data sets. This can help reduce the amount of data that is transferred over the network, leading to faster performance and reduced bandwidth usage.

When you have a need for real-time data: GraphQL subscriptions allow clients to subscribe to data and receive real-time updates as the data changes. This can be particularly useful for real-time applications such as chat applications, stock trading platforms, or gaming applications.

When you want to enable client-driven development: With GraphQL, clients can drive the development of your API by requesting only the data they need and providing feedback on the structure of the data. This can lead to a more iterative development process that is more closely aligned with the needs of the clients.

In summary, implementing GraphQL in a web app using an API can be worth it when you have a complex API, diverse clients, a need for real-time data, or when you want to enable client-driven development.

I don't think our app is dynamic enough that it requires real time updates like a trading app. Plus for the Beta we don't have that many API endpoints and they work so I'm not scared of the cost of migrating.

antoine-dowgo commented 1 year ago

Here is another tool when/if we want to implement graphQL with AWS: https://aws.amazon.com/fr/appsync/