NOTE: See Running the app frontend
section below if you only wish to work on the frontend.
-
Bun (JavaScript Runtime)
-
Node.js (Required for other internal tools)
-
NOTE: If you download the file from github and just place in
bin
folder, don't forget to give it executable permission. -
Use your package manager to install it if your package manager has the
postgresql-server
package is available in your distro's repo.
You don't need any setup for Redis
and Meilisearch
.
After you've installed the postgresql-server
you'll need to initialize the database. Run the following command to initialize the postgres db cluster:
sudo postgresql-setup --initdb
Change the var/lib/pgsql/data/pg_hba.conf
file to allow direct local connections:
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
- host all all 127.0.0.1/32 ident
+ host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 ident
Now start the postgres server:
sudo systemctl start postgresql
To restart already running server use restart
instead of start
.
Log into psql console using:
sudo -u postgres psql
Add a user:
CREATE USER prisma WITH CREATEDB LOGIN PASSWORD 'YourPassword';
You can see all the users using \du
.
Now create a database:
CREATE DATABASE crmm_dev WITH OWNER prisma;
Add the database extensions:
CREATE EXTENSION tsm_system_rows;
You might need to install the postgresql-contrib
package if it's not available.
Restart the postgresql server after adding the extension.
Your database setup is complete now. Keep in mind that you'll need to start the database again after a reboot.
-
Clone the repo in your folder of choice.
-
cd
into the project root and runbun install
to install all deps. -
Now go into
/packages/backend
and runbunx prisma generate
andbunx prisma db push
to synchronise the database with the schema. -
env
fileFRONTEND_URL="http://localhost:3000" CORS_ALLOWED_URLS="http://localhost:3000" OAUTH_REDIRECT_URI="http://localhost:3000/auth/callback" CDN_SERVER_URL="http://localhost:5500" CACHE_CDN_URL="http://localhost:5500" COOKIE_DOMAIN="localhost" PG_DATABASE_URL="postgresql://prisma:PASSWORD@localhost:5432/crmm_dev?schema=public" CDN_SECRET="ANY_RANDOM_STRING" FRONTEND_SECRET="a-secret-between-frontend-and-backend" NODE_ENV="development" # Auth Secrets HASH_SECRET_KEY="HASH_SECRET" GITHUB_ID="GITHB_OAUTH_ID" GITHUB_SECRET="GITHUB_OAUTH_SECRET" DISCORD_ID="DISCORD_OAUTH_ID" DISCORD_SECRET="DISCORD_OAUTH_SECRET" GOOGLE_ID="GOOGLE_OAUTH_APP_ID" GOOGLE_SECRET="GOOGLE_OAUTH_APP_SECRET" GITLAB_ID="GITLAB_OAUTH_APP_ID" GITLAB_SECRET="GITLAB_OAUTH_APP_SECRET" MEILISEARCH_MASTER_KEY="MEILISEARCH_MASTERY_KEY" # Email transport credentials BREVO_USER="[email protected]" SUPPORT_EMAIL="[email protected]" SUPPORT_EMAIL_PASSWORD="" NOREPLY_EMAIL="[email protected]" NOREPLY_EMAIL_PASSWORD="" ADMIN_EMAIL="[email protected]" ADMIN_EMAIL_PASSWORD="" # Deployment Config (Not required) SSH_USER="" SSH_HOST="" # Path to ssh key SSH_KEY=""
Your database url will look something like this
postgresql://DB_USER:PASSWORD@localhost:5432/DB_NAME?schema=public
Paste this env in a
.env
file in/packages/backend
.
- Start the postgres server if not running
cd
into/packages/backend
- Start the redis server:
redis-server --port 5501
- Start the meilisearch server:
meilisearch --master-key MEILISEARCH_MASTER_KEY
Must be same as specified in the env - Start the main app backend:
bun run dev
- The backend server will start on localhost:5500
If you'd like to start all these with one command, you can make use of the pm2 config.
- Install pm2.
- Adjust the executable paths and and project path in pm2 config. (Use absolute paths)
cd
into/packages/backend
- Create
redis
andmeilisearch
folders. - Run
pm2 start pm2.config.cjs
. It will start all three processes. You can manage them using pm2 cli. \
*You'll still have to start the database server manually.
cd
into/packages/frontend
- Change the urls to localhost ones in
utils/config.ts
- Run
bun run dev
- The frontend server will start on localhost:3000
- NOTE: Make sure to change back those urls in the config.ts when making a commit.
If you wish to only work on the frontend, you can totally skip the backend setup and just proxy the requests to the hosted backend.
Set proxy: true
in utils/config.ts
and now all the api requests will be made to the prod backend.