Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
143 commits
Select commit Hold shift + click to select a range
f4d6cbe
refactored backend
erdzan12 Aug 7, 2022
3a56dd2
adapt changes
erdzan12 Aug 7, 2022
ecbd884
add votes
erdzan12 Aug 7, 2022
c4dec90
update angular and init gql in angular
erdzan12 Aug 7, 2022
aa89b71
add cards query and fieldresolvers
erdzan12 Aug 7, 2022
32932c1
add more gql
erdzan12 Aug 7, 2022
fd4b735
npm audit fix
lakhoune Aug 10, 2022
49a6581
reenable latexjs import
lakhoune Aug 10, 2022
722a7c4
npm audit
lakhoune Aug 10, 2022
6ffba45
adjust readme
lakhoune Aug 10, 2022
ca7e28b
update readme
lakhoune Aug 10, 2022
e87c0d6
fix tab not being disabled if unauthorized
lakhoune Aug 10, 2022
ee9506f
validator
erdzan12 Aug 10, 2022
1744b7b
#155
lakhoune Aug 10, 2022
17a92a1
#155
lakhoune Aug 10, 2022
cee81b9
#155
lakhoune Aug 10, 2022
62cd3cf
#155
lakhoune Aug 10, 2022
e822374
close #155
lakhoune Aug 10, 2022
bd25d60
fix bug
erdzan12 Aug 15, 2022
2697e04
rm console.log
erdzan12 Aug 15, 2022
552380a
nullable
erdzan12 Aug 15, 2022
917c785
fix adding cards in frontend
lakhoune Aug 15, 2022
f45ba76
check undefined
lakhoune Aug 15, 2022
08f4ae1
add info about redis to readme
lakhoune Aug 15, 2022
e30f0b4
ultimate format
erdzan12 Aug 15, 2022
57f2db7
add firebase login
erdzan12 Aug 17, 2022
2d28c84
migration
erdzan12 Aug 17, 2022
b73da77
rename angular-cards folder to frontend
lakhoune Aug 31, 2022
984807b
Merge pull request #180 from StudyGrow/frontend-folder-rename
lakhoune Aug 31, 2022
ec67f4b
remove old backend from root dir
lakhoune Aug 31, 2022
e31ce56
rename scripts
lakhoune Aug 31, 2022
444f03d
Merge pull request #181 from StudyGrow/remove-old-backend
lakhoune Aug 31, 2022
b56b25c
formatting
lakhoune Aug 31, 2022
0d0c9c0
fix chrome logo
lakhoune Aug 31, 2022
e3ae3ca
translate cookie banner
lakhoune Aug 31, 2022
0ba01ee
fix validator
erdzan12 Aug 31, 2022
2268de3
fix
erdzan12 Aug 31, 2022
67aea8f
remove unsibscribe
erdzan12 Aug 31, 2022
44dce78
add env doc
erdzan12 Aug 31, 2022
24c38f0
fix translation
lakhoune Aug 31, 2022
a4dc39d
Merge branch 'backend-graphql' of https://github.com/StudyGrow/Cards …
lakhoune Aug 31, 2022
7858eeb
refactor
lakhoune Aug 31, 2022
be79afa
translate sort options
lakhoune Sep 2, 2022
6923289
fix tags sorting to move cards with no tags to end
lakhoune Sep 2, 2022
538e17b
redirect to home if signup success, show welcome message after signup
lakhoune Sep 2, 2022
a0e7d98
fix logout
lakhoune Sep 2, 2022
a80d3d1
fix return value
lakhoune Sep 2, 2022
85ab5a1
remove console logs
lakhoune Sep 2, 2022
e8698a9
gitignore
lakhoune Nov 23, 2022
83570f7
backend
erdzan12 Jan 14, 2023
1fc995d
WIP
lakhoune Feb 17, 2023
840a163
working graphql generation
Feb 17, 2023
632c1ef
fix user graphql field
Feb 17, 2023
9dab296
rm lock
Feb 17, 2023
f4d6d3e
Adapt calls
Feb 17, 2023
31b472f
add generated graphql schema
lakhoune Feb 17, 2023
e938e87
Merge branch 'backend-graphql' of https://github.com/StudyGrow/Cards …
lakhoune Feb 17, 2023
a0d11ad
dont push autogenerated schema
lakhoune Feb 17, 2023
ccd847a
update readme
lakhoune Feb 17, 2023
a771256
Update auth
erdzan12 Feb 18, 2023
8f1f1d0
update readme
lakhoune Feb 19, 2023
ff75bd1
gitignore
lakhoune Feb 19, 2023
d15f133
Merge commit 'ff75bd106ff87312b86645d721d7139a858cad7b'
lakhoune Feb 19, 2023
e59d021
bump version
lakhoune Feb 19, 2023
315fe21
wip
lakhoune Feb 25, 2023
4be7652
bump angular apollo
lakhoune Feb 25, 2023
f146211
angular 15
lakhoune Feb 25, 2023
6b1f408
ng material
lakhoune Feb 25, 2023
42abde7
update angular cli
lakhoune Feb 25, 2023
4a28b68
add docker compose
lakhoune Feb 26, 2023
7da6ce5
fix bootstrap import
lakhoune Feb 26, 2023
cc62310
documentation
lakhoune Feb 26, 2023
72008d2
remove launch.json from history
lakhoune Feb 26, 2023
e0df3f8
bump ngx-quill and ng-bootstrap
lakhoune Feb 26, 2023
2f74c98
Merge pull request #184 from StudyGrow/upgrade-frontend
lakhoune Feb 27, 2023
b471639
add static serve for frontend
lakhoune Feb 27, 2023
331aab6
dockerize app
lakhoune Feb 27, 2023
bacf296
build for production
lakhoune Feb 27, 2023
c72150a
add creds to env for now
lakhoune Feb 27, 2023
ed88981
add prisma seed
lakhoune Feb 27, 2023
094b9cc
add checks on seeding
lakhoune Feb 27, 2023
9ee9cb3
documentation
lakhoune Feb 27, 2023
fe04200
docker-compose. This time without credentials ^^
lakhoune Feb 27, 2023
6e5606d
delete unused dockerfile
lakhoune Feb 27, 2023
d80d39b
workdir
lakhoune Feb 27, 2023
3b98e6d
add comment
lakhoune Feb 27, 2023
3fcb6a8
change exposed port
lakhoune Feb 27, 2023
7ce373a
fix dockerfile
lakhoune Feb 27, 2023
8551bb8
cleanup dockerfile
lakhoune Feb 27, 2023
6d49fc5
update firebase id for default user
lakhoune Feb 27, 2023
0864ac4
fixes dockerfile
lakhoune Feb 27, 2023
ffab071
Merge pull request #186 from StudyGrow/dockerize-app
lakhoune Feb 27, 2023
937cab1
fix dockerfile
lakhoune Mar 1, 2023
2734453
change permissions on docker-entrypoint file
lakhoune Mar 20, 2023
44b860f
update google icon
lakhoune Apr 11, 2023
14152aa
remove ngx cookieconsent
lakhoune Apr 11, 2023
78450a4
remove cookies section since we no longer use coookies
lakhoune Apr 11, 2023
111cc07
fix width on quill editor
lakhoune Apr 11, 2023
0899def
adjust welcome message
lakhoune Apr 11, 2023
fce2980
make safehtml pipe skip script tags
lakhoune Apr 11, 2023
dbc76fd
use safehtml pipe
lakhoune Apr 11, 2023
b45e889
remove unused code
lakhoune Apr 11, 2023
0ad837a
add translations
lakhoune Apr 11, 2023
4d682fc
error handling for login
lakhoune May 18, 2023
837f992
translate placeholder
lakhoune May 18, 2023
7feacc2
reorder interceptors
lakhoune May 18, 2023
1ac8b87
fix signin redirect, closes #191
lakhoune May 27, 2023
055fb40
fix signin redirect, closes #191
lakhoune May 27, 2023
c6ede92
Merge branch 'ng-16' into release/2.0.0
lakhoune Jun 7, 2023
090e148
translate notifications
lakhoune Jun 7, 2023
a82a9bc
Merge branch 'lakhoune/issue193' into release/2.0.0
lakhoune Jun 7, 2023
37c9900
Feature: Update github action
erdzan12 Jun 8, 2023
b7b33ab
Fix: args
erdzan12 Jun 8, 2023
cd9a1af
Fix: args
erdzan12 Jun 8, 2023
1b8c555
Fix: Dockerfile
erdzan12 Jun 8, 2023
ede0678
Fix: Action
erdzan12 Jun 8, 2023
14e97b1
Fix: stack file path
erdzan12 Jun 8, 2023
56ed29d
Fix: Build for arm
erdzan12 Jun 8, 2023
a334157
Fix: Make cards query public
erdzan12 Jun 8, 2023
5aad09a
Fix: Make cards query public
erdzan12 Jun 8, 2023
20b51f3
Fix: Use never version
erdzan12 Jun 8, 2023
7a63ead
try
erdzan12 Jun 8, 2023
1070d37
Merge remote-tracking branch 'origin/release/2.0.0' into feature-state
lakhoune Jun 8, 2023
99ea6d5
Fix: @Public()
erdzan12 Jun 8, 2023
627e33f
Merge commit '99ea6d5b0c74020739326a71cf63e0d9f70f7262' into feature-…
lakhoune Jun 8, 2023
31c85ce
Fix: Public
erdzan12 Jun 8, 2023
593be8a
Merge commit '31c85ce2f5d55425ea24c5fdddcbce2e54b1a32b' into feature-…
lakhoune Jun 8, 2023
1512407
transform carouselstate to feature state
lakhoune Jun 8, 2023
667286d
handle like count
lakhoune Jun 8, 2023
3443eaa
Merge branch 'feature-state' into release/2.0.0
lakhoune Jun 8, 2023
44a2760
show rejection if user wants to go to previous card on first card
lakhoune Jun 8, 2023
45d225a
nullable
lakhoune Jun 8, 2023
e9f29e9
Feature: Seed db and schema update
erdzan12 Jun 8, 2023
c36bcb6
fix selector
lakhoune Jun 8, 2023
5f9f75c
Merge branch 'release/2.0.0' of https://github.com/StudyGrow/Cards in…
lakhoune Jun 8, 2023
38a48b6
sst
lakhoune Jun 8, 2023
f68315f
closes #194
lakhoune Jun 8, 2023
55b35fd
remove checkbox, disable google sign in
lakhoune Jun 8, 2023
8cfca74
Update README.md
lakhoune Jun 8, 2023
9947232
Merge remote-tracking branch 'origin/lakhoune-patch-1' into release/2…
lakhoune Jun 9, 2023
4cb3507
update datareducer keys
lakhoune Jun 9, 2023
3e4ac3b
restructure application state
lakhoune Jun 9, 2023
aa889cf
update reducer for new state structure
lakhoune Jun 9, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**/node_modules
**/dist
66 changes: 52 additions & 14 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,61 @@ name: Deploy
on:
push:
branches:
- main
- release/2.0.0

