40 lines
1.9 KiB
Markdown
40 lines
1.9 KiB
Markdown
# Sample web application
|
|
|
|

|
|
|
|
## Minimal 3 tier web application
|
|
- **React frontend:** Uses react query to load data from the two apis and display the result
|
|
- **Node JS and Golang APIs:** Both have `/` and `/ping` endpoints. `/` queries the Database for the current time, and `/ping` returns `pong`
|
|
- **Postgres Database:** An empty PostgreSQL database with no tables or data. Used to show how to set up connectivity. The API applications execute `SELECT NOW() as now;` to determine the current time to return.
|
|
|
|

|
|
|
|
## Running the Application
|
|
|
|
While the whole point of this course is that you probably won't want/need to run the application locally (See: `11-development-workflow`), we can do so as a starting point.
|
|
|
|
The `Makefile` contains the commands to start each application.
|
|
|
|
### Postgres
|
|
|
|
It's way more convenient to run postgres in a container as we saw in `04-using-3rd-party-containers`, so we will do that.
|
|
|
|
`make run-postgres` will start postgres in a container and publish port 5432 from the container to your localhost.
|
|
|
|
### api-node
|
|
|
|
To run the node api you will need to run `npm install` to install the dependencies (I used node `v19.4.0` and npm `v9.2.0`).
|
|
|
|
After installing the dependencies, `make run-api-node` will run the api in development mode with nodemon for restarting the app when you make source code changes.
|
|
|
|
### api-golang
|
|
|
|
To run the golang api you will need to run `go mod download` to download and install the dependencies (I used `go1.19.1`)
|
|
|
|
After installing the dependencies, `make run-api-golang` will build and run the api.
|
|
|
|
### client-react
|
|
|
|
Like `api-node`, you will first need to install the dependencies with `npm install` (again, I used node `v19.4.0` and npm `v9.2.0`)
|
|
|
|
After installing the dependencies, `make run-client-react` will use vite to run the react app in development mode. |