Welcome to the Zero Day Codebase! This is a monorepo that houses multiple applications and libraries. It uses Nx as the build system and pnpm as the package manager. The repository includes a web application and also integrates with Cloudflare Workers for deployment.
To get started with the project, follow the steps below.
First, clone the repository to your local machine using the following command:
git clone https://github.com/Adnan-The-Coder/zero-day-codebase.gitpnpm is the package manager used for managing dependencies in this repository. To install pnpm, follow the steps below based on your operating system:
You can install pnpm globally using Homebrew (macOS) or npm (Linux/macOS):
npm install -g pnpmYou can install pnpm using npm via the command prompt:
npm install -g pnpmIf you encounter any issues with the installation, refer to the official pnpm documentation.
Once pnpm is installed, navigate to the root directory of the project (where the package.json is located) and run the following command to install all the dependencies:
pnpm installThis will install the necessary packages for both the web UI and any other internal libraries or applications.
The project contains a web application built using Next.js. To run the application, follow these steps:
To start the web application locally, use the following command:
nx serve webThis will start the development server on a local machine and you can access the application in your browser at http://localhost:3000. If port 3000 is already in use, it will automatically use the next available port (e.g., 3001).
The web application is built using Next.js, a React framework, and is designed to be used as the user interface of this project. Any changes made within the web directory will trigger rebuilding the project and potentially redeploying the application to Cloudflare Workers.
The web application is also deployed to Cloudflare Workers. This deployment happens automatically when changes are made inside the web folder.
- Changes made within the
apps/webfolder will trigger a deployment to Cloudflare Workers. This is managed by OpenNext scripts written with pnpm run build and pnpm run deploy, through CD pipeline using Cloudflare accont ID and API token. - Every time you run the
nx serve webcommand and changes are made, the build will trigger the deployment process to Cloudflare Workers, ensuring the latest version is always live.
Nx provides several commands for managing your monorepo, including tasks like running, building, testing, and linting applications and libraries.
Starts the development server for a given project (e.g., web).
nx serve webThis will start the development server for the web project, and you can access the application at http://localhost:3000 (or the next available port).
Builds the project and compiles the code.
nx build webThis command will build the web project and output the compiled code to the dist/ folder, which is ready for deployment.
Runs linting checks on the specified project.
nx lint webThis will check the web project for linting errors, and output any issues found.
Runs unit tests for a given project.
nx test webThis will run the unit tests for the web project and show the results in the terminal.
Builds the affected projects based on the changes made to the workspace.
nx affected:build --base=main --head=HEADThis will only build projects that were affected by the changes between the main branch and the current branch.
Run a target (e.g., build, test, lint) for multiple projects at once.
nx run-many --target=build --projects=web,other-appThis command allows you to run the build target for both the web project and another app in the workspace.
Upgrade the Nx workspace and its dependencies to the latest version.
nx migrate latestThis will migrate your workspace to the latest Nx version, making sure everything is up-to-date.
Here's a quick overview of the folder structure in the monorepo:
zero-day-codebase/
├── .github/ # Contains Tests, CI/CD pipelines using github action workflows
├── apps/ # Application packages
│ ├── web/ # Main web application
│ ├── cf-server/ # Cloudflare workers deployed, Backend server for Platform analytics, user related CRUD operations and APIs enabled features
│ ├── python backend/ # Python Backend (coming soon...)
├── packages/ # Shared packages
├── nx.json/ # Configurationa file of nx
├── pnpm-lock.yaml/ # Lockfile for pnpm dependencies
├── package.json/ # Root package manager configuration
└── pnpm-workspace.yaml/ # Defines the structure and workspace of pnpm monorepo
If you run into any issues, here are a few things to check:
- Make sure
pnpmis installed: Verify that you can runpnpm --versionto ensurepnpmis installed globally. - Run Nx with
--verbose: If a command isn't working as expected, try adding--verboseto get more detailed error logs. - Clear Nx cache: If things are stuck, try clearing the Nx cache with
nx resetand reinstall dependencies.
Start from dev branch: When starting any work, always create your branch from the dev branch. Branch naming convention:
- For new features: feat/featurename
- For bug fixes: fix/whatyouarefixing
- For updating content: update/whereyouareupdating
- For documentation updates: docs/whatyouupdated
- For refactoring code: refactor/whatyourefactored
- For urgent hotfixes: hotfix/urgentfix
After completing task, push changes and create a PR to merge your branch into the dev branch. Provide a clear description of the changes in the PR.
Testing Stage is avoided in this rapid development phase and the code is reviewed while merging to main branch itself.
After successful testing, create a PR from the test branch to the main branch. This PR must be approved by the CTO and at least 1 other member. Once approved, the changes will be deployed to production.
Use the following prefixes for clear and consistent commit messages:
feat: for new features.
fix: for bug fixes.
docs: for documentation updates.
refactor: for code refactoring.
style: for formatting and style changes (not affecting code logic).
test: for adding or updating tests.
chore: for maintenance tasks.
Example: feat: add user authentication to login page.
The CI/CD pipeline must run error-free.
If any merge conflicts arise, contributors should immediately contact the Adnan or Nazish for resolution.
In case of critical hotfixes or urgent issues, Adnan must trigger the emergency procedure.
This project is licensed under the MIT License - see the LICENSE file for details.