28.02.2025
Download and install Git. During installation, accept the default values.
Working with files in this instruction will take place on the drive – ‘C’.
Press on the keyboard – ‘Win+R’, then enter in the opened window:
cmd
Next, press – ‘Enter’, the terminal will open, enter the command below:
mkdir C:\GitProjects && cd C:\GitProjects && gh repo clone CrystalSystems/crystal-v1.0
This command will create the ‘GitProjects’ folder at – ‘C:\GitProjects’, and clone it into – CRYSTAL v1.0, from project repository.
Download and install MongoDB Community Server (if the link does not open, use VPN), in the ‘Platform’ field, select ‘Windows x64’, in the ‘Package’ field, select ‘msi. In the installer, select ‘Complete’ and click ‘Next’, complete the installation, accepting the default values. MongoDB will be installed at the address – “C:\Program Files\MongoDB”, the program – MongoDB Compass should also be installed.
Enter the command in the terminal:
cd C:\Program Files\MongoDB\Server\8.0\bin\ && mongod.exe
Enter the command in the terminal:
mkdir C:\GitProjects\crystal-v1.0\frontend\env && cd C:\GitProjects\crystal-v1.0\frontend\env && echo VITE_BASE_URL=http://localhost:3000 > .env.dev
Enter the command:
npm install -g pnpm@latest-10 && pnpm -v
Enter the command:
cd C:\GitProjects\crystal-v1.0\frontend && pnpm i
Enter the command:
pnpm dev
After a successful launch, the frontend part of the project will be available at:
http://localhost:8200/
Open an additional terminal window.
Enter the command to create a folder – ‘env’:
mkdir C:\GitProjects\crystal-v1.0\backend\env && cd C:\GitProjects\crystal-v1.0\backend\env
In the next command, you need to set the value of the variable – ‘JWT_SECRET_KEY’, you can enter the value of letters and numbers yourself, or generate it in various services, for example in Nano ID.
An example of what JWT_SECRET_KEY might look like – ‘IA9bVtK6yQu1hpG2TCKCrC5h0VJmRZcZlrnZ’.
echo JWT_SECRET_KEY=JWT_SECRET_KEY > .env
When registering a user with the same email as in the variable – ‘CREATOR_EMAIL’, the administrator mode (editing/deleting users and posts) will be enabled. Change the data in the command below to the desired email.
echo CREATOR_EMAIL=email_for_admin_mode >> .env
The variable – ‘PRODUCTION_STATUS’, in the .env.dev file, determines in which mode the server will be launched, in this case – development mode.
Enter the command:
echo PRODUCTION_STATUS=false > .env.dev
Enter the command:
cd C:\GitProjects\crystal-v1.0\backend & pnpm i
Enter the command:
pnpm startDev
After a successful launch, the terminal should display messages – ‘Server is running’ and ‘DB connected’.
Go to the browser window with the project, at the address – http://localhost:8200/, refresh the page, then register and add a post.
Open MongoDB Compass, and click on the button – ‘Add new connection’, in the field – ‘URI’, the address should be – ‘mongodb://localhost:27017’, click the button – ‘Save & Connect’, after that in the list of databases on the left, a database should appear called – ‘crystal’, which will have two collections – ‘posts’ and ‘users’.
The code below is located in the directory – ‘backend\server.js’ and is responsible for connecting to the local MongoDB server, as well as for the fact that the database will be called – ‘crystal’.
mongoose.connect(
"mongodb://127.0.0.1:27017/crystal"
)
This may happen because the MongoDB service is not running. To start it, follow these steps:
press ‘Win + R’, in the window that opens, enter – ‘Services.msc’ and press – ‘Enter’.
In the window that opens – ‘Services’, find – ‘MongoDB Server (MongoDB)’, right click and select – ‘Start’. MongoDB Server will start, run – ‘pnpm startDev’ again.
Share
Comment on