- Node.js installed (version 22 or higher)
- MongoDB instance running (e.g., on
mongodb://localhost:27017)
For local development, both sonic-server and main-app are configured using .env files in their respective directories.
Create a file named .env in the sonic-server/ directory with the following content:
MONGO_URI=mongodb://mongouser:mongopassword@127.0.0.1:27017/
DB_NAME=web-shopping
SONIC_HOST=localhost
SONIC_PORT=1491
SONIC_AUTH=SecretPassword
GRPC_PORT=50051
NODE_ENV=developmentMONGO_URI: Points to your local MongoDB instance.DB_NAME: The database name to use.GRPC_PORT: The port on which thissonic-serverinstance will listen for gRPC connections frommain-app.
Create a file named .env in the main-app/ directory with the following content:
SONIC_GRPC_ENDPOINT=localhost:50051
NODE_ENV=developmentKey main-app variables:
SONIC_GRPC_ENDPOINT: Tellsmain-appwhere to connect to thesonic-server's gRPC service.
After creating the .env files, follow these steps to start the development environment:
- Start the Sonic Server:
Open a terminal, navigate to the
sonic-server/directory, and run:
npm install
npm startThe sonic-server will connect to MongoDB and start its gRPC server on localhost:50051.
- Create Mock Data for MongoDB:
- Navigate to the
sonic-server/directory.
node generateMockData.js- Start the Main Application:
Open another terminal, navigate to the
main-app/directory, and run:
npm install
npm startThe main-app will start its web server on http://localhost:3030 and connect to the sonic-server's gRPC service.
You should then be able to access the main application in your browser at http://localhost:3030.
- Main Application (
main-app): Runs its web server on port3030. - Sonic Server (
sonic-server): Runs its gRPC service on port50051(configured byGRPC_PORTinsonic-server/.env). - MongoDB: Runs on port
27017.