This project is maintained by the @frylo-d-ts.
- How to use this template?
- Run Locally
- Technical stack
- File structure
- Code style
- Documentation
- Git
- Environment
- Support
- README changes
- Change the h1 title to the name of your project.
- Change line
This project is maintained
, place there your email. - Replace all
PROJ
instances to your Jira tasks code. - Add emails in support part of readme.
package.json
- Change name of the project
- Change description
- Change version
- Change author
- Change keywords or remove this prop
commitlint.config.js
- Change Jira tasks number prefix to validate commit messages correctly
module.exports = { rules: { 'task-numbers': [2, 'always', 'NEXT-'], // Replace 'NEXT-' with your Jira task prefix }, plugins: [
- Change Jira tasks number prefix to validate commit messages correctly
- Env files (
.env.development
,.env.prod
,.env.stage
)- Replace domain names
- Configure what env should be pass protected
- Docker config
- Change
project-name
atpackage.json
, at script with namedocker
. - Rename
.env example
file to.env
and put real creds to DB inside. - Replace
projectName
instances to the name of a project at:dev docker-compose.yml
,prod docker-compose.yml
. - Replace
example.com
to real domain atnginx.conf
.
- Change
- Final steps
- Remove this chapter from README
- Remove unnecessary pages from
./src/app
folder - Enjoy development ;)
Below are the instructions on how to run project locally:
Preconditions:
- Install NVM (windows, linux / macos)
- Install Docker (windows / linux / macos)
# Clone the project
git clone <github-project-link>
# Go to the project directory
cd <project-folder>
# Switch to correct node version
nvm install
nvm use
# Install pnpm - https://pnpm.io/
npm install -g pnpm
# Install all dependencies
pnpm i
# Start the server in dev mode
pnpm dev
- Next.js - SSR React.js framework.
- Vanilla Extract CSS - Zero-runtime lib for writing styles.
- Zustand - State management lib.
- clsx - Combinator for class names.
- Storybook - Framework for writing powerful docs for UI Kit.
- Docker - Virtual environment to run your project easily.
- MongoDB - NoSQL database to store your data.
Press to open
.
├── .husky Contains tasks for precommit
├── .vscode All required plugins are stored here as recommendations
├── @types Global types
├── src Folder with all sources
│ ├── app Folder defining routing of app
│ ├── assets Folder with assets, could be imported from code
│ ├── components Check "Components folder" chapter
│ │ ├── blocks Check "Components folder" chapter
│ │ ├── common Check "Components folder" chapter
│ │ └── sections Check "Components folder" chapter
│ ├── stores Folders with all zustand stores
│ ├── styles Folders with all basic vanilla-extract/css styles
│ ├── constants Project constants
├── next.config.js Config for NextJS
├── next-env.d.ts Typing config for NextJS
├── package.json Yarn package list and config
├── public Static files
│ ├── favicon.ico Favicon of site
│ └── fonts Folder with all fonts
└── README.md You are here
Folder /src/components
is divided to few folders. Take a look at the main idea of this folders:
Priority | Folder | Idea |
---|---|---|
1 | /src/components/sections | Usually each page is built from sections. So this folder contains sections for each page. SECTION - it is components taking full width of device. |
2 | /src/components/blocks | Blocks are reusable components, used inside in sections. Main difference between Block and Section - Block can't take full width of page. |
3 | /src/components/common | This components could be used everywhere. By other words, components in this folder could be named as UI Kit of project. Any change in this folder have to be documented via storybook. |
Some of project components are covered by storybook
. To open project docs do the following:
pnpm sb:dev # Starts locally OR
pnpm sb:build # Make static build
This command will open storybook on you local machine. Read more about storybook
at official documentation.
When any developer finished his work, he commits files and lint-staged
package runs commands before making a commit.
It is run ONLY for STAGED files. So do not be worried to make commits.
// Check TS files for no errors
'**/*.(ts|tsx)': () => 'pnpm tsc --noEmit',
// Lint and format TS and JS files
'**/*.(ts|tsx|js)': (filenames) => [
`pnpm eslint --fix ${filenames.join(' ')}`,
`pnpm prettier --write ${filenames.join(' ')}`,
],
Format of branch names:
PROJ-{task-number}-{short-description}
Examples:
PROJ-821-fix-bug
- if task exists when branch createdNOTASK-update-deps
- if task do not exists when branch created
Format of commit messages:
PROJ-{task-number}: What has been done
Examples:
PROJ-872: Update mobx to 0.1.2
PROJ-324: Added shift and debugVideoPos. Upd docs
NOTASK: Logging into chat
We work in sprints. So git flow adjusted for sprint logic.
Tips:
- All tasks are forked from current
main
. - When task ready for code review - you create MR into current
main
branch. - If task do not pass tests, you simply fix bugs at same branch and merge it to
main
again. - At the end of sprint we create release branch to perform regression testing on testing stage.
- All hot-fixed from regression testing are located on release branch.
- After all fixed hot-fixes release branch merge to main.
Deployment script uses .creds.mjs
file from the root of the project. This file gitignored, that allows you to store creds in more secure manner.
If you do not have .creds.mjs
, then create it by copying .creds.example.mjs
file. Put credentials to your server inside of it.
For not deployment supports only VPS servers with SSH connection to them. It is because of necessary to run CLI commands to restart docker-compose on server.
To deploy your app, simply run one of the following commands, matching the env you gonna to deploy:
pnpm deploy:stage # Deploy to staging environment
pnpm deploy:prod # Deploy to production environment
There are several scripts to manage docker:
pnpm docker:dev
- base docker-compose command for dev environment.pnpm docker:dev.reset
- resets docker with dev docker-compose.yml file.pnpm docker:prod
- base docker-compose command for prod environment.pnpm docker:prod.reset
- resets docker with prod docker-compose.yml file.
I'll show you some examples of usage of this command on development env example. They gonna work same for prod env.
Examples:
pnpm docker:dev up # `docker compose up` for local development
pnpm docker:dev down --volumes # `docker compose down --volumes`, stops containers & networks, removes volumes
pnpm docker:dev build --no-cache # `docker compose build --no-cache`, builds all containers from scratch
pnpm docker:dev.reset # downs docker-compose with all volumes and performs build without cache usage
For any support, email maintainer of the project or: