Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(repo): update "Getting started" in the README.md #668

Merged
merged 10 commits into from
Aug 22, 2023
145 changes: 143 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ and say hi to us at #kampus-projects channel.

## Getting started

### 1. Cloning the project

- Fork `kamp-us/monorepo` under your personal account.
- eg: `usirin/monorepo`
- Clone the project to your local computer:
Expand All @@ -28,6 +30,147 @@ git clone [email protected]:kamp-us/monorepo.git
cd monorepo
```

- Install dependencies.

```sh
npm install
emredevsalot marked this conversation as resolved.
Show resolved Hide resolved
```

### 2. Modifying `hosts` file

- Add the following text block to [your `/etc/hosts` file](https://www.howtogeek.com/27350/beginner-geek-how-to-edit-your-hosts-file/).

```text
127.0.0.1 localhost.kamp.us
127.0.0.1 pasaport.localhost.kamp.us
127.0.0.1 pano.localhost.kamp.us
127.0.0.1 sozluk.localhost.kamp.us
127.0.0.1 gql.localhost.kamp.us
```

### 3. Setting up `.env` files

- Duplicate `.env.example` files and rename them as `.env` in the following folders: `db/prisma`, `apps/gql`, `apps/kampus`, `apps/pasaport`.

### 4. Prisma Setup and Database Configuration

- Move to `db/prisma` folder.

```sh
cd db/prisma
```

- Start the image. (You should have docker installed.)

```sh
docker-compose up -d
```

- Generate artifacts. (e.g. Prisma Client)

```sh
npm run prisma:generate
```

- Push the Prisma schema state to the database.

```sh
npm run prisma:push
```

- Run seed command to fill database with demo data.

```sh
npm run prisma:seed
```

### 5. Running dev servers

- Run the command below at the root folder.

```sh
# Runs "gql", "kampus" and "pasaport" apps so the platform can be alive with 1 command.
npm run web
```

- Now you can go to [localhost.kamp.us:3000](localhost.kamp.us:3000) to see it live. 🚀

```sh
# Runs all "dev" commands on each package inside the workspace
npm run dev
```

```sh
# Runs only "gql" server so backend work can be done separetly.
npm run gql
```

### 6. Logging in on development server(optional)

#### 6.1 GitHub

- Go to [OAuth Apps page](https://github.com/settings/developers) on GitHub.
emredevsalot marked this conversation as resolved.
Show resolved Hide resolved
- Click on `New OAuth App`.
- Application name: "you can choose any name"
- Homepage URL: http://pasaport.localhost.kamp.us:3001/
- Authorization callback URL: http://pasaport.localhost.kamp.us:3001/auth/callback/github
- Click on `Register Application`.
- On the application page, click on `Generate a new client secret`.
- Make the following changes to the corresponding files.

```sh
# apps/kampus, apps/pasaport
GITHUB_ID=<Your_Client_ID>
GITHUB_SECRET=<Your_Client_Secret>
```

- Now you can use `Sign in with GitHub` on development server.

<!---

#### 6.2 Discord

- Go to [Applications page](https://discord.com/developers/applications) on Discord.
- Click on `New Application`.
- Name: "you can choose any name"
- Click on `Create`.
- Go to `OAuth2` on the left sidebar.
- Click on `Reset Secret` to generate secret key.
- Click on `Add Redirect` and enter `http://pasaport.localhost.kamp.us:3001/auth/callback/discord`
- Save changes.
- Make the following changes to the corresponding files.

```sh
# apps/kampus, apps/pasaport
DISCORD_ID=<Your_Client_ID>
DISCORD_SECRET=<Your_Client_Secret>
```

- Now you can use `Sign in with Discord` on development server.

#### 6.3 Twitch

- Go to [Developer Applications page](https://dev.twitch.tv/console/apps) on Twitch.
- Click on `Register Your Application`.
- Name: "you can choose any name"
- OAuth Redirect URLs: https://pasaport.localhost.kamp.us:3001/auth/callback/twitch
emredevsalot marked this conversation as resolved.
Show resolved Hide resolved
- Category: Website Integration
- Click on `Create`.
- Click on `Manage` for your application.
- Click on `New Secret`.

- Make the following changes to the corresponding files.

```sh
# apps/kampus, apps/pasaport
TWITCH_ID=<Your_Client_ID>
TWITCH_SECRET=<Your_Client_Secret>
```

- Now you can use `Sign in with Twitch` on development server.

-->

## Structure

- `/apps`: services & apps
Expand All @@ -37,8 +180,6 @@ cd monorepo

These folders are [registered as workspaces in package.json](package.json#L4-L7)

## Running the projects

## Use Correct Node Version

If you haven't already install [Volta](https://volta.sh), you can install install it with:
Expand Down
2 changes: 1 addition & 1 deletion apps/gql/.env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
NODE_ENV=development
DATABASE_URL=mysql://kampus:kampus@localhost:3306/kampus?schema=public
NEXTAUTH_URL=http://localhost:3001/auth
NEXTAUTH_URL=http://pasaport.localhost.kamp.us:3001/auth
6 changes: 3 additions & 3 deletions apps/kampus/.env.example
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# update with the url after running `npm run dev` under `apps/gql`
NEXT_PUBLIC_GQL_URL=http://localhost:4000/graphql
NEXTAUTH_URL=http://localhost:3001/auth
NEXT_PUBLIC_GQL_URL=http://gql.localhost.kamp.us:4000/graphql
NEXTAUTH_URL=http://pasaport.localhost.kamp.us:3001/auth
DATABASE_URL=mysql://root:kampus@localhost:3306/kampus
AUTH_COOKIE_DOMAIN=''
AUTH_COOKIE_DOMAIN='.localhost.kamp.us'
GITHUB_ID=''
GITHUB_SECRET=''
DISCORD_ID=''
Expand Down
4 changes: 2 additions & 2 deletions apps/pasaport/.env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
NODE_ENV=development
NEXTAUTH_URL=http://localhost:3001/auth
NEXTAUTH_URL=http://pasaport.localhost.kamp.us:3001/auth
DATABASE_URL=mysql://root:kampus@localhost:3306/kampus
AUTH_COOKIE_DOMAIN=''
AUTH_COOKIE_DOMAIN='.localhost.kamp.us'
GITHUB_ID=''
GITHUB_SECRET=''
DISCORD_ID=''
Expand Down