Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/chrisvilches/learn

Learning app. Generates math problems and tests your skills.
https://github.com/chrisvilches/learn

nestjs online-judge react typescript

Last synced: 2 months ago
JSON representation

Learning app. Generates math problems and tests your skills.

Awesome Lists containing this project

README

        

# Learn App

[![Netlify Status](https://api.netlify.com/api/v1/badges/4181054b-f24b-4bb3-8124-bd493304b60e/deploy-status)](https://app.netlify.com/sites/chrisvilches-learn/deploys)

Learning app. Generates math problems and tests your skills.

It works similar to an online judge. Problems are generated based on chosen topic.

Made with TypeScript, NestJS and React.

## Deployment

### Frontend App (React)

Example of how to set environment variables:

```sh
VITE_BASE_URL=http://localhost:3000 npm run dev
```

### Web App (NestJS)

Example of how to deploy using Docker.

Setup database:

```sh
DATABASE_URL=postgresql://postgres:[email protected]:5432/learn_dev?schema=public
SECRET_KEY=abcdefghijkl

docker build --target db -t learn-db-setup .
docker run --rm --env DATABASE_URL=$DATABASE_URL --network=custom_network1 learn-db-setup
```

Run app:

```sh
docker build --target app -t learn-app .
docker run -dit -p 3007:3000 --env ALLOW_HOST=https://learn.chrisvilches.com --env DATABASE_URL=$DATABASE_URL --env SECRET_KEY=$SECRET_KEY --network=custom_network1 --name learn learn-app
```

## Testing

### `problem-generator` unit tests

Make sure to pass the `PYTHON_CMD` (Python interpreter path) environment variable:

```sh
PYTHON_CMD=/usr/bin/python3 npm run test --prefix ./packages/problem-generator
```

### `webapp` unit tests and integration tests

For unit tests, run (on `./packages/webapp`):

```sh
npm run test
```

For integration tests, make sure Docker (at least version 24.0.7) is installed.

Compile the `problem-generator` package:

```sh
npm run build --prefix ./packages/problem-generator/
```

Run:

```sh
npm run test:e2e --prefix ./packages/webapp/
```

## Troubleshooting

### Use `ts-node`, not `tsx` for scripts

Using `tsx` for some reason doesn't inject dependencies correctly (they become `undefined` and crashes).

This may be related to decorator related configurations when compiling and executing TS code. Since dependency injection uses reflection, decorators and metadata are necessary, and `tsx` may be omitting that.