Coder Social home page Coder Social logo

pedromspeixoto / posts-demo Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 2.47 MB

This is a demo repo with a Golang API and a React FE to showcase some functionalities around DevOps frameworks and tools

Makefile 3.89% Go 59.02% Dockerfile 2.12% Shell 1.43% JavaScript 13.05% HTML 2.88% SCSS 17.61%

posts-demo's Introduction

posts-demo

Table of Contents

Overview

This is a demo repo with a Golang API and a React FE to showcase some functionalities around DevOps frameworks and tools.

The main purpose of this demo aims to demonstrate on how Sentry can be used to track errors in both the API and the FE.

To test it locally please first create a free tier account in Sentry and then replace the <SENTRY_DSN> placeholder in the .env files with the DSN provided by Sentry for both Golang and React projects.

This demo uses the following tools:

  • Sentry for error tracking
  • Docker and Docker Compose for containerization
  • Make for automation

The Golang backend has the following features:

  • CRUD operations for posts [GET, POST, PUT, DELETE]
  • MySQL as a database engine
  • Gorm for ORM
  • Goose for database migrations
  • Zap for logging
  • UberFx for configuration
  • Go modules for dependency management
  • Chi for routing
  • Swagger for API documentation

The React FE has the following features:

  • Axios for API calls
  • React Router for routing
  • React Bootstrap for UI components
  • NGINX as a web server
  • Docker multi-stage build for production

Requirements

Installation

  1. Clone the repo:
git clone https://github.com/pedromspeixoto/posts-demo.git
  1. Create a default.env file for the API:
cd api
touch default.env

Example of the local API .env file:

ENV="development"
APP_PORT="8080"
ALLOWED_HOSTS=*

LOGGER_TYPE="zap"
LOGGER_LEVEL="1"

MYSQL_HOST="0.0.0.0"
MYSQL_PORT="3306"
MYSQL_USER="username"
MYSQL_PASSWORD="password"
MYSQL_DB_NAME="dev_posts"

SENTRY_ENABLED=true
SENTRY_DSN=<SENTRY_DSN>
  1. Create a .env file for the FE:
cd fe
touch .env

Example of the local FE .env file:

NODE_ENV=production
REACT_APP_API_URL=http://localhost:8080
REACT_APP_SENTRY_DSN=<SENTRY_DSN>
  1. Start both API and FE using the make target:
make docker-compose-up-local

Usage

  • Access the FE at http://localhost, perform any requests and see the performance and errors in Sentry:

Posts React FE

Posts Swagger

  • If you have properly configured sentry, you will be able to see the errors and performance logs in Sentry:

Sentry Errors

Sentry Performance

  • Also, this allows us to have a full picture of all requests performed in the application with E2E tracing:

Sentry Tracing

Testing

TBD - Unit, Integration, API and E2E tests will be added in a future release

posts-demo's People

Contributors

pmspeixoto avatar pedromspeixoto 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.