Clone or fork this repository (https://github.com/jmcelhone/Soundscape)
| Layer | Technology |
|---|---|
| Frontend | React |
| Frontend Map API | Leaflet |
| Frontend Build System | Vite |
| Frontend Testing Library | Vitest |
| Backend | Node.js, Express |
| Backend Build System | npm |
| Backend Testing Library | Jest |
| Database | Supabase |
soundscape/
├── client/
│ ├── __mocks__/
│ ├── public/
│ ├── src/
│ │ ├── assets/
│ │ ├── hooks/
│ │ └── style/
│ ├── .gitignore
│ ├── README.md
│ ├── eslint.config.js
│ ├── index.html
│ ├── package.json
│ ├── package-lock.json
│ ├── tsconfig.app.json
│ ├── tsconfig.json
│ ├── tsconfig.node.json
│ ├── vite.config.ts
│ └── vitest.setup.ts
├── server/
│ ├── sql/
│ ├── test/
│ ├── src/
│ ├── jest.config.ts
│ ├── package.json
│ ├── package-lock.json
│ └── tsconfig.json
├── cypress/
| ├── e2e/
| ├── fixtures/
| ├── screenshots/
| └── support/
├── .gitignore
├── cypress.config.js
├── package.json
├── package-lock.json
├── tsconfig.json
├── User-Manual.md
├── dev-docs.md
└── README.md
This repo is separated into the client and server directories for both the static webpage using Vite, React and TypeScript, and the server for database interactions using Node.js and TypeScript.
Root:
.gitignore- General repo gitignorepackage*- npm package configuration filestsconfig.json- TypeScript language configurationUser-Manual.md- Project user manualdev-docs.md- This documentREADME.md- Project README
Client:
.gitignore- Vite specific gitignoreREADME.md- Vite specific READMEeslint.config.js- ESLint configurationindex.html- Root HTML for webpagepackage*- Client specific npm package configurationtsconfig*- Client specific TypeScript language configurationvite.config.ts- Vite configurationvitest.setup.ts- Vitest configuration__mocks__/- Contains mocks for testingpublic/- Webpage assetssrc/- Webpage logic and React componentsassets/- React assetshooks/- Custom hooks for Reactstyle/- Webpage CSS
Server:
jest.config.ts- Jest configurationpackage*- Server specific npm configurationtsconfig.json- Server specific TypeScript language configurationsql/- Database SQL schemastest/- Server Jest testing suitessrc- Server logic
In the root directory, run npm run dev which will run the env-setup.sh script.
Further details on this script can be found in Set-up Environment.
Once the environment is setup, both Vite and Node will be run concurrently. To access the webpage, use the link provided by Vite. Any changes in the client or server will relaunch the server that was modified automatically.
The client can also be build by running npm run build in the client directory.
This will compile the static webpage into the client/dist directory, and can
be viewed using npm run preview. The link given by Vite will access the static
webpage.
Run npm run test which will run the env-setup.sh script. Further details
on this script can be found in Set-up Environment
Tests can be run individually in the client and server directories with
npm run test. The environment setup script will not run in this case. The
environment file may not be setup properly, and npm install may be needed
in order to install packages needed.
Integrations test can be run in the root directory. Make sure the application is running locally and run npx cypress run to run all cypress tests. An individual test file can be run with npx cypress run --spec "cypress/e2e/path/to/file" and run tests with a specfic browser by running npx cypress run --browser chrome. To use the cypress GUI to interactively run and create tests run npx cypress open.
In the client/src/ directory, create a new *.test.tsx file. When making tests,
import @testing-library/react for writing frontend unit tests. SignUpForm.test.tsx
contains good examples for using mocks with beforeEach(), as well as describe()
and it() for writing individual tests.
In the server/test/ directory, create a new TypeScript file with the following,
as well as any imports you would like in your tests:
import { jest, describe, expect, test } from '@jest/globals';
describe(<test suite name>, () => {
test(<test name>, () => {
<test to write>
});
});
Writing multiple tests in the suite is done by adding more test() calls in the
describe() anonymous function. Further information can be found in the
Jest Documentation.
In the client directory, run npm run build which will build a static webpage
in client/dist. Run npm run preview to view the compiled webpage through Vite.
In the server directory, run npm start which will start the node server.
The environment setup script will not be run, and the environment file may not be
setup correctly see Set-up Environment for
more information. npm install should be run on each deployment from both the
client and server directories.
For deployment for release on a production server, make sure that the environment variables are set properly for that server:
client/.env:VITE_SERVER_URL- link to the backend serverVITE_COOKIE_HOST_URL- URL to be put in user session cookies
server/.env:COOKIE_HOST_URL- URL to be put in user session cookies
- URL rewrites/redirects
/api*- rewrite to server URL/auth/confirm*- redirect to server URL +/auth/confirm*for email verification redirects