Local Development
How to set up a local development environment for Poveroh
Poveroh is designed to be easy to set up and run locally. This guide will walk you through the steps to get started with local development.
Every scripts are written in JavaScript and can be run using npm
, so the operating system does not matter. As long as you have Node.js installed, you can follow these instructions on any platform.
Poveroh repository follows the GitHub approach.
The development branch is main
.
Before starting to work on a new feature or fix, create a new branch from main
with a descriptive name. For example, if you are working on a new feature called "user authentication", you can create a branch named feature/user-authentication
.
When you finish your work, push the branch to the remote repository and create a pull request (PR) against the main
branch.
Prerequisites
Before you begin, ensure you have the following installed:
- Node.js (>= 18.x)
- Docker - to run PostgreSQL and NGIX CDN
- Git (for version control)
- A code editor (e.g., Visual Studio Code)
Run Locally
Get start
-
Clone the project
git clone https://github.com/Poveroh/poveroh.git
-
Go to the project folder
cd poveroh
-
Install dependencies
npm install
-
Copy
.env.example
file to.env
, then edit it with the necessary values. For more details, read docs.If you don't modify them, the default values are sufficient to run the project.
Warning: Since these are default values, security is not guaranteed.
Setup Database and CDN
Docker and Docker Compose must be installed, up, and running on the machine.
-
Run
setup
filenpm run setup
The command will execute the following steps:
- Create and run database docker image.
- Navigate to the
packages/prisma
directory. - Generate the Prisma client.
- Apply any pending migrations to the database using Prisma.
- Create and run CDN ngix docker image.
⚠️ Warning:
If you encounter any difficulties or something doesn't go as planned, read this file to execute it manually. -
Create a user; open a browser to localhost:3000/sign-up and sign up.
-
Optionally, you can run the following exactly script to generate and fill database with fake data:
npm run setup:data --user=<user_id_created_before>
You can find user ID on the personal information page
Build and run
-
Build project
npm run build
-
Run project
npm run dev
Debugging & Logging
To debug the project, you can use the built-in debugging tools in your IDE or editor.
If you use VSCode, you can go to the Run and Debug
section and select one of the following options.
Remember that you must run npm run dev
before starting the debugging session.
If you want to debug both simultaneously, you can select Poveroh:app+api
in the Run and Debug
section of VSCode.
This will start both the frontend and backend in debug mode, allowing you to debug both at the same time.
Frontend
If you run comand npm run dev
, automatically the project will be started in debug mode, so in console you can see the logs and debug information.
While coding, it is recommmended to use logger.debug
to log debug information. In production, these logs will not be displayed, but in development mode, they will be visible in the console.
Make sure to print debug information only when necessary, as it can clutter the console and make it harder to find important logs.
If you want to debug it, you can use the browser's developer tools or if you use VSCode, you can go in the Run and Debug
section and select Poveroh:app
.
Backend
In backend, logs are printed in a folder logs
under api
folder. Logs file are in gitignore
, so they are not pushed to the repository.
Unlike the frontend, debug logs are not printed when running the npm run dev
command, but only if LOG_LEVEL
is set to DEBUG
. Default value is INFO
.
Like the frontend, you can attach a debugger to the backend. If you use VSCode, you can go in the Run and Debug
section and select Poveroh:api
.