This guide provides step-by-step instructions for setting up the authentication template application on your local machine and deploying to Render.com.
Before you begin, you'll need to install the following software:
- Node.js and npm (Node Package Manager)
- PostgreSQL
- A code editor (e.g., VS Code, Webstorm, etc.)
- Git
Node.js is the JavaScript runtime that powers the server-side of this application. npm is the package manager that comes with Node.js and helps you install dependencies.
- Download the installer from Node.js official website
- Choose the LTS (Long Term Support) version
- Run the installer and follow the installation wizard
- Verify installation by opening Command Prompt and typing:
node --version npm --version
Option 1: Using Homebrew (recommended):
brew install node
Option 2: Using the installer:
- Download the installer from Node.js official website
- Choose the LTS version
- Run the installer and follow the instructions
- Verify installation in Terminal:
node --version npm --version
sudo apt update
sudo apt install nodejs npm
node --version
npm --version
PostgreSQL is the database used by this application to store user information.
- Download the installer from PostgreSQL Downloads
- Run the installer and follow the installation wizard
- Remember the password you set for the
postgressuperuser - Ensure the installer adds PostgreSQL to your PATH
- Verify installation:
psql --version
Option 1: Using Homebrew (recommended):
brew install postgresql@17
brew services start postgresql@17Option 2: Using Postgres.app:
- Download from Postgres.app
- Move to Applications and open
- Click "Initialize" to create a new server
Verify installation:
psql --version
sudo apt update
sudo apt install postgresql postgresql-contrib
sudo systemctl start postgresql
sudo systemctl enable postgresqlAfter installing PostgreSQL, create a database for the project:
# Connect to PostgreSQL as the postgres user
psql -U postgres
# In the PostgreSQL shell, create the database
CREATE DATABASE csc317_project;
# Exit the shell
\qOn macOS with Homebrew, you may need to use:
createdb csc317_project-
Fork the repository on GitHub by clicking the "Fork" button in the top right corner
-
Clone your fork locally:
git clone https://github.com/YOUR-USERNAME/CSC317Project-F25.git cd CSC317Project-F25
Alternatively, download the ZIP file of the project and extract it to a location of your choice.
In the project directory, run:
npm install
This will install all the required dependencies specified in package.json.
Create a .env file in the root directory of the project:
cp .env.example .env
Or manually create a file named .env in the project root directory with the following content:
PORT=3000
NODE_ENV=development
DATABASE_URL=postgresql://postgres:your_password@localhost:5432/csc317_project
SESSION_SECRET=your_secure_random_string_here
Notes:
PORT: The port on which the application will run (default: 3000)NODE_ENV: The environment (development, production, etc.)DATABASE_URL: The connection string for your PostgreSQL database- Format:
postgresql://username:password@host:port/database_name - Replace
your_passwordwith the password you set during PostgreSQL installation
- Format:
SESSION_SECRET: A random string used to sign the session ID cookie (for security)
For the SESSION_SECRET, you should use a long, random string. You can generate one by running this in the terminal:
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
Run the database initialization script to create the required tables:
npm run db:init
You should see output like:
✓ Users table created
✓ Profile images table created
✓ Session table created
✓ Indexes created
✅ Database initialization complete!
In the project directory, run:
npm run dev
This will start the application in development mode with nodemon, which automatically restarts the server when you make changes to the code.
Open your web browser and navigate to:
http://localhost:3000
You should see the home page of the authentication template.
Render.com is a cloud platform that makes it easy to deploy web applications with PostgreSQL databases.
- Go to Render.com and sign up for a free account
- Connect your GitHub account to Render
Make sure your project is in a GitHub repository:
git init
git add .
git commit -m "Initial commit"
git remote add origin <your-github-repo-url>
git push -u origin main- In your Render dashboard, click "New" → "PostgreSQL"
- Fill in the details:
- Name:
csc317-project-db(or your preferred name) - Database:
csc317_project - User: Leave as default
- Region: Choose the closest to your users
- PostgreSQL Version: 17 (latest)
- Instance Type: Free (for development)
- Name:
- Click "Create Database"
- Wait for the database to be created
- Copy the Internal Database URL from the database info page (you'll need this later)
- In your Render dashboard, click "New" → "Web Service"
- Connect your GitHub repository
- Fill in the details:
- Name:
csc317-project(or your preferred name) - Region: Same as your database
- Branch:
main - Runtime: Node
- Build Command:
npm install - Start Command:
npm start - Instance Type: Free (for development)
- Name:
In your web service settings, add the following environment variables:
- Click "Environment" in the left sidebar
- Add the following variables:
DATABASE_URL: Paste the Internal Database URL from your PostgreSQL databaseSESSION_SECRET: Generate a secure random string (use the command from Step 5 above)NODE_ENV:production
After your first deployment, you need to initialize the database tables. You have two options:
Option A: Using Render Shell
- Go to your web service dashboard
- Click "Shell" in the left sidebar
- Run:
npm run db:init
Option B: Using a One-off Job
- In your Render dashboard, click "New" → "Cron Job"
- Connect to the same repository
- Set the command to:
npm run db:init - Run it once, then delete the cron job
- Render will automatically deploy your application when you push to GitHub
- You can also manually trigger a deploy from the dashboard
- Once deployed, click the URL at the top of your web service page to view your app
When you push changes to GitHub, Render will automatically redeploy your application. You can also:
- View deploy logs in the "Events" tab
- Rollback to previous versions if needed
- Monitor your app's health in the "Metrics" tab
If you encounter issues connecting to PostgreSQL:
-
Ensure PostgreSQL is running:
- Windows: Check Services for "postgresql"
- macOS:
brew services listor check Postgres.app - Linux:
sudo systemctl status postgresql
-
Check your DATABASE_URL in the
.envfile:- Verify username and password are correct
- Ensure the database exists
- Check the port (default: 5432)
-
Test the connection manually:
psql -U postgres -d csc317_project
If npm run db:init fails:
- Ensure the database exists:
createdb csc317_project - Check database permissions
- Verify your DATABASE_URL is correct
- Check PostgreSQL logs for detailed error messages
If you encounter issues with Node.js or npm:
- Ensure you have the correct version of Node.js installed (18.x or higher recommended)
- Try deleting the
node_modulesfolder and runningnpm installagain - Clear npm cache with
npm cache clean --force
If port 3000 is already in use:
- Change the PORT in your
.envfile to another value (e.g., 3001, 8080) - Restart the application
If your Render deployment fails:
- Check the deploy logs for error messages
- Ensure all environment variables are set correctly
- Verify the DATABASE_URL uses the Internal Database URL
- Check that the build and start commands are correct
After setting up the application, you can:
- Register a new user account
- Log in with the created account
- Explore the protected routes
- Start building your own features on top of this authentication template
- Modify the styling to match your application's design
For more information about the template features and how to extend them, refer to the TEMPLATE-README.md file.