Sherehe is a web application built with React, TypeScript, Vite, and Tailwind CSS.
- React
- TypeScript
- Vite
- Tailwind CSS
- Zustand
- Axios
- React Router
- Material UI
- Font Awesome
Before running or building the application, ensure the following are installed:
- Node.js
- npm
- Git
You can verify the installed versions with:
node --version
npm --version
git --versionClone the project:
git clone <repository-url>Navigate into the project:
cd sherehe-webInstall the project dependencies using:
npm installThis installs the dependencies defined in package.json and generates the node_modules directory.
For CI/CD environments, the preferred command is:
npm cinpm ci installs dependencies based on the existing package-lock.json and provides more predictable dependency installation in automated environments.
The application uses Vite environment variables.
Create the appropriate environment files in the project root:
.env
.env.development
.env.production
Environment variables exposed to the frontend must follow the Vite naming convention:
VITE_VARIABLE_NAME=value
For example:
VITE_API_BASE_URL=https://api.example.comOnly variables prefixed with VITE_ are exposed to the client-side application.
Vite automatically selects the appropriate environment file based on the command being executed.
When running:
npm run devVite runs in development mode and loads:
.env
.env.development
If the same variable exists in both files, the value in .env.development takes precedence.
For example:
# .env
VITE_API_BASE_URL=https://api.example.com# .env.development
VITE_API_BASE_URL=https://dev-api.example.comRunning:
npm run devwill use:
https://dev-api.example.com
When running:
npm run buildVite runs in production mode and loads:
.env
.env.production
If the same variable exists in both files, the value in .env.production takes precedence.
For example:
# .env
VITE_API_BASE_URL=https://api.example.com# .env.production
VITE_API_BASE_URL=https://prod-api.example.comRunning:
npm run buildwill use:
https://prod-api.example.com
For this project, the configuration can be thought of as:
npm run dev
|
v
development mode
|
┌──────┴──────┐
│ │
.env .env.development
│ │
└──────┬──────┘
|
v
.env.development wins
when variables overlap
And for production:
npm run build
|
v
production mode
|
┌──────┴──────┐
│ │
.env .env.production
│ │
└──────┬──────┘
|
v
.env.production wins
when variables overlap
Therefore, shared/default configuration can be placed in:
.env
Development-specific configuration should be placed in:
.env.development
Production-specific configuration should be placed in:
.env.production
Do not place passwords, private keys, database credentials, or other secrets in VITE_ environment variables.
Vite variables are embedded into the frontend bundle during the build process and are therefore accessible to users of the application.
For example, if:
VITE_API_BASE_URL=https://api.example.comis used during:
npm run buildthe value becomes part of the generated frontend application.
Because Vite environment variables are resolved during the build process, the required environment configuration must be available when the Docker image is built.
For example:
.env.production
|
v
npm run build
|
v
dist/
|
v
Docker image
Changing the .env.production values after the application has already been built will not automatically change the values inside the generated frontend bundle. A new build is required.
Start the Vite development server:
npm run devThe application will normally be available at:
http://localhost:1337
The development server supports hot module replacement, so changes to the source code are reflected automatically.
To create a production build:
npm run buildThe build process performs the following:
- Compiles the TypeScript/React application.
- Processes the Vite configuration.
- Bundles the frontend assets.
- Optimizes the generated JavaScript and CSS.
- Generates the production-ready static files.
The output is generated in:
dist/
The resulting structure will be similar to:
dist/
├── assets/
├── index.html
└── ...
The contents of dist/ are the files that need to be served in production.
After building the application, the production bundle can be tested locally using:
npm run previewThis is useful for verifying the production build before deployment.
Note that npm run preview is intended for local preview/testing and should not normally be used as the production web server.