Skip to content

Commit 2379d10

Browse files
committed
Update readme guidelines and added bash scripts
1 parent 79167e6 commit 2379d10

File tree

8 files changed

+84
-38
lines changed

8 files changed

+84
-38
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ frontend/.idea
3636
backend/.git
3737
frontend/.git
3838

39+
backend/dbdata-old
3940
backend/dbdata
4041

4142
# TODO: For demo purposes we allow .env to be pushed

README.md

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,39 +26,64 @@
2626
* Docker
2727
* Nginx
2828

29+
## Setup
2930

31+
### Run and Deploy Instantly
3032

33+
### This would run the script to install and setup backend and frontend apps
34+
```bash
35+
$ chmod +x start.sh
36+
$ chmod +x stop.sh
37+
```
3138

32-
## Setup
3339

40+
#### Start the docker apps
41+
```bash
42+
$ ./start.sh
43+
```
3444

3545

36-
### Run and Deploy Instantly
46+
#### Stop the docker apps
3747
```bash
38-
$ docker-compose up
48+
$ ./stop.sh
49+
```
3950

40-
or
51+
<br>
4152

42-
$ docker-compose up --build
43-
```
4453

54+
---
4555

46-
### Run Individually
56+
### Run Manually
4757

4858
#### 1) Backend (default url http://localhost:8888)
4959

5060
```bash
5161
$ cd backend
62+
63+
# install deps
5264
$ pnpm install
65+
66+
# run mysql db server
5367
$ docker-compose up
68+
69+
# run prisma migration
70+
$ npx prisma migrate dev
71+
72+
# (optional) add predefined data to db
73+
$ npx prisma db seed
74+
75+
# run backend app
76+
$ pnpm run start
77+
or
78+
$ pnpm run start:dev
5479
````
5580

5681

5782
#### 2) Frontend (default url http://localhost:8080)
5883
```bash
5984
$ cd frontend
6085
$ pnpm install
61-
$ pnpm run start
86+
$ pnpm run dev
6287
````
6388
6489

backend/README.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ $ pnpm run start:dev
2020
$ pnpm run start:prod
2121
```
2222

23+
24+
> Once backend mysql db is running we need to run Prisma CLI to apply migrations and generate the Prisma client:
25+
26+
```bash
27+
$ npx prisma migrate dev
28+
29+
$ npx prisma generate
30+
```
31+
32+
2333
## Test
2434

2535
```bash
@@ -33,13 +43,6 @@ $ pnpm run test:e2e
3343
$ pnpm run test:cov
3444
```
3545

36-
##
37-
Use Prisma CLI to apply migrations and generate the Prisma client:
38-
39-
```bash
40-
$ npx prisma migrate dev
41-
$ npx prisma generate
42-
```
4346

4447
### Seed the Cafes and Employees (add dummy data)
4548

@@ -57,7 +60,7 @@ Then just to be sure run again...
5760
$ npx prisma migrate dev
5861
```
5962

60-
After that, seed data is now added.
63+
After that, seeded data is now planted in the db ;-)
6164

6265

6366
## API

backend/docker-compose.yaml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,3 @@ services:
99
environment:
1010
- MYSQL_ROOT_PASSWORD=password
1111
- MYSQL_DATABASE=cedb
12-
13-
14-
backend:
15-
build: .
16-
depends_on:
17-
- db
18-
ports:
19-
- '8888:8888'
20-
volumes:
21-
- .:/app
22-
environment:
23-
- DATABASE_URL=mysql://root:password@db:3306/cedb
24-
- NODE_DOCKER_PORT=8888
25-

backend/src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ async function bootstrap() {
1313
};
1414

1515
app.enableCors(options);
16-
await app.listen(port);
16+
await app.listen(port || 8888);
1717
}
1818
bootstrap();

frontend/README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
44

55

6-
### Features
6+
## Features
77

88
-[React.js](https://react.dev/)
99
-[Material-UI](https://mui.com/)
@@ -25,24 +25,25 @@ This template provides a minimal setup to get React working in Vite with HMR and
2525
Run the following command on your local environment:
2626

2727
```shell
28-
git clone --depth=1 https://github.com/sonht113/react-boilerplate-for-starter.git
29-
cd my-project-name
30-
pnpm install
28+
$ pnpm install
3129
```
3230

3331
Then, you can run locally in development mode with live reload:
3432

3533
```shell
36-
pnpm run dev
34+
$ pnpm run dev
3735
```
3836

39-
Open http://localhost:5173 with your favorite browser to see your project.
37+
Open http://localhost:5173 (development) with your favorite browser to see your project.
4038

39+
> **Important:**
40+
> Backend should be already running at http://localhost:8888 or whatever the .env settings is configured
41+
42+
## Project Structure
4143
```shell
4244
.
4345
├── README.md # README file
4446
├── .github # GitHub folder
45-
├── .husky # Husky configuration
4647
├── public # Public assets folder
4748
├── src
4849
│ ├── apis # Common apis folder

start.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
# Install pnpm globally
4+
echo "===========[ Install local pnpm globally...] ============"
5+
npm install -g pnpm
6+
7+
# Navigate to backend directory and install dependencies
8+
echo "===========[ Install backend deps...] ============"
9+
cd backend
10+
pwd
11+
pnpm install
12+
13+
# Return to the root directory and start Docker containers
14+
echo "===========[ Run main docker command...] ============"
15+
cd ..
16+
pwd
17+
docker-compose up -d
18+
19+
# Navigate back to backend directory and run Prisma migrations
20+
echo "===========[ Run prisma migrate in backend...] ============"
21+
cd backend
22+
pwd
23+
npx prisma db seed
24+
npx prisma migrate dev
25+
26+
echo "===========[ Setup complete! ] ============"

stop.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
echo "===========[ Stop docker] ============"
4+
docker-compose down

0 commit comments

Comments
 (0)