- Node.js: Install the latest version of Node.js from the official website.
- Nginx: Install Nginx to serve the frontend and backend on a single domain. (for reverse proxy) (Optional)
- PM2: Install PM2 to manage the backend server. (Optional)
- Git: Install Git to clone the repository. (Optional)
-
Clone the repository:
git clone https://github.com/caltechmsc/site.git && cd site
-
Setup the backend:
-
Create a
.env
file in thebackend
directory and add the following environment variables:PORT=5000 # Port number for the server (default: 5000) HOST=localhost # Host address for the server (default: localhost) JWT_SECRET=secret # Secret key for JWT token generation PUBLICATIONS_URL=https://feeds.library.caltech.edu/people/Goddard-W-A-III/article.json # URL for the Caltech Library publications PUBLICATIONS_HTML_URL=https://caltech-msc.github.io/publications/pubs-current.html # URL for the Caltech Library publications HTML (GitHub Pages)
-
Install the dependencies:
cd backend # Move to the backend directory npm install # Install the dependencies
-
Start the backend server:
npm start # Start the backend server
or
pm2 start server.js # Start the backend server with PM2
-
Go back to the root directory:
cd .. # Move to the root directory
-
-
Setup the frontend:
-
Create a
.env
file in thefrontend
directory and add the following environment variables:PORT=3000 # Port number for the server (default: 3000) HOST=localhost # Host address for the server (default: localhost) GOOGLE_CLIENT_ID=client_id # Google OAuth 2.0 client ID
Note: The
GOOGLE_CLIENT_ID
is required for the admin dashboard for google login. You can generate the client ID from the Google Cloud Console. -
Install the dependencies:
cd frontend # Move to the frontend directory npm install # Install the dependencies
-
Build the Tailwind CSS:
npm run build:css # Build the Tailwind CSS
-
Start the frontend server:
npm start # Start the frontend server
or
pm2 start server.js # Start the frontend server with PM2
Note: The configuration to connect to the backend server is already set in the frontend application. If you want to change the backend server address, configure the server URL in the
frontend/public/js/app.js
file (Default:/api
). -
-
Setup Nginx (Optional):
- Configure Nginx as a reverse proxy
/api
to the backend server. (Default:http://localhost:5000
) - Configure Nginx to serve the frontend application. (Default:
http://localhost:3000
) - Restart Nginx to apply the changes.
- (Optional) Configure Certbot for SSL certificate generation and renewal.
- Configure Nginx as a reverse proxy
-
Access the application:
The application should now be running on the machine host, if you are using Nginx, you can access the application via the domain name or IP address of the server.
Note: If you are developing the application, you need to install the development dependencies in the root directory to use linting and formatting tools.