Skip to content

Commit 1cdf0e3

Browse files
committed
feat: Update README with GPT
1 parent 932d28a commit 1cdf0e3

File tree

5 files changed

+178
-137
lines changed

5 files changed

+178
-137
lines changed

.dockerignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules
2+
dist
3+
.git
4+
.vscode
5+
*.log
6+
.env

Dockerfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Stage 1: Build the app
2+
FROM node:20-alpine AS builder
3+
4+
# Set working directory
5+
WORKDIR /app
6+
7+
# Install dependencies
8+
COPY package*.json ./
9+
RUN npm install
10+
11+
# Copy source code
12+
COPY . .
13+
14+
# Build the app
15+
RUN npm run build
16+
17+
# Stage 2: Serve the app with a lightweight web server
18+
FROM nginx:stable-alpine
19+
20+
# Copy built assets from builder
21+
COPY --from=builder /app/dist /usr/share/nginx/html
22+
23+
# Copy custom Nginx config (optional)
24+
COPY nginx.conf /etc/nginx/conf.d/default.conf
25+
26+
# Expose port
27+
EXPOSE 80
28+
29+
# Start nginx server
30+
CMD ["nginx", "-g", "daemon off;"]

README.md

Lines changed: 108 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -1,165 +1,136 @@
11
# React Sample
22

