Giter Site home page Giter Site logo

tvmaze-webapp's Introduction

TvMaze Webapp

This project was generated using Nx.

Nx logo

Demo

https://tvmaze-webapp.vercel.app/

Audit

https://tvmaze-webapp.vercel.app/audit.html

Install

Clone or download the repository

Go to project directory and run npm install to install dependencies

Development server

Run npx nx serve tvmaze-webapp for a dev server. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.

Build

Run npx nx build tvmaze-webapp to build the project. The build artifacts will be stored in the dist/ directory. Use the --prod flag for a production build.

Running unit tests

Run npx nx test tvmaze-webapp to execute the unit tests via Jest.

Running end-to-end tests

Run npx nx run tvmaze-webapp-e2e:e2e to execute the end-to-end tests via Cypress in headless mode

Run npx nx run tvmaze-webapp-e2e:e2e --watch to open Cypress UI and run tests in interactive mode

Note: run e2e tests without using the development server to avoid port conflicts

Running the linter

Run npx nx run tvmaze-webapp:lint to run the linter and to make static code analysis.

Understand the monorepo workspace

This monorepo contains two projects:

  • An app called tvmaze-webapp
  • A library used by the app called react-query-crud

Run npx nx dep-graph to see a diagram of the dependencies of the project.

Tech Stack

  • NextJS
  • TypeScript
  • Formatting and Static Code Analysis:
    • Prettier
    • ESLint
  • Material UI component library
  • Testing
    • Unit Testing: Jest and React Testing Library
    • E2E Testing: Cypress

Architecture

  • Use of a Data Abstraction Layer (DAL)
  • Decoupling of frontend from backend: the purpose is to use a common interface with different implementations for real data, mock data or even Graphql. So changing the way of getting data should not affect front-end code
  • The app uses some OOP principles and patterns
    • Domain entities are models like ITvShow, for example
    • Use of Repository Pattern
    • Use of Singleton Pattern to avoid creating new instances of repositories each re-render
    • Use of Master/Detail Pattern
  • Abstraction layer functionality is grouped in a library I created ad hoc called react-query-crud (based in React Query). In this case it only reads data but usually DAL executes CRUD operations
  • Asynchronous State is managed using React Query library:
    • It provides a cache system to manage server state (asynchronous requests):
    • It optimizes and caches requests: requests made against TvMaze API endpoints with same parameters are loaded from browser cache avoiding new requests
    • It keeps UI data updated making requests automatically when browser window recover focus
    • Failure protection: If a request fails, React Query will try three times more before throwing an error
  • Synchronous State is managed using Redux Toolkit
    • Redux is used to pass the TvShow object chosen by the user from the search results view to the details page
  • There is an endpoint defined as Nextjs Servless Function
    • /api/mock-tvshows It is used for testing purposes and returns mock data from a JSON file

tvmaze-webapp's People

Contributors

yagolopez avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.