Ru

Instructions for deploying CRYSTAL v1.0 on a local PC

28.02.2025

Local PC specifications:

  • OS – Windows 11 Pro, hereinafter referred to as Win 11.
  • Command line (Windows terminal), hereinafter referred to as terminal.
  • MongoDB Compass v1.45.0.
  • MongoDB Community Server v8.0.4.

Project structure:

  • MongoDB v8.0.4.
  • Express.js v4.21.2.
  • React v19.0.0.
  • Node.js v23.6.1.
  • PNPM v10.5.2.
  • Vite v6.1.0.

It is necessary to consistently follow all the points.


1. Installing Git.


Download and install Git. During installation, accept the default values.


2. Creating a directory with the project on your local PC.


The project will be cloned using GitHub CLI, but you can use other methods (HTTPS, SSH). More about GitHub CLI, installer.


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.


3. Installing the MongoDB database.


3.1. Installing MongoDB Community Server.


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.


3.2. Starting the MongoDB server.


If your MongoDB version is higher than 8, change the version number in the command below. Check the version number at the address – ‘C:\Program Files\MongoDB\Server’.


Enter the command in the terminal:

cd C:\Program Files\MongoDB\Server\8.0\bin\ && mongod.exe

4. Starting the frontend part of the project and creating the .env file.


4.1. Create a .env.dev file with the local server address.


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

4.2. Installing PNPM.


Enter the command:

npm install -g pnpm@latest-10 && pnpm -v

4.3. Installing dependencies.


Enter the command:

cd C:\GitProjects\crystal-v1.0\frontend && pnpm i

4.4. Launching the frontend part of the project.


Enter the command:

pnpm dev

After a successful launch, the frontend part of the project will be available at:

http://localhost:8200/

5. Launching the backend part of the project and creating .env files.


Open an additional terminal window.


5.1. Creating a .env file with a secret JSON Web Token key and administrator email.


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

5.2. Creating a .env.dev file


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

5.3. Installing dependencies.


Enter the command:

cd C:\GitProjects\crystal-v1.0\backend & pnpm i

5.4. Launching the backend part of the project.


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.


6. MongoDB Compass


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"
)

Possible problems.


Error – ‘MongoError: connect ECONNREFUSED 127.0.0.1:27017’ (DB does not start).


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

Copy

BTC (Network BTC) - 1C2EWWeEXVhg93hJA9KovpkSd3Rn3BkcYm

Ethereum (Network ERC20) - 0x05037ecbd8bcd15631d780c95c3799861182e6b8

This website uses cookies. By clicking the 'Accept' button or continuing to use the website, you agree to the use of cookies.