jobs:
# test-angular-build:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - run: cd angular-cards
# - run: npm i
# - run: npm run build
build:
runs-on: ubuntu-latest
# needs: test-angular-build

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/cards:latest
platforms: linux/arm64 # This is added for building image for arm64 architecture
build-args: |
DB_URL: ${{ secrets.DB_URL }}
JWT_SECRET: ${{ secrets.JWT_SECRET }}
FIREBASE_TYPE: ${{ secrets.FIREBASE_TYPE }}
FIREBASE_PROJECT_ID: ${{ secrets.FIREBASE_PROJECT_ID }}
PRIVATE_KEY_ID: ${{ secrets.PRIVATE_KEY_ID }}
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
CLIENT_EMAIL: ${{ secrets.CLIENT_EMAIL }}
CLIENT_ID: ${{ secrets.CLIENT_ID }}
AUTH_URI: ${{ secrets.AUTH_URI }}
TOKEN_URI: ${{ secrets.TOKEN_URI }}
AUTH_PROVIDER_X509_CERT_URL: ${{ secrets.AUTH_PROVIDER_X509_CERT_URL }}
CLIENT_X509_CERT_URL: ${{ secrets.CLIENT_X509_CERT_URL }}

deploy:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v2
- uses: akhileshns/heroku-deploy@v3.12.12 # This is the action
- name: Checkout codebase
uses: actions/checkout@v2

