Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
236 changes: 184 additions & 52 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,58 +1,190 @@
# 📘 Digital Logbook (Digital Diary)

## Project Setup Instructions

### Node.js and npm Versions

This project requires the following versions:

- **Node.js**: v22.7.0
- **Docker**: 27.1.2
- **Postgres**: 16.3
- **Node Package Manager**: 10.8.2

To ensure compatibility, please use these specific versions.

### Setting Up Your Environment

Prior to setting up the enviornment, if you are not familiar with Node.js and NPM go through this awsome [blog post](https://medium.com/@oroz.askarov/all-you-need-to-know-about-npm-and-packages-as-a-beginner-b6fcea8b3519).

1. **Install Node Version Manager (nvm)**:
If you don't already have `nvm` installed, you can install it by following the instructions [here](https://github.com/nvm-sh/nvm#installing-and-updating).
2. **Navigate to the server directory**
```bash
cd server/
```
3. **Switch to the required Node.js version**:
Once `nvm` is installed, navigate to the project directory and run:
```bash
nvm use
```
4. **Install the environment incase if it's not already available (optional)**
If step 2 prompts you to install the environment then run:
```bash
nvm install
```
5. **Install the correct npm**:
Install node package manager with this specific version:
```bash
npm install [email protected]
```

### Installing dependencies

1. **Install dependencies by running**
```bash
npm install
```
### Installing database

To host the database locally we are going to use docker, please make sure that you have docker desktop installed in your PC.

- Once you do, if you have cloned the repo for the first time then type this command in the root directory of the project
A web application developed with **Next.js (TypeScript)**, **PostgreSQL** (via **Prisma**), and **Docker**. This project is part of the **TRACE T2T Internship Program** to help interns and mentors track evaluations and logbook entries efficiently.

---

## 🚀 Tech Stack

- **Frontend/Backend**: [Next.js](https://nextjs.org/) (v14.2.5) with TypeScript
- **Database**: PostgreSQL (v16.3) via [Prisma ORM](https://www.prisma.io/)
- **Containerization**: Docker with Compose
- **Other Services**: Redis, pgAdmin

---

## 🔧 Prerequisites

Ensure you have the following installed:

- **Node.js**: `v22.7.0`
- **npm**: `v10.8.2`
- **Docker**: `v27.1.2`
- **PostgreSQL**: Installed **locally**
- **Docker Desktop** running

---

## 📁 Project Setup Instructions

### 1. Clone the Repository

```bash
git clone https://github.com/tracet2t/Digital-Logbook.git
cd Digital-Logbook
```

---

### 2. Configure Environment Variables

Edit a `.env` file in the root directory:

```env
BASE_URL=http://localhost:3000

# Database
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/postgres?schema=public"

# Authentication
JWT_SECRET="thisismysecretkey"
JWT_EXPIRY="60 min"
ISSUER=http://localhost:3000
AUDIENCE=http://localhost:3000

# Frontend
NEXT_PUBLIC_BASE_URL=http://localhost:3000

# Email Config - Replace with your credentials
EMAIL_USER="[email protected]"
EMAIL_PASS="your-app-password"
```

📝 **Note**: Replace email credentials with valid ones.

---

### 3. Install Node and npm (Using `nvm`)

```bash
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
nvm install 22.7.0
nvm use
npm install -g [email protected]
```

---

### 4. Install PostgreSQL Locally

You must have PostgreSQL running on your machine (outside Docker):

- Create a `postgres` database
- Use credentials:
- **User**: `postgres`
- **Password**: `postgres`

---

### 5. Prepare for Initial Docker Build

#### A. Dockerfile

In `server/Dockerfile`, **comment out** this line:

```Dockerfile
# RUN npx prisma migrate deploy
```

#### B. docker-compose.yml

**Comment out** the entire `nextjs-app` block:

```yaml
# nextjs-app:
# container_name: nextjs-app
# build:
# context: ./server
# dockerfile: Dockerfile
# ports:
# - "3000:3000"
# environment:
# NEXT_PUBLIC_POSTGRES_HOST: pgdb
# NEXT_PUBLIC_POSTGRES_USER: postgres
# NEXT_PUBLIC_POSTGRES_PASSWORD: postgres
# NEXT_PUBLIC_REDIS_HOST: redis
# NEXT_PUBLIC_REDIS_PORT: 6379
# depends_on:
# - postgres
# - redis
# networks:
# - mynetwork
# dns:
# - 8.8.8.8
# - 1.1.1.1
```

---

## 🐳 Start Docker Services

```bash
docker compose up --build
```
- If you are trying to run the database for development run

This will run:

- **pgAdmin**: [http://localhost:8080](http://localhost:8080)
- **PostgreSQL**
- **Redis**

---

## 🧬 Run Prisma Migrations

In a **new terminal**:

```bash
cd server/
npm install
npx prisma migrate dev
```
docker compose up

This sets up your DB schema and generates the Prisma client.

---

## ▶️ Run the App Locally

```bash
cd server/
npm run dev
```

Then open [http://localhost:3000](http://localhost:3000)

---

## 🛠 pgAdmin Setup (Optional)

- Go to: [http://localhost:8080](http://localhost:8080)
- Login:
- **Email**: `[email protected]`
- **Password**: `admin`
- Add a server manually:
- **Host**: Use PostgreSQL container IP (get via `docker inspect`)
- **Username**: `postgres`
- **Password**: `postgres`

---

## 👤 Default Mentor Login

Use the following default login to access the mentor dashboard:

- **Email**: `[email protected]`
- **Password**: `t2tuser`

This account is created automatically on first migration.

---
2 changes: 1 addition & 1 deletion server/.env
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ BASE_URL=http://localhost:3000
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings

JWT_SECRET=hftgry5486
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/postgres?schema=public"
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/testdb?schema=public"
JWT_SECRET="thisismysecretkey"
JWT_EXPIRY="60 min"
ISSUER=http://localhost:3000
Expand Down
90 changes: 0 additions & 90 deletions server/prisma/migrations/20240827030131_init/migration.sql

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading