Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
58762bb
GitHub Classroom Feedback
github-classroom[bot] Sep 20, 2024
da01f25
Setting up GitHub Classroom Feedback
github-classroom[bot] Sep 20, 2024
ebecb30
add deadline
github-classroom[bot] Sep 20, 2024
556234f
feat(create-turbo): apply official-starter transform
turbobot-temp Sep 20, 2024
ba1cf7c
feat(create-turbo): apply pnpm-eslint transform
turbobot-temp Sep 20, 2024
fd7531f
feat(create-turbo): install dependencies
turbobot-temp Sep 20, 2024
db19038
create api-gateway and question service
javinchua Sep 20, 2024
71d6848
add shadcn
javinchua Sep 20, 2024
0db5938
update readme
javinchua Sep 21, 2024
decdaaf
add dtos and validation pipes
javinchua Sep 22, 2024
036e198
update readme
javinchua Sep 22, 2024
3ce7b3c
remove contributions
javinchua Sep 22, 2024
58dae0a
add app dependency graph (#2)
javinchua Sep 22, 2024
b827184
Add tailwind dependency to app/web (#4)
javinchua Sep 25, 2024
5770cd8
Fix tailwind not showing on frontend (#6)
javinchua Sep 25, 2024
bcc66ab
Add github workflows (#8)
javinchua Sep 27, 2024
c109833
[Questions] CRUD endpoints (#3)
jeffrey-jian Sep 27, 2024
b53e618
Add Supabase Authorization on backend (#5)
javinchua Sep 27, 2024
7645fb7
Add auth frontend (#7)
javinchua Sep 27, 2024
9c0f63e
Update pnpm version to use v9 (#11)
javinchua Sep 28, 2024
04a016f
Update package manger in package.json (#12)
javinchua Sep 28, 2024
0d5cc1b
Rename forms to PascalCase (#9)
javinchua Sep 28, 2024
5ecb636
[Questions] Add filter params for get, better exceptions (#10)
jeffrey-jian Sep 28, 2024
aed5b5a
[Questions] Initialize Questions Repository Frontend (#13)
jonyeokj Sep 29, 2024
118bba9
[Questions] Create duplicated question title hotfix (#15)
jeffrey-jian Sep 29, 2024
e706f7f
Docs: Update README.md docs on setting up (#16)
javinchua Sep 29, 2024
28bb798
[Questions] Better zod validation messages (#19)
jeffrey-jian Sep 29, 2024
b2312ec
feat: Update toast to better colours with logos (#20)
javinchua Oct 1, 2024
e2db70e
feat: filtering and sorting for questions repo
firwer Sep 29, 2024
5240690
chore: change table ui to shadcn datatable and pre-built multi-select…
firwer Oct 1, 2024
f4620fa
fix: table width keeps changing and incorrect question complexity sort
firwer Oct 1, 2024
e865822
refactor: abstract table logic and columns
firwer Oct 2, 2024
3befd91
fix: accidental removal of suspense
firwer Oct 3, 2024
a5ccbd5
fix: linter and toast
firwer Oct 3, 2024
47f99d0
fix: ui nitpick
firwer Oct 3, 2024
473844e
chore: modify category filter logic, add search box and fix sorting i…
firwer Oct 3, 2024
5490e8b
feat: add sort by category number
firwer Oct 3, 2024
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
Empty file added .github/.keep
Empty file.
102 changes: 102 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: CI

on:
push:
branches:
- main
- staging
pull_request:
types: [opened, synchronize]

jobs:
install:
name: Install Dependencies
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./project
steps:
- name: Checkout Repository
uses: actions/checkout@v4

# We un-hoist packages to ensure that each package has the necessary
# dependencies and do not rely implicitly on dependencies from other packages.
- name: Un-hoist packages
run: |
sed -i 's/node-linker=hoisted/node-linker=isolated/g' .npmrc

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV

- name: Cache turbo build setup
uses: actions/cache@v4
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-

- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: 18

- name: Install Dependencies
run: pnpm install --frozen-lockfile

lint:
name: Type Check & Lint
needs:
- install
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./project
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Un-hoist packages
run: |
sed -i 's/node-linker=hoisted/node-linker=isolated/g' .npmrc

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV

- name: Cache turbo build setup
uses: actions/cache@v4
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-

- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: 18

- name: Install Dependencies
run: pnpm install --frozen-lockfile

- name: Run type checking
run: pnpm type-check

- name: Run linting
run: pnpm lint
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[![Review Assignment Due Date](https://classroom.github.com/assets/deadline-readme-button-22041afd0340ce965d47ae6ef1cefeee28c7c493a6346c4f15d667ab976d596c.svg)](https://classroom.github.com/a/bzPrOe11)
# CS3219 Project (PeerPrep) - AY2425S1
## Group: Gxx

Expand Down
38 changes: 38 additions & 0 deletions project/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# Dependencies
node_modules
.pnp
.pnp.js

# Local env files
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

# Testing
coverage

# Turbo
.turbo

# Vercel
.vercel

# Build Outputs
.next/
out/
build
dist


# Debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Misc
.DS_Store
*.pem
Empty file added project/.npmrc
Empty file.
3 changes: 3 additions & 0 deletions project/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"singleQuote": false
}
7 changes: 7 additions & 0 deletions project/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"eslint.workingDirectories": [
{
"mode": "auto"
}
]
}
136 changes: 136 additions & 0 deletions project/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# Project

This Turborepo includes a Next.js frontend, a NestJS API gateway, and NestJS microservices, using shadcn/ui for CSS and Zod for validation.

## Layout

This Turborepo includes the following packages/apps:

### Apps

- `web`: [Next.js](https://nextjs.org/) app for the frontend
- `api-gateway`: [NestJS](https://nestjs.com/) backend serving as an entry point into microservices
- `questions-service`: [NestJS](https://nestjs.com/) backend handling all questions related functions

```mermaid
graph TD
A[Web Client] -->|HTTP Request| B(API Gateway)
B -->|RPC Call| C[Questions Service]
B -->|RPC Call| D[Other Microservice 1]
B -->|RPC Call| E[Other Microservice 2]

subgraph Microservices
C
D
E
end
```

### Packages

- `@repo/eslint-config`: `eslint` configurations (includes `eslint-config-next` and `eslint-config-prettier`)
- `@repo/typescript-config`: `tsconfig.json`s used throughout the monorepo
- `@repo/dtos`: Shared DTOs and Zod schemas
- `@repo/pipes`: Shared NestJS pipes

Each package/app is 100% [TypeScript](https://www.typescriptlang.org/).

### Utilities

- [TypeScript](https://www.typescriptlang.org/) for static type checking
- [ESLint](https://eslint.org/) for code linting
- [Prettier](https://prettier.io) for code formatting
- [TurboRepo](https://turbo.build/repo/docs) for easily managing monorepo
- [shadcn/ui](https://ui.shadcn.com/) for CSS
- [Zod](https://zod.dev/) for validation
- [TanStack Query](https://tanstack.com/query/latest/docs/framework/react/overview) for querying

## Getting Started

### Build

To build all apps and packages, run the following command:

```
pnpm build
```

### Setup Environment Variables

Each `project/apps` has a `.env` that you should create.
Copy the `.env.example` file in each of these apps to create a new `.env` file:

```bash
$ cp .env.example .env
```

Then, replace the variables accordingly.

### Develop

To develop all apps and packages, run the following command:

```
pnpm install
pnpm dev
```

## Development Guide

### Frontend Development

The frontend is located in `apps/web`. This is a Next.js application where you'll develop your user interface.

### Creating a New Microservice

To create a new microservice:

1. Navigate to the `apps` directory
2. Run the following command:
```
nest new {service} --strict --skip-git --package-manager=pnpm
```
Replace `{service}` with the name of your new microservice.

### Integrating a New Microservice

After creating a new microservice, you need to integrate it with the API gateway:

1. Register the microservice client in `api-gateway/src/api-gateway-module.ts`
2. Create a new controller within `api-gateway/src/{service}` which redirects requests to the microservice. You can follow the format of `api-gateway/src/questions/questions.controller.ts`

### Shared Packages

- `packages/dtos`: This is where we define our schemas and DTOs using Zod. These can be shared across the frontend and backend, and are used for validation pipes on the backend.
- `packages/pipes`: This is where we store pipes to be shared across NestJS apps.

### Using Shared Packages

To use packages in other packages or apps:

1. Add the package name (found in that package's `package.json`) to the `package.json` of your target app or package.
2. You can then import it in your code.

### Validation

We use Zod for validation across the project. Define your schemas in `packages/dtos`, and use them for both frontend and backend validation.

### Styling

We use shadcn/ui for CSS. Refer to the [shadcn/ui documentation](https://ui.shadcn.com/) for usage instructions.

## Best Practices

- Keep your microservices small and focused on a specific domain.
- Use the shared DTOs for consistency between frontend and backend.
- Write unit tests for your services and controllers.
- Use Zod schemas for both runtime validation and TypeScript type inference.

## Troubleshooting

If you encounter any issues:

1. Ensure all dependencies are installed with `pnpm install`
2. Check that you're using the correct Node.js version (specified in `.nvmrc`)
3. Clear your build cache with `pnpm clean`
4. If problems persist, please open an issue in the repository
2 changes: 2 additions & 0 deletions project/apps/api-gateway/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SUPABASE_URL=your-supabase-url
SUPABASE_KEY=your-supabase-key
9 changes: 9 additions & 0 deletions project/apps/api-gateway/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/** @type {import("eslint").Linter.Config} */
module.exports = {
root: true,
extends: ['@repo/eslint-config/nest.js'],
parser: '@typescript-eslint/parser',
parserOptions: {
project: true,
},
};
4 changes: 4 additions & 0 deletions project/apps/api-gateway/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "all"
}
Loading