Giter Club home page Giter Club logo

metrics-exercise's Introduction

Metrics-Exercise

This is a Proof of Concept -> Post and display metrics from frontend to a backend

The structure is a monorepo split in frontend and backend (an API).

Backend is built with FastAPI (Python). It has these features:

  • Gets metrics.
  • Post metrics to backend.
  • Get averages of metrics by day, hour, minute with a range timestamp.

The API has an OpenAPI docs at the endpoins /docs and /redoc.

Frontend is built with React (TypeScript) + Chakra UI (styles) + React-Vis (charts). Ith has these features:

  • Gets metrics.
  • Post metrics.
  • Get averages of metrics by day, hour, minute with a range timestamp.
  • Display averages in a Time-Series chart.
  • Responsive UI.

The project can be run in two ways:

  1. Installing and running each service separately
  2. docker-compose

Each service separately

This option need some steps. The two services need to run in the same machine because there is a CORS with backend (it doesn't affect with localhost).

Backend

Python 3.9 is needed and I'll recommend you to use virtual environment. There is a requirements.txt file if you install deps with PIP. If you use poetry, there is a pyproject.toml.

Before run the project create a .env file. There is a dev.env as a example, if you prefer rename this file to .env.

To run use python main.py and you get API running at the port you set in .env file

Frontend

The front was developed with NODE 16. Is the typical project made with create-react-app and the TypeScript template.

Before run please modify at src/context/MetricsProvider.tsx. You need to set BACKEND const to the correct backend url. If you use dev.env with backend, uncomment the first BACKEND const and comment the second.

Then you can start with npm start.

Docker-Compose

If you choose this option, run docker-compose up and you get:

  • Frontend at 3333 port
  • Backend at 8888 port

With docker-compose the project doesn't work well because an unresolved (by me) issue with CORS.

metrics-exercise's People

Contributors

crisconru avatar

Stargazers

Victor Suarez avatar

Watchers

 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.