- name: Deploy
uses: kitconcept/docker-stack-deploy@v1.0.1
with:
heroku_api_key: ${{secrets.HEROKU_API_KEY}}
heroku_app_name: ${{secrets.APP_NAME_HEROKU}}
heroku_email: "jungerjunge2@gmail.com"
registry: "docker.io"
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
remote_host: ${{ secrets.REMOTE_HOST }}
remote_user: ${{ secrets.REMOTE_USER }}
remote_private_key: ${{ secrets.REMOTE_PRIVATE_KEY }}
stack_file: "/home/ubuntu/StudyGrow/Cards/stack.yml"
stack_name: "cards"
14 changes: 11 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
/node_modules
.env
.DS_Store
.vscode
.vscode
backend/firebase-admin.json
node_modules
angular-cards/.angular/cache
angular-cards/dist
.env
backend/src/schema.graphql
backend/package-lock.json
backend/yarn.lock

.vscode/launch.json
30 changes: 0 additions & 30 deletions .vscode/launch.json

This file was deleted.

99 changes: 99 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Building layer
FROM node:16-alpine as build

# Add these lines at the top of your Dockerfile
ARG DB_URL

ARG JWT_SECRET

ARG FIREBASE_TYPE
ARG FIREBASE_PROJECT_ID
ARG PRIVATE_KEY_ID
ARG PRIVATE_KEY
ARG CLIENT_EMAIL
ARG CLIENT_ID
ARG AUTH_URI
ARG TOKEN_URI
ARG AUTH_PROVIDER_X509_CERT_URL
ARG CLIENT_X509_CERT_URL

