-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Final Project setup: Design tokens, docker, knip, codegen #8
Changes from all commits
2f30905
d3236f7
aa14368
2bfbe59
0366405
8887f45
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "backend"] | ||
path = backend | ||
url = [email protected]:toggle-corp/ai-chatbot-backend.git |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
enable-pre-post-scripts=true |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,92 @@ | |
|
||
The AI chatbot will be white-labeled, allowing for full customization to meet the needs of any company. The chatbot will be integrated with Facebook Messenger, WhatsApp, and a custom chat window that can be embedded into company websites. | ||
|
||
Useful Resources and Links | ||
## Built with | ||
[![React][react-shields]][react-url] [![Vite][vite-shields]][vite-url] [![Typescript][typescript-shields]][typescript-url] | ||
|
||
* Board board: https://github.com/orgs/toggle-corp/projects/36 | ||
* Timeline: | ||
* Figma: | ||
* Local Deployment: | ||
## Getting started | ||
|
||
Below are the steps to guide you through preparing your local enviroment for the AI CHATBOT CMS. Before diving into setup please look into the concept of [Github Sub Modules](https://github.blog/open-source/git/working-with-submodules/), [Docker Merge](https://docs.docker.com/compose/how-tos/multiple-compose-files/merge/). | ||
|
||
### Prerequisites | ||
|
||
To begin, ensure you have network access. Then, you'll need the following: | ||
|
||
1. [Git](https://git-scm.com/) | ||
2. [Node.JS](https://nodejs.org/en/) version >=18 / 20+ | ||
3. [Pnpm](https://pnpm.io/) | ||
4. Alternatively, you can use [Docker](https://www.docker.com/) to build the application. | ||
|
||
### Local development (with docker) | ||
|
||
Clone the repository using HTTPS, SSH, or Github CLI | ||
```bash | ||
git clone https://github.com/toggle-corp/ai-chatbot-cms.git #HTTPS | ||
git clone [email protected]:toggle-corp/ai-chatbot-cms.git #SSH | ||
gh repo clone toggle-corp/ai-chatbot-cms #Github CLI | ||
``` | ||
Download the contents of backend(ai-chatbot-backend) | ||
```bash | ||
git submodule update --init --recursive | ||
``` | ||
Update Environment variables | ||
* create .env file and add COMPOSE_FILE variable for the ai-chatbot-cms | ||
```bash | ||
touch .env | ||
``` | ||
* Copy env.example to .env and update the variables for the backend | ||
```bash | ||
cd backend | ||
cp env.example .env | ||
``` | ||
> NOTE: The backend has a higher priority than the ai-chatbot-cms. You can add backend environment variables in the CMS, but you must create a .env file in the backend for them to work. | ||
|
||
Build the docker image | ||
```bash | ||
docker compose build | ||
``` | ||
Start the development server | ||
```bash | ||
docker compose up | ||
``` | ||
Install the dependencies | ||
```bash | ||
docker compose exec react bash -c 'pnpm install' | ||
``` | ||
Generate type | ||
```bash | ||
docker compose exec react bash -c 'pnpm generate:type' | ||
``` | ||
### Local development (without docker) | ||
|
||
Same steps upto downloading the contents of backend | ||
|
||
Update Enviroment variables | ||
|
||
* create .env file and add COMPOSE_FILE and other variable for the ai-chatbot-cms | ||
```bash | ||
touch .env | ||
``` | ||
> NOTE: Copy the env variables from the docker compose file in environment section | ||
|
||
Install the dependencies | ||
```bash | ||
pnpm install | ||
``` | ||
Generate type | ||
```bash | ||
pnpm generate:type | ||
``` | ||
Start the development server | ||
```bash | ||
pnpm start | ||
``` | ||
|
||
<!-- MARKDOWN LINKS & IMAGES --> | ||
<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links --> | ||
[react-shields]: https://img.shields.io/badge/react-%2320232a.svg?style=for-the-badge&logo=react&logoColor=%2361DAFB | ||
[react-url]: https://reactjs.org/ | ||
[vite-shields]: https://img.shields.io/badge/vite-%23646CFF.svg?style=for-the-badge&logo=vite&logoColor=white | ||
[vite-url]: https://vitejs.dev/ | ||
[typescript-shields]: https://img.shields.io/badge/typescript-%23007ACC.svg?style=for-the-badge&logo=typescript&logoColor=white | ||
[typescript-url]: https://www.typescriptlang.org/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { CodegenConfig } from '@graphql-codegen/cli'; | ||
|
||
const config: CodegenConfig = { | ||
schema: process.env.APP_GRAPHQL_CODEGEN_ENDPOINT, | ||
documents: [ | ||
'src/**/*.tsx', | ||
'src/**/*.ts', | ||
], | ||
ignoreNoDocuments: true, // for better experience with the watcher | ||
generates: { | ||
'./generated/types/': { | ||
preset: 'client', | ||
}, | ||
}, | ||
config: { | ||
enumsAsTypes: true, | ||
}, | ||
}; | ||
|
||
export default config; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: chatbot | ||
|
||
services: | ||
react: | ||
build: ../ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pass it using context There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For this we use case build and context are same so this should be fine. |
||
command: sh -c 'pnpm install && pnpm start --host' | ||
environment: | ||
APP_TITLE: ${APP_TITLE:-CMS} | ||
APP_GRAPHQL_ENDPOINT: ${APP_GRAPHQL_ENDPOINT:-http://localhost:8001/graphql/} | ||
APP_GRAPHQL_CODEGEN_ENDPOINT: ${APP_GRAPHQL_CODEGEN_ENDPOINT:-./backend/schema.graphql} | ||
volumes: | ||
- ../:/code | ||
ports: | ||
- '3000:3000' | ||
depends_on: | ||
- web | ||
Comment on lines
+15
to
+16
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where is this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is pulled from backend docker-compose |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,26 @@ | |
<title> | ||
%APP_TITLE% | ||
</title> | ||
<link href="https://api.fontshare.com/v2/css?f[]=nunito@300,700,400&f[]=bebas-neue@400&display=swap" rel="stylesheet"> | ||
<link href="https://fonts.googleapis.com/css2?family=Assistant:wght@300;400;600;700&family=Manrope:wght@300;400;600;700&display=swap" rel="stylesheet"> | ||
<style> | ||
html, body { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
body { | ||
font-family: "Manrope", sans-serif; | ||
font-optical-sizing: auto; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what does this do? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i have taken reference from the Timur and base-react-app, so i don't know exactly why this css are are we need to discuss about it with ankit dai. |
||
font-weight: 400; | ||
font-style: normal; | ||
} | ||
|
||
@media screen { | ||
body { | ||
background-color: #F5FAFF; | ||
} | ||
} | ||
Comment on lines
+38
to
+42
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we need this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same in this just changed the values |
||
</style> | ||
</head> | ||
<body> | ||
<noscript> | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"$schema": "https://unpkg.com/knip@5/schema.json", | ||
/* NOTE: It is ignored because some of the files and types inside the generated will not be used but needed. */ | ||
"ignore": ["generated/**/*.ts"], | ||
"entry": [ | ||
"src/index.tsx!", | ||
"src/**/*.test.ts", | ||
"src/**/*.test.tsx" | ||
], | ||
"project": [ | ||
"src/**/*.tsx!", | ||
"src/**/*.ts!", | ||
"src/**/*.d.ts", | ||
"src/**/*.test.ts", | ||
"src/**/*.test.tsx", | ||
"generated/**/*.ts" | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,30 +4,37 @@ | |
"version": "0.0.0", | ||
"type": "module", | ||
"scripts": { | ||
"generate:type": "graphql-codegen --require dotenv/config --config codegen.ts", | ||
"prestart": "pnpm generate:type", | ||
"start": "vite", | ||
"dev": "vite", | ||
"prebuild": "pnpm generate:type", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we really need this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we need to generate type before build |
||
"build": "vite build", | ||
"preview": "vite preview", | ||
"test": "vitest", | ||
"coverage": "vitest run --coverage", | ||
"pretypecheck": "pnpm generate:type", | ||
"typecheck": "tsc", | ||
"lint": "pnpm lint:js && pnpm lint:css", | ||
"lint:fix": "pnpm lint:js --fix && pnpm lint:css --fix", | ||
"prelint:unused": "pnpm generate:type", | ||
"lint:unused": "knip --no-gitignore --tags=-knipignore", | ||
"prelint:js": "pnpm generate:type", | ||
"lint:js": "eslint src", | ||
"lint:css": "stylelint \"./src/**/*.css\"", | ||
"lint:unused": "knip --tags=-knipignore", | ||
"lint": "pnpm lint:js && pnpm lint:css", | ||
"lint:fix": "pnpm lint:js --fix && pnpm lint:css --fix", | ||
"test": "vitest", | ||
"test:coverage": "vitest run --coverage", | ||
"postinstall": "patch-package" | ||
}, | ||
"dependencies": { | ||
"@apollo/client": "^3.11.8", | ||
"@togglecorp/fujs": "^2.0.0", | ||
"@graphql-typed-document-node/core": "^3.2.0", | ||
"@julr/vite-plugin-validate-env": "^1.1.1", | ||
"@togglecorp/fujs": "^2.0.0", | ||
"graphql": "^16.9.0", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0", | ||
"react-router-dom": "^6.11.1" | ||
}, | ||
"devDependencies": { | ||
"@graphql-codegen/cli": "^5.0.2", | ||
"@graphql-codegen/client-preset": "^4.3.3", | ||
"@types/node": "^20.1.3", | ||
"@types/react": "^18.0.28", | ||
"@types/react-dom": "^18.0.11", | ||
|
@@ -36,6 +43,7 @@ | |
"@vitejs/plugin-react-swc": "^3.0.0", | ||
"@vitest/coverage-v8": "^2.1.3", | ||
"autoprefixer": "^10.4.14", | ||
"dotenv": "^16.4.5", | ||
"eslint": "^8.40.0", | ||
"eslint-config-airbnb": "^19.0.4", | ||
"eslint-import-resolver-typescript": "^3.5.5", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why the file name is changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docker compose uses docker-compose.yml as default configuration file, since we need additional configuartion as provide in README we don't want developer to directly use docker-compose.yml