33
[![GitHub stars](https://img.shields.io/github/stars/raminr77/react_sample?style=social)](https://github.com/raminr77/react_sample/)
4+
[![GitHub_forks](https://img.shields.io/github/forks/raminr77/react_sample?style=social)](https://github.com/raminr77/react_sample/)
45

5-
## Start your React Project with a ready config!
6+
# 🚀 React Sample Project
67

7-
this is a sample of the ReactJs project for starting easily and fast.
8+
A simple and clean React + TypeScript + Vite starter project, configured with essential tools and structured with best practices gained from 7+ years of frontend development experience.
89
<br/>
9-
In this project, we added some configs and installed some necessary packages. they help you to ready very fast and don't waste time them.
10+
This is a sample of the ReactJs project for starting easily and fast.
1011
<br />
1112

12-
## Contents
13+
## 📁 Project Structure
1314

14-
- [Configs](https://github.com/raminr77/react_sample#Configs)
15-
- [Packages](https://github.com/raminr77/react_sample#Packages)
16-
- [Hooks](https://github.com/raminr77/react_sample#Hooks)
17-
- [Tools (utils)](https://github.com/raminr77/react_sample#tools-utils)
18-
- [How To Run](https://github.com/raminr77/react_sample#how-to-run)
19-
- [API Pattern](https://github.com/raminr77/react_sample#api-pattern)
20-
- [You Can Use In This Project](https://github.com/raminr77/react_sample#you-can-use-in-this-project)
15+
```
16+
scripts/ # For Custom Scripts (Icon Generator, etc.)
17+
public/ # Application files (PWA, Icons, Splash Screens, etc.)
18+
src/
19+
├── pages/ # Application pages (auth, landing, main, etc.)
20+
├── layout/ # Layout components and containers
21+
├── shared/ # Shared logic: helpers, constants, services, types, store
22+
├── styles/ # Global styles (SCSS & Tailwind)
23+
└── __test__/ # Unit tests
24+
```
2125

22-
<br />
23-
<hr />
24-
<br />
26+
The project includes complete configurations for **ESLint**, **Prettier**, **Stylelint**, **Husky** (pre-commit hooks), and **CI/CD via GitHub Actions**.
2527

26-
- ## Configs
27-
28-
- Eslint
29-
- Prettier
30-
- Stylelint
31-
- Dockerfile
32-
- `.env` file
33-
- Commit lint
34-
- Redux Config
35-
- Style Config
36-
- SEO & PWA tags
37-
- `jsconfig` file
38-
- `tsconfig` file
39-
- Folder structure
40-
- API cache system
41-
- Private route system
42-
- `lint-staged` config
43-
- Custom `manigest.json`
44-
- `constants` structure
45-
- First loading animation
46-
- API Pattern for request
47-
- Lock API request system
48-
- Cancel duplicate request
49-
- Reset default browser CSS
50-
- Scroll to the top when route change
51-
- Transform data system for API request
52-
- Pre-Commit and Commit-Message config (husky)
53-
54-
- ## Packages
55-
56-
### Dependencies
57-
58-
- TypeScript
59-
- sass (for component module sass)
60-
- animate.css (for your animations)
61-
- tailwindcss (for main style system)
62-
- lodash (for working easily with array)
63-
- axios (for API service and request system)
64-
- classnames (for merge ClassNames and module sass)
65-
- react-router-dom (for routing system in your project)
66-
- prop-types (for specify type in your JSX & component file)
67-
- react-toastify (for notify message to user in your project)
68-
- react-device-detect (for check devices and specify mobile type)
69-
- @reduxjs/toolkit & react-redux (for state management in your project)
70-
71-
### DevDependencies
72-
73-
- husky
74-
- eslint (+ plugins and configs)
75-
- prettier (+ plugins and configs)
76-
- stylelint
77-
- lint-staged
78-
- eslint-config-airbnb
79-
- commitlint + config-conventional
80-
- ## Hooks
81-
82-
- useApi (for requests)
83-
- usePageData (for page requests)
84-
- useCopyToClipboard (for copy text)
85-
- useOnScreen (for traking an element on screen)
86-
87-
- ## Tools (utils)
88-
89-
- Snackbar
90-
- `htmlDecode` function
91-
- URLs for share in social
92-
- `generateSnackbar` function
93-
- `apiRequestObject` for API pattern
94-
- `removeUndefinedFromObject` function
95-
- Log system (Empty function for your config)
96-
- `redirect` and `attachObjectQueriesToUrl` functions
97-
- `truncate` and `shouldTruncate` functions for your texts
98-
- `isDemo`, `isProduction`, `isDevelopment`, `appVersion` and `appName` variables
99-
- `faToEn`, `enToFa`, `arToFa`, `faPriceToEnNumber` and `formatPrice` functions for your numbers (persian language)
28+
---
10029

101-
<br />
30+
## ⚙️ Getting Started Locally
10231

103-
## You Can Use In This Project
32+
### 1. Install Dependencies
10433

105-
- You can use the AnimateCSS framework for your animations, add the class `animate__animated` to an element, along with any of the animation names white the `animate__` prefix.
34+
```bash
35+
npm install
36+
```
10637

107-
`<h1 class="animate__animated animate__bounce">An animated element</h1>`
38+
### 2. Create the `.env` File
10839

109-
REF: https://animate.style/
40+
Create your local environment file by copying the example file:
11041

111-
- You can use `Vazir` font in this project. for change `EN` to `FA` number with font, use `fa-num-font` and `fa-num-font-bold` class. also you can use `vazir-bold` for bold type.
112-
- You can import file from `src` address like this:
42+
```bash
43+
cp .env.example .env
44+
```
11345

114-
`import { INDEX_PAGE_ROUTE } from 'routes/RedirectRoutes';`
46+
Then make sure to configure your **Firebase settings** required for push notifications inside `.env`.
11547

116-
<br />
48+
If you're just testing the app and don't have Firebase set up, you can use dummy values for now.
11749

118-
## API Pattern
50+
---
11951

120-
- Your API
52+
## 🐳 Running with Docker
12153

122-
**TODO**
54+
### Build and Run
12355

124-
- useApi
56+
```bash
57+
docker build -t react-sample-app .
58+
docker run -d -p 3000:80 react-sample-app
59+
```
12560

126-
**TODO**
61+
Visit: [http://localhost:3000](http://localhost:3000)
12762

128-
- usePageData
63+
---
12964

130-
**TODO**
65+
## 📦 Using Docker Compose
13166

132-
<br />
67+
```bash
68+
docker-compose up --build
69+
```
70+
71+
To stop and remove containers:
72+
73+
```bash
74+
docker-compose down
75+
```
76+
77+
---
78+
79+
## ✅ Testing
80+
81+
Unit tests can be added and placed under the `src/__test__` folder. You can use any preferred framework like Vitest or Jest.
82+
83+
---
84+
85+
## 📄 License
86+
87+
This project is open-source and licensed under the [MIT License](LICENSE).
88+
89+
## 💡 Tips & Features
90+
91+
### ✨ Animations
92+
93+
You can use the [AnimateCSS](https://animate.style/) framework for applying animations by adding the class `animate__animated` and the desired animation class with the `animate__` prefix:
94+
95+
```html
96+
<h1 class="animate__animated animate__bounce">An animated element</h1>
97+
```
98+
99+
🔧 **But there's more!** This project includes a custom helper function for generating animation class names easily:
100+
101+
```ts
102+
animator({ name: 'fadeIn', speed: 'faster' });
103+
```
104+
105+
This will generate appropriate class names automatically.
106+
107+
---
108+
109+
### 📁 Import Aliases
110+
111+
You can import modules from the `src` folder using the `@/` alias:
112+
113+
```ts
114+
import { APP_ROUTES } from '@/shared/constants';
115+
```
116+
117+
---
118+
119+
## 🧪 Available NPM Commands
120+
121+
Here’s a list of useful scripts for development and maintenance:
133122

134-
## How To Run
135-
136-
- First Git Clone Or Download Project
137-
- Copy and rename `.env.example` to `.env`
138-
- `npm install` or `yarn add`
139-
- Just Run: `npm start`
140-
- Run white style watching:
141-
- Windows: `npm run dev:windows`
142-
- Linux or MaxOs: `npm run dev`
143-
144-
### Other Commands
145-
146-
- Test: `npm run test`
147-
- Build: `npm run build`
148-
- Eslint: `npm run lint:fix`
149-
- Prettier: `npm run pretty`
150-
- Stylelint: `npm run lint:style`
151-
- Styles (Watching): `npm run styles`
152-
- Build Styles: `npm run build:styles`
153-
154-
<hr />
155-
156-
### Project TODO
157-
158-
- [ ] Scripts
159-
- [ ] Storybook
160-
- [ ] Test config
161-
- [ ] E2E test config
162-
- [ ] Folder Structure
163-
- [ ] Convert js to ts
164-
- [ ] Add API pattern Doc to MD file
165-
- [ ] Add usePageData & UseApi Doc to MD file
123+
| Command | Description |
124+
|------------------|----------------------------------------------|
125+
| `dev` | Run the project locally using Vite |
126+
| `test` | Run unit tests with Vitest |
127+
| `prepare` | Prepare Git hooks using Husky |
128+
| `lint` | Run ESLint and fix issues automatically |
129+
| `format` | Format the code using Prettier |
130+
| `build` | Build TypeScript and the app bundle |
131+
| `check-lint` | Check lint issues without fixing |
132+
| `check-format` | Check code formatting |
133+
| `preview` | Preview production build at port 8080 |
134+
| `check-types` | Type-check the project without emitting files|
135+
| `pretty` | Format all JS/TS/CSS/SCSS source files |
136+
| `lint:style` | Run Stylelint for style file validation |

docker-compose.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
version: '3.8'
2+
3+
services:
4+
react-app:
5+
build:
6+
context: .
7+
dockerfile: Dockerfile
8+
container_name: react-sample-app
9+
ports:
10+
- "3000:80"
11+
restart: unless-stopped
12+
environment:
13+
- NODE_ENV=production
14+
volumes:
15+
- ./public:/usr/share/nginx/html/public:ro
16+
depends_on: []

nginx.conf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
server {
2+
listen 80;
3+
server_name _;
4+
5+
root /usr/share/nginx/html;
6+
index index.html;
7+
8+
location / {
9+
try_files $uri $uri/ /index.html;
10+
}
11+
12+
location /assets/ {
13+
access_log off;
14+
expires 30d;
15+
}
16+
17+
error_page 404 /index.html;
18+
}

0 commit comments

Comments
 (0)