# And then use them like this
ENV DB_URL=${DB_URL}

ENV JWT_SECRET=${JWT_SECRET}

ENV FIREBASE_TYPE=${FIREBASE_TYPE}
ENV FIREBASE_PROJECT_ID=${FIREBASE_PROJECT_ID}
ENV PRIVATE_KEY_ID=${PRIVATE_KEY_ID}
ENV PRIVATE_KEY=${PRIVATE_KEY}
ENV CLIENT_EMAIL=${CLIENT_EMAIL}
ENV CLIENT_ID=${CLIENT_ID}
ENV AUTH_URI=${AUTH_URI}
ENV TOKEN_URI=${TOKEN_URI}
ENV AUTH_PROVIDER_X509_CERT_URL=${AUTH_PROVIDER_X509_CERT_URL}
ENV CLIENT_X509_CERT_URL=${CLIENT_X509_CERT_URL}


WORKDIR /app

COPY . .

# _________________________________________________________ Backend _________________________________________________________
WORKDIR /app/backend

RUN npm i --force

RUN npm run build

# _________________________________________________________ Frontend _________________________________________________________

WORKDIR /app/frontend

RUN npm i --force

RUN npm run build:prod

# _________________________________________________________ Step 2: Production _________________________________________________________
# Runtime (production) layer
FROM node:16-alpine as production

# install dos2unix (for docker-entrypoint.sh)
RUN apk add --no-cache dos2unix

# ___________________________________________________________ Backend _____________________________________________________________

WORKDIR /app/backend

# Copy backend files
COPY ./backend .

# replace localhost with db (docker-compose service name for db container) Note: this might also replace localhost in other places in the .env file
# RUN sed -i 's/localhost/db/g' .env

# Install runtime dependecies (without dev/test dependecies)
RUN npm i --only=production --force

# Copy backend build
COPY --from=build /app/backend/dist/ ./dist/

# ___________________________________________________________ Frontend _____________________________________________________________
# Frontend served under /app/backend/frontend/dist/frontend/*
RUN mkdir -p /app/backend/frontend

# Copy frontend build files
# Note that they will be
COPY --from=build /app/frontend ./frontend/

# ___________________________________________________________ Step 3: Entrypoint _________________________________________________________

WORKDIR /app

COPY ./docker-entrypoint.sh /app

RUN dos2unix /app/docker-entrypoint.sh
RUN chmod +x /app/docker-entrypoint.sh

# Expose application port
EXPOSE 4444

ENTRYPOINT [ "/app/docker-entrypoint.sh" ]
118 changes: 84 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,79 +1,129 @@
# Cards Project

This project provides the code for frontend and backend of our cards website currently hosted on <https://studygrow-cards.herokuapp.com/>
This project provides the code for frontend and backend of our cards website currently hosted on <https://cards.leier.lu/>

## Getting Started

To test this project locally you should clone this repository.

### Prerequisites
## Prerequisites

To run this project you need to have the Node Package Manager installed, which can be downloaded here: <https://www.npmjs.com/get-npm/>

Additionally, following environment variables should be present:
PORT=
APP_AUTH_SECRET=
APP_AUTH_GOOGLE_CLIENTID=
APP_AUTH_GOOGLE_SECRET=
APP_AUTH_GOOGLE_REDIRECT_URI=
MONGO_URL_PRODUCTION=
MONGO_URL_TEST=
SECRET=
AUTH_TOKEN_EXPIRATION=
REFRESH_TOKEN_EXPIRATION=
### Backend

