Git Product home page Git Product logo

ouorz-mono's Introduction

OUORZ-MONO

Front-end code & Docker image that power www.ouorz.com and other related projects

build status license

screenshot-ouorz-com



Main App

Past Iterations


Feature Highlights

  • SSR/SSG/On-demand ISR
  • Command palette
  • Redux + Redux Saga state management
  • Nexment comment system
  • Dynamic table of contents sidebar
  • Personal dashboard
  • Dark mode

Summary of Tech Stacks

Super opinionated, completely overkill.

  • TypeScript
  • Framework
    • React (Next.js)
    • Foundation/Adaptor implementation coming soon
    • Storybook
    • Turborepo
  • Data Fetching
    • swr
      • Infinite Loading
      • Revalidation
      • Suspense
    • fetch (API Routes)
  • State Management
    • Redux Toolkit
    • Redux Saga
  • Styling:
    • styled-components
    • Tailwind CSS
  • Content Management:
    • WordPress (Qiniu - Static file storage)
    • WP REST API (GraphQL implementation coming soon)
    • Tencent Cloud CVM (CentOS/Nginx/MySQL/PHP)
    • Nexment (LeanCloud)
    • Newsletter (Buttondown)
  • Error Logging & Web Vitals Metric
    • Sentry
  • Linters
    • ESLint
    • Prettier
    • CommitLint
  • CI/CD
    • Github Actions
    • Vercel

Project Setup

git clone [email protected]:ttttonyhe/ouorz-mono.git
pnpm install
cd apps/main

Create a .env file with your configuration, see below for a list of environment variables used in this project:

  • LeanCloud:
    • NEXT_PUBLIC_LC_KEY
    • NEXT_PUBLIC_LC_ID
  • Buttondown:
    • NEXT_PUBLIC_BUTTONDOWN_TOKEN
  • Sentry:
    • NEXT_PUBLIC_SENTRY_DSN
    • SENTRY_AUTH_TOKEN
    • SENTRY_PROJECT
    • SENTRY_ORG
  • On-demand ISR:
    • REVALIDATION_REQUEST_TOKEN
pnpm run dev:main


WordPress App

Warning

Running WordPress in a Docker container is extremely slow on lower-spec machines

>=1 GB of RAM without MySQL 8, or >=2 GB of RAM with MySQL 8 is recommended

This project is wrapped up in a Docker container built based on the official WordPress Docker image: wordpress:php8.0-apache.


Static Image

Each build outputs a static Docker image (similar to a typical containerized application) which means updating WordPress itself or adding new themes/plugins requires redeployment.


Persistent Storage

All uploads are stored in an external store (Qiniu, similar to AWS S3), therefore wp-content/uploads can be treated as temporary data.


Custom Themes

main app uses WordPress REST API to fetch data, wordpress app functions as a headless CMS. The theme peg is used to customize the behaviour of the REST API endpoints, therefore peg/functions.php should be the main focus when it comes to the development of wordpress app.


Environment Variables

  • MySQL Database:
    • WORDPRESS_DB_HOST
    • WORDPRESS_DB_NAME
    • WORDPRESS_DB_PASSWORD
    • WORDPRESS_DB_USER
    • WORDPRESS_TABLE_PREFIX
  • Settings:
    • WORDPRESS_DEBUG

Optionally, WORDPRESS_CONFIG_EXTRA can be set to include other configurations:

  • MySQL SSL Connection:
    • define("MYSQL_CLIENT_FLAGS", MYSQLI_CLIENT_SSL);
  • Turn Off PHP Warnings & Notices:
    • ini_set("error_reporting", E_ALL & ~E_NOTICE);
    • ini_set("display_errors","Off")
  • Redis Object Cache:
    • define("WP_REDIS_HOST", "redis_database_host");
    • define("WP_REDIS_PASSWORD", "redis_database_pwd");"
    • define("WP_REDIS_PORT", "redis_database_port")

Local Development

docker build --tag ouorz-wordpress .
docker run -p 8080:80 \
-e WORDPRESS_DB_HOST=[dev_database_host] \
-e WORDPRESS_DB_USER=[dev_database_user] \
-e WORDPRESS_DB_PASSWORD=[dev_database_pwd] \
-e WORDPRESS_DB_NAME=[dev_database_name] \
-e WORDPRESS_DEBUG=true \
-e WORDPRESS_CONFIG_EXTRA="define('MYSQL_CLIENT_FLAGS', MYSQLI_CLIENT_SSL);" \
-e WORDPRESS_TABLE_PREFIX=[dev_database_prefix] \
ouorz-wordpress


Analytics App

This project is based on Umami

Geolocation Data Access

Follow the instructions here → to sign up for Maxmind GeoLite2, and retrieve a license key


Project Setup

git clone [email protected]:ttttonyhe/ouorz-mono.git
pnpm install
cd apps/analytics

Create a .env file with your configuration, see below for a list of environment variables used in this project:

  • DATABASE_URL
  • HASH_SALT
  • MAXMIND_LICENSE_KEY
pnpm --filter @ouorz/analytics run build-postgresql-client
pnpm run dev:analytics


Twilight Toolkit

A super opinionated front-end toolkit library

twilight-toolkit-storybook

UI

Storybook: https://ui.twilight-toolkit.ouorz.com →

Currently only available in React, Foundation/Adaptor implementation is coming soon.


Utilities

Work in progress



Monorepo

Tooling

Build system: Turborepo with Remote Caching

Monorepo Manager: PNpm


Practices

Running Scripts

  • Use project aliases to run commands in different packages more easily:
    pnpm --filter @ouorz/main run upgrade
  • Use pre-defined Turborepo scripts whenever content awareness (i.e. caching) is needed:
    pnpm run build:main

Managing Dependencies

  • Root package.json should only contain development dependencies

WIP


Statistics

Repobeats analytics image



Development

Gitflow

Not really following this though...

git_branching_workflow


E2E Testing

Test runner: Cypress

Start server:

pnpm run build:main
pnpm run start:main

# or
cd apps/main
pnpm run dev:test

Run tests:

pnpm run test:main

apps/main uses Cypress Dashboard, disable it by changing the configuration file accordingly.



Deployment

apps/wordpress

Build then deploy the Docker image via apps/wordpress/Dockerfile.

Note: by default, the image listens on port 80, rather than the more common 8080


apps/main

This project utilizes a combination of Server-side Rendering (SSR) and (On-demand) Incremental Static Generation (ISG):

pnpm run build:main
pnpm run start:main

apps/analytics

pnpm run build:analytics
pnpm run start:analytics

packages/twilight-ui

To deploy the storybook, export it as a static web app:

pnpm run build:twilight:ui:storybook

Deploy with Fly.io

Configuration file fly.toml can be found under apps/wordpress. Persistent storage should mount to /var/www/html/wp-content.

fly launch

fly secrets set \
WORDPRESS_DB_HOST=[dev_database_host] \
WORDPRESS_DB_USER=[dev_database_user] \
WORDPRESS_DB_PASSWORD=[dev_database_pwd] \
WORDPRESS_DB_NAME=[dev_database_name] \
WORDPRESS_DEBUG=false \
WORDPRESS_TABLE_PREFIX=[dev_database_prefix] \

fly deploy

Optionally, volumes with the same name can be created in multiple Fly.io regions which allows Fly to run one or more instances of the app in multiple regions:

fly volumes create ouorz_wordpress_wp_content --region yyz --size 1 --no-encryption
fly volumes create ouorz_wordpress_wp_content --region fra --size 1 --no-encryption
fly volumes create ouorz_wordpress_wp_content --region hkg --size 1 --no-encryption
fly scale count 3

Optionally, Fly.io offers full-managed Redis databases which can be created using the following commands:

fly redis create

Traffic is automatically routed through a private IPv6 address restricted to your Fly organization.


Deploy with Vercel / Netlify

Make sure to set root directory path to apps/<project-name>, then update build command to the following:

cd ../.. && pnpm run build:<project-name>

Deploy with Vercel

Deploy with Netlify


Enabling diff-based deployment is highly recommended:

git diff --quiet HEAD^ HEAD ./

License

GPL-3.0

FOSSA Status

ouorz-mono's People

Contributors

dependabot[bot] avatar fossabot avatar ttttonyhe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

ouorz-mono's Issues

Github Pages Support

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Icons Component Migration

  • Delete src/components/Icons/index.tsx and all of its usage
  • Add new dependency @heroicons/react
  • Use icon components provided by @heroicons/react

Build a debuncer

  • Debounce
    • Action (Function:T)
    • Delay (Number)
  • Callback
    • Times (Number)
    • Callback Queue (Array<T>)

Migrate to Next.js 13

Objectives

  • Migrate from pages to app directory
  • Use layouts instead of Page/Content components
  • Refactor and create server/client components
  • OG image generation
  • fetch caching
  • Route transition animation

Known Issues

  • Title does not change when navigating between pages (nextjs)
  • Progress bar implementation without next/router
  • Nexment integration

ALCHEMY_API_PATH undefined

ALCHEMY_API_PATH is undefined, and I'm unsure of how to fix it. Googling takes me to alchemy.com, which seems to be the right place as it's an API for fetching NFT data.
Also, I can't seem to figure out how to get ISR revalidate to work. It appears that there's some missing code on WordPress' end.

Private dashboard

  • Authenticated private dashboard
  • Investment portfolio tracking etc.

SASS Design System

  • Utilize more SASS features such as mixins, variables
  • Use rem instead of px

Command Palette

  • Build a keybinding registry
  • Build auto-complete functionality
  • Build the command palette component

Static Blog Posts Generation

  • Develop WordPress REST API posts ID collection endpoint
  • Use Next.js getStaticPaths to pre-render all blog posts

unfriendly documentation for beginners

I have been testing your website for like 3 days now but I feel like the documentation does not touch on few things like configuring the database well. for example. you can find something like /posts/126 which they seem to be fetched by some API cos they are not available in the codebase but I can't really tell where they are coming from or how to configure them to use own details or posts. kindly update

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.