A full-stack user authentication project built with Node.js, Express, React, PostgreSQL, and JWT.
This project allows users to:
- register an account
- log in securely
- authenticate protected routes with JWT
- manage profile data through a dedicated frontend app
It is a study project focused on backend auth flows, PostgreSQL integration, and frontend interaction with a REST API.
Before starting, make sure you have:
- Node.js 18+
- npm
- PostgreSQL running locally or in a container
- A database created for the app
usersapi/
├── backend/
│ ├── .env.example
│ ├── src/
│ ├── package.json
│ └── ...
├── frontend/
│ ├── app/
│ ├── package.json
│ └── ...
├── README.md
└── .gitignore
- Open a terminal in the
backendfolder. - Install dependencies:
npm install- Create a
.envfile inbackend/based on.env.example:
cp .env.example .env- Update the values in
.envwith your PostgreSQL and JWT credentials:
PORT=3000
DB_USER=your_database_user
DB_PASSWORD=your_database_password
DB_HOST=localhost
DB_PORT=5432
DB_DATABASE=userapi
ACCESS_TOKEN_SECRET=your_access_token_secret
REFRESH_TOKEN_SECRET=your_refresh_token_secret-
Create the database and the required table. The SQL structure is available in
backend/src/config/schema.sql. -
Start the backend server:
npm run devBy default, the backend runs on:
- Open a terminal in the
frontendfolder. - Install dependencies:
npm install- Start the frontend app:
npm run devBy default, the frontend runs on:
To use the full application, both services must be running at the same time:
- PostgreSQL database
- backend API
- frontend app
- Backend: 3000
- Frontend: 5173
- PostgreSQL: 5432
- The backend uses CORS configured for
http://localhost:5173. - JWT secrets should be long and unique in production.
- The project is intentionally designed as a learning-focused application and is meant to evolve over time.