### Installing

Using the command line navigate to the projects folder and type in the following command:
Using the command line navigate to the `./backend` folder and run:

```shell
npm install
```

npm will install all the dependencies for you. After that use the following command to start the server:
Additionally, some environment variables should be contained in the `backend/.env` file. Here is an example with some default values:

```.env
DB_USER=postgres
DB_PASSWORD=mysecretpassword
DB_PORT=5432
DB_HOST=localhost:${DB_PORT}
DB_NAME=studycards
DB_SCHEMA=studycards
# DB_URL=postgresql://${DB_USER}:${DB_PASSWORD}@${DB_HOST}/${DB_NAME}?schema=${DB_SCHEMA}&sslmode=prefer
DB_URL=postgresql://postgres:mysecretpassword@localhost:5432/studycards?schema=studycards&sslmode=prefer
JWT_SECRET=myJWTsecret
PORT=4444
HOST=localhost

# Firebase config
FIREBASE_TYPE=service_account
FIREBASE_PROJECT_ID=
PRIVATE_KEY_ID=
PRIVATE_KEY=
CLIENT_EMAIL=
CLIENT_ID=
AUTH_URI=
TOKEN_URI=
AUTH_PROVIDER_X509_CERT_URL=
CLIENT_X509_CERT_URL=
```

```shell
npm run watch
docker run --name some-postgres -p 5432:5432 -e POSTGRES_PASSWORD=mysecretpassword -e POSTGRES_DB=studycards -d postgres
```

The server will tell you on which port it will be running in the console (80 by default). Navigate to `http://localhost:port`, where port is the port provdided by the server.
```shell
npx prisma db push
```

## Modifiying the frontend
```shell
npx prisma generate
```

The frontend is built using Angular. The Angular project folder is located in angular-cards. Download and install Angular with:
If you want to have some sample data, you can run

```shell
npx prisma db seed
```

### Frontend

Download and install Angular with:

```shell
npm install -g @angular/cli
```

Then navigate to the angular-cards folder and start the Angular Dev Server with the following command:
Navigate to `./frontend`. Run:

```shell
npm install
```

## Starting the backend

The database is started using the following command:

```bash
docker run --name some-postgres -p 5432:5432 -e POSTGRES_PASSWORD=mysecretpassword -e POSTGRES_DB=studycards -d postgres
```

After that use the following command to start the server:

```shell
ng serve --proxy-config proxy.conf.json --open
npm run start
```

We use proxy config to bypass CORS problem, caused by angular, when communicating with our server.\
A graphql playground is available at `localhost:4444/graphql`

## Starting the frontend

Navigate to the frontend folder and start the Angular Dev Server with the following command:

```shell
npm run start
```

We use proxy config to bypass CORS problem, caused by angular, when communicating with our server.

## Building for production

After you are done modifying the frontend you can use the following command to build your project:

```shell
ng build
npm run build
```

After the process has finished you can stop the Angular Dev Server and navigate to `http://localhost:port`, where port is the port provdided by the server.

## Built With

- [MongoDB](https://www.mongodb.com/) - Database
- [Express](https://expressjs.com/) - Middleware for handling HTTP requests
- [PostgreSQL](https://www.postgresql.org/) - Database
- [NestJS](https://expressjs.com/) - Backend
- [Prisma](https://www.prisma.io/) - database toolkit
- [GraphQL](https://graphql.org/) query language
- [Angular](https://angular.io/) - Frontend
- [NodeJs](https://nodejs.org/) - Backend Server
- [Passport](http://www.passportjs.org/) - Middleware for Authentication
- and much more

## Authors

- **Erdzan Rastoder** - _Original idea, Initial work_ - [Github](https://github.com/orgs/StudyGrow/people/erdzan12)
- **Ben Lakhoune** - _Initial work_ - [Github](https://github.com/lakhoune) - [Website](http://lakhoune.com)
- **Erdzan Rastoder** - _Original idea, Initial work_, _Maintainer_ - [Github](https://github.com/orgs/StudyGrow/people/erdzan12)
- **Ben Lakhoune** - _Initial work_, _Maintainer_ - [Github](https://github.com/lakhoune) - [Website](http://lakhoune.com)

## License

Expand Down
Loading