# FreeStuff

Give away free stuff to charities and those in need

## Development environment
- Docker Development Environment (backed by docker compose) for isolated dev infra
- VSCode for an IDE connected to the dev containers
- Standard JS for linting and formatting
- Local testing (TBD)
- Git branching startegy (TBD)
- CI/CD strategy (TBD)

## App structure
- Postgres database
- S3-compatible blobstore 
- Redis cache
- App server running Express with server-side rendering
- Pug templating engine
- SASS stylesheets
- Native JS

## Deployment infrastructure (TBD)
- Digital ocean (compose/swarm/manual config)
- Dev/Staging/Prod environments
- Incremental rollout
- Autoscaling
- Backups
- Alerts

## Getting started

### Prerequisites
- Install Docker Desktop
- Install VS Code
- Install TablePlus

### Setup Docker Dev Environment
Fork the GitHub repo to your own account. In Docker Desktop, create a Dev Environment using your git repo URL (https://github.com/your-username/freestuff).

Open the `app` container in VSCode from Docker Dev, then enter the `app` folder.

```sh
cd app
```

Install the necessary NodeJS dependencies.
```sh
npm install
```

### Setting up SGID
Create a new application at the [SGID Developer Portal](https://developer.id.gov.sg/), and use `http://localhost:1337/login` for the redirection URI.
Using the downloaded SGID credentials, create a `.env` file and populate it with the necessary SGID environment variables.

```sh
export SGID_CLIENT_ID="<your-sgid-client-id>"
export SGID_CLIENT_SECRET="<your-sgid-client-secret>"
export SGID_PRIVATE_KEY="<your-sgid-private-key>"
export SGID_REDIRECT_URI="http://localhost:1337/login"
```

Override the dummy SGID environment variables in `compose-dev.yml` with
```sh
source .env
```

### Start your dev server
Start your app server in the VSCode terminal.

```sh
npm run dev
```
The application should be accessible at http://localhost:1337.