From 9c05f4333bf0593b945a0d0b9ba61c52a53f7d47 Mon Sep 17 00:00:00 2001 From: Eugene Fox Date: Thu, 22 Feb 2024 18:34:31 +0000 Subject: [PATCH] - Moved frontend to a separate folder - Updated README.md --- .devcontainer/devcontainer.json | 22 -------- .github/dependabot.yml | 12 ---- README.md | 55 ++++++++++++++++--- .dockerignore => frontend/.dockerignore | 0 .eslintrc.cjs => frontend/.eslintrc.cjs | 0 .gitignore => frontend/.gitignore | 0 Dockerfile => frontend/Dockerfile | 0 index.html => frontend/index.html | 0 package.json => frontend/package.json | 0 {public => frontend/public}/vite.svg | 0 {src => frontend/src}/App.styles.ts | 0 {src => frontend/src}/App.tsx | 0 .../src}/Components/CartesianGrid.tsx | 0 .../src}/Components/ChartSkeleton.styles.ts | 0 .../src}/Components/ChartSkeleton.tsx | 0 .../src}/Components/TrackChart.tsx | 0 .../src}/Components/TrackLinePlot.tsx | 0 .../src}/Components/TrackSurfacePlot.tsx | 0 {src => frontend/src}/Data/IChartPoint.ts | 0 {src => frontend/src}/Data/IPoint.ts | 0 {src => frontend/src}/Data/ITrack.ts | 0 {src => frontend/src}/Data/LoadMockData.ts | 0 {src => frontend/src}/Data/MaxSpeed.ts | 0 {src => frontend/src}/Data/Surface.ts | 0 .../src}/Data/TrackChartDataProps.ts | 0 {src => frontend/src}/Utils/makeStyles.ts | 0 {src => frontend/src}/main.tsx | 0 {src => frontend/src}/vite-env.d.ts | 0 tsconfig.json => frontend/tsconfig.json | 0 .../tsconfig.node.json | 0 vite.config.ts => frontend/vite.config.ts | 0 yarn.lock => frontend/yarn.lock | 0 32 files changed, 46 insertions(+), 43 deletions(-) delete mode 100644 .devcontainer/devcontainer.json delete mode 100644 .github/dependabot.yml rename .dockerignore => frontend/.dockerignore (100%) rename .eslintrc.cjs => frontend/.eslintrc.cjs (100%) rename .gitignore => frontend/.gitignore (100%) rename Dockerfile => frontend/Dockerfile (100%) rename index.html => frontend/index.html (100%) rename package.json => frontend/package.json (100%) rename {public => frontend/public}/vite.svg (100%) rename {src => frontend/src}/App.styles.ts (100%) rename {src => frontend/src}/App.tsx (100%) rename {src => frontend/src}/Components/CartesianGrid.tsx (100%) rename {src => frontend/src}/Components/ChartSkeleton.styles.ts (100%) rename {src => frontend/src}/Components/ChartSkeleton.tsx (100%) rename {src => frontend/src}/Components/TrackChart.tsx (100%) rename {src => frontend/src}/Components/TrackLinePlot.tsx (100%) rename {src => frontend/src}/Components/TrackSurfacePlot.tsx (100%) rename {src => frontend/src}/Data/IChartPoint.ts (100%) rename {src => frontend/src}/Data/IPoint.ts (100%) rename {src => frontend/src}/Data/ITrack.ts (100%) rename {src => frontend/src}/Data/LoadMockData.ts (100%) rename {src => frontend/src}/Data/MaxSpeed.ts (100%) rename {src => frontend/src}/Data/Surface.ts (100%) rename {src => frontend/src}/Data/TrackChartDataProps.ts (100%) rename {src => frontend/src}/Utils/makeStyles.ts (100%) rename {src => frontend/src}/main.tsx (100%) rename {src => frontend/src}/vite-env.d.ts (100%) rename tsconfig.json => frontend/tsconfig.json (100%) rename tsconfig.node.json => frontend/tsconfig.node.json (100%) rename vite.config.ts => frontend/vite.config.ts (100%) rename yarn.lock => frontend/yarn.lock (100%) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json deleted file mode 100644 index 85dc438..0000000 --- a/.devcontainer/devcontainer.json +++ /dev/null @@ -1,22 +0,0 @@ -// For format details, see https://aka.ms/devcontainer.json. For config options, see the -// README at: https://github.com/devcontainers/templates/tree/main/src/typescript-node -{ - "name": "Node.js & TypeScript", - // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile - "image": "mcr.microsoft.com/devcontainers/typescript-node:1-20-bullseye", - - // Features to add to the dev container. More info: https://containers.dev/features. - // "features": {}, - - // Use 'forwardPorts' to make a list of ports inside the container available locally. - // "forwardPorts": [], - - // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "yarn install" - - // Configure tool-specific properties. - // "customizations": {}, - - // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. - // "remoteUser": "root" -} diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index f33a02c..0000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,12 +0,0 @@ -# To get started with Dependabot version updates, you'll need to specify which -# package ecosystems to update and where the package manifests are located. -# Please see the documentation for more information: -# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates -# https://containers.dev/guide/dependabot - -version: 2 -updates: - - package-ecosystem: "devcontainers" - directory: "/" - schedule: - interval: weekly diff --git a/README.md b/README.md index 96cda55..f4bb60a 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,51 @@ # MuiCharts Small demo app on .NET/React. Job entry challenge -> **IMPORTANT**: This branch contains the source code for the front-end of the application. The back-end source code is located in the `backend` branch. +## Devcontainers +This repository is equipped with configuration files for Dev Containers feature which allows you to develop this project in a containerized environment. You can use VS Code with Dev Containers extension and Docker or you can use GitHub Codespaces. Read more at [Developing inside a Container](https://code.visualstudio.com/docs/remote/containers). -## Development -```bash -yarn dev -``` +## Backend +Path: `/backend` -## Build -```bash -yarn build -``` +Backend is a simple ASP.NET Core Web API project with EF Core and SQLite. It provides a RESTful API for the frontend to consume and incorportaes DDD principles. + +### Projects +- `MuiCharts.Api` - ASP.NET Core Web API project +- `MuiCharts.Contracts` - Shared Web API contracts that can be extracted into a separate package and shared between the client and the server +- `MuiCharts.Infrastructure` - Infrastructure layer with EF Core and SQLite +- `MuiCharts.Domain` - Domain layer with business logic and models + +### Essential variables +Use these properties as environmental variables or CLI arguments to configure the backend: +#### HTTPS +If you want to use Kestrel as your primary web server (with no reverse proxy), you can use the following properties to configure HTTPS with Let's Encrypt certificate: +- `HTTPS_PORTS=443` - Listen for HTTPS requests on port 443 +- `LettuceEncrypt:AcceptTermsOfService=true` - bypass interactive prompt +- `LettuceEncrypt:DomainNames:0=example.com` - domain name for the certificate (use `:1`, `:2`, `:3`, etc. to add more) +- `LettuceEncrypt:EmailAddress=eugene@xfox111.net` - email address for certificate issuer + +> **Note**: you need to have either a public IP address or a domain name to use Let's Encrypt certificates. Otherwise, use `dotnet dev-certs https` to generate a self-signed certificate. + +#### Data persistence +Configure these options if you want to change default paths for data persistence: +- `ConnectionStrings:DataContext=Data Source=/persistence/data.db` - SQLite DB connection string (default: `/persistence/data.db`) +- `LettuceEncrypt:CertificatesPath=/persistence` - path to store Let's Encrypt certificates (default: `/persistence` for `Production` and `data.db` for `Development`) + +> **IMPORTANT**: default persistence paths are configured to be used in a Docker container, where the user is `root`. `/persistence` is not writtable by a non-root user, so you need either to change the paths if you want to run the app outside of a container without root privileges or run app as `sudo`. + +## Frontend +Path: `/frontend` + +Frontend is a simple React app with Material-UI. It consumes the RESTful API provided by the backend (or uses its emulation) and visualizes the data. + +> 🚧 WIP + +## Docker +Use sample `docker-compose.yml` file to deploy the project on one server using Nginx + +## GitHub Actions +Path: `.github/workflows` + +There are two GitHub Actions workflows: +- `backend.yml` - CI/CD for the backend. Deploys the app to a remote server using Docker and SSH +- `frontend.yml` - CI/CD for the frontend. Deploys the app to GitHub Pages diff --git a/.dockerignore b/frontend/.dockerignore similarity index 100% rename from .dockerignore rename to frontend/.dockerignore diff --git a/.eslintrc.cjs b/frontend/.eslintrc.cjs similarity index 100% rename from .eslintrc.cjs rename to frontend/.eslintrc.cjs diff --git a/.gitignore b/frontend/.gitignore similarity index 100% rename from .gitignore rename to frontend/.gitignore diff --git a/Dockerfile b/frontend/Dockerfile similarity index 100% rename from Dockerfile rename to frontend/Dockerfile diff --git a/index.html b/frontend/index.html similarity index 100% rename from index.html rename to frontend/index.html diff --git a/package.json b/frontend/package.json similarity index 100% rename from package.json rename to frontend/package.json diff --git a/public/vite.svg b/frontend/public/vite.svg similarity index 100% rename from public/vite.svg rename to frontend/public/vite.svg diff --git a/src/App.styles.ts b/frontend/src/App.styles.ts similarity index 100% rename from src/App.styles.ts rename to frontend/src/App.styles.ts diff --git a/src/App.tsx b/frontend/src/App.tsx similarity index 100% rename from src/App.tsx rename to frontend/src/App.tsx diff --git a/src/Components/CartesianGrid.tsx b/frontend/src/Components/CartesianGrid.tsx similarity index 100% rename from src/Components/CartesianGrid.tsx rename to frontend/src/Components/CartesianGrid.tsx diff --git a/src/Components/ChartSkeleton.styles.ts b/frontend/src/Components/ChartSkeleton.styles.ts similarity index 100% rename from src/Components/ChartSkeleton.styles.ts rename to frontend/src/Components/ChartSkeleton.styles.ts diff --git a/src/Components/ChartSkeleton.tsx b/frontend/src/Components/ChartSkeleton.tsx similarity index 100% rename from src/Components/ChartSkeleton.tsx rename to frontend/src/Components/ChartSkeleton.tsx diff --git a/src/Components/TrackChart.tsx b/frontend/src/Components/TrackChart.tsx similarity index 100% rename from src/Components/TrackChart.tsx rename to frontend/src/Components/TrackChart.tsx diff --git a/src/Components/TrackLinePlot.tsx b/frontend/src/Components/TrackLinePlot.tsx similarity index 100% rename from src/Components/TrackLinePlot.tsx rename to frontend/src/Components/TrackLinePlot.tsx diff --git a/src/Components/TrackSurfacePlot.tsx b/frontend/src/Components/TrackSurfacePlot.tsx similarity index 100% rename from src/Components/TrackSurfacePlot.tsx rename to frontend/src/Components/TrackSurfacePlot.tsx diff --git a/src/Data/IChartPoint.ts b/frontend/src/Data/IChartPoint.ts similarity index 100% rename from src/Data/IChartPoint.ts rename to frontend/src/Data/IChartPoint.ts diff --git a/src/Data/IPoint.ts b/frontend/src/Data/IPoint.ts similarity index 100% rename from src/Data/IPoint.ts rename to frontend/src/Data/IPoint.ts diff --git a/src/Data/ITrack.ts b/frontend/src/Data/ITrack.ts similarity index 100% rename from src/Data/ITrack.ts rename to frontend/src/Data/ITrack.ts diff --git a/src/Data/LoadMockData.ts b/frontend/src/Data/LoadMockData.ts similarity index 100% rename from src/Data/LoadMockData.ts rename to frontend/src/Data/LoadMockData.ts diff --git a/src/Data/MaxSpeed.ts b/frontend/src/Data/MaxSpeed.ts similarity index 100% rename from src/Data/MaxSpeed.ts rename to frontend/src/Data/MaxSpeed.ts diff --git a/src/Data/Surface.ts b/frontend/src/Data/Surface.ts similarity index 100% rename from src/Data/Surface.ts rename to frontend/src/Data/Surface.ts diff --git a/src/Data/TrackChartDataProps.ts b/frontend/src/Data/TrackChartDataProps.ts similarity index 100% rename from src/Data/TrackChartDataProps.ts rename to frontend/src/Data/TrackChartDataProps.ts diff --git a/src/Utils/makeStyles.ts b/frontend/src/Utils/makeStyles.ts similarity index 100% rename from src/Utils/makeStyles.ts rename to frontend/src/Utils/makeStyles.ts diff --git a/src/main.tsx b/frontend/src/main.tsx similarity index 100% rename from src/main.tsx rename to frontend/src/main.tsx diff --git a/src/vite-env.d.ts b/frontend/src/vite-env.d.ts similarity index 100% rename from src/vite-env.d.ts rename to frontend/src/vite-env.d.ts diff --git a/tsconfig.json b/frontend/tsconfig.json similarity index 100% rename from tsconfig.json rename to frontend/tsconfig.json diff --git a/tsconfig.node.json b/frontend/tsconfig.node.json similarity index 100% rename from tsconfig.node.json rename to frontend/tsconfig.node.json diff --git a/vite.config.ts b/frontend/vite.config.ts similarity index 100% rename from vite.config.ts rename to frontend/vite.config.ts diff --git a/yarn.lock b/frontend/yarn.lock similarity index 100% rename from yarn.lock rename to frontend/yarn.lock