Skip to content

Commit 94d036f

Browse files
authored
docs: provides instructions on running and configuring the demos. (#675)
1 parent 858ff49 commit 94d036f

File tree

8 files changed

+92
-22
lines changed

8 files changed

+92
-22
lines changed
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CLERK_PERISHABLE_KEY=perishable key from clerk
2+
CLERK_SECRET_KEY=secret key from clerk
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
CLERK_PERISHABLE_KEY=perishable key from clerk
2+
CLERK_SECRET_KEY=secret key from clerk
3+
REDIS_HOST=Redis database host (probably from upstash)
4+
REDIS_PORT=Redis database prt
5+
REDIS_PASSWORD=Redis database password

lib/java/fullstack_demo/README.md

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Full-stack App Demo
2+
3+
## Purpose
4+
5+
This project demonstrates a fully working task management app built using React, TypeScript, and Java. The app is deployed live on Fly.io at https://fullstack-demo-cold-breeze-8913.fly.dev/.
6+
7+
## Running the app
8+
9+
To run the app, you'll first need to configure the Java web server. Copy the [.env.development](./.env.development) file to `.env` and set up the Clerk keys by setting up an account at https://clerk.dev. Once done, you can start the server using the following command
10+
11+
```bash
12+
./gradlew bootRun
13+
```
14+
15+
You can access the site at https://localhost:8080.
16+
17+
If you want to test changes to the frontend client code, it would be easier to run the frontend react site separate. Navigate to [src/main/frontend](./src/main/frontend/) and run the React website as normal:
18+
19+
```bash
20+
npm run dev
21+
```
22+
23+
## Architecture
24+
25+
The app is built using the React library running on a Java web server. The homepage is located at [src/main/frontend/src/App.tsx](./src/main/frontend/src/App.tsx) and contains the main `TodoApp` component.
26+
27+
The `TodoApp` component and sub-components uses `fetch` to get data from the backend API which is located at [TodosController.java](./src/main/java/com/codedifferently/fullstack_demo/controller/TodosController.java).
28+
29+
The backend API gets a repository instance from a bean configured at [RepositoryConfiguration.java](./src/main/java/com/codedifferently/fullstack_demo/repository/RepositoryConfiguration.java), using an environment variable to choose between a JSON repository implementation or a Redis version. For more on the repository pattern, [see this article on Medium](https://medium.com/@pererikbergman/repository-design-pattern-e28c0f3e4a30).
30+
31+
## Connecting to Redis
32+
33+
By default, the app is configured to store data an in-memory which gets cleared out as soon as the web server is shut down or restarts. You can connect it to a Redis database by creating one at Upstash or on Vercel (called Upstash KV). Then, uncomment the commented out lines in [application.yml](./src/main/resources/application.yml) and update your `.env` file.
34+
35+
## Deploying live
36+
37+
To deploy this app, sign up for an account on Fly.io and create a project pointing to your fork of this repo. You can run the `./gradlew build` to build the app and then use `fly deploy` utility command to deploy the Java web server to production. Fly.io leverages the [Dockerfile](./Dockerfile) config to run the web server.
38+
39+
## Tools
40+
41+
Here are a list of tools used to compile this demo. You can read the official documentation to learn how various aspects of the demo function.
42+
43+
* React (https://react.dev)
44+
* Java Spring Boot (https://spring.io/projects/spring-boot)
45+
* Java Spring MVC (https://spring.io/guides/gs/serving-web-content)
46+
* Upstash Redis (https://upstash.com/docs/redis/overall/getstarted)
47+
* Fly.io (https://fly.io)
48+
* Docker (https://docs.docker.com/build/concepts/dockerfile/)

lib/java/fullstack_demo/src/main/frontend/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
"version": "0.0.0",
55
"type": "module",
66
"scripts": {
7-
"dev": "vite",
7+
"dev": "NODE_ENV=development vite",
88
"build": "tsc -b && NODE_ENV=production vite build",
99
"lint": "eslint .",
10-
"preview": "vite preview"
10+
"preview": "NODE_ENV=production vite preview"
1111
},
1212
"dependencies": {
1313
"@clerk/clerk-react": "^5.17.1",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=Your Next Public Clerk Publishable Key here
2+
CLERK_SECRET_KEY=Your Clerk Secret Key here
3+
DB_TYPE=in-memory
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=Your Next Public Clerk Publishable Key here
2+
CLERK_SECRET_KEY=Your Clerk Secret Key here
3+
DB_TYPE=redis
4+
KV_REST_API_TOKEN=Your Redis api token here
5+
KV_REST_API_URL=Your Redis database URL

lib/typescript/fullstack_demo/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ yarn-error.log*
3131

3232
# env files (can opt-in for committing if needed)
3333
.env*
34+
!.env.example
35+
!.env.example.*
3436

3537
# vercel
3638
.vercel
+25-20
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,41 @@
1-
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
1+
# Full-stack App Demo
22

3-
## Getting Started
3+
## Purpose
44

5-
First, run the development server:
5+
This project demonstrates a fully working task management app built using NextJS and TypeScript. The app is deployed live on Vercel at https://code-differently-24-q4.vercel.app/
6+
7+
## Running the app
8+
9+
To run the app, copy the [.env.example](./.env.example) file as `.env` and setup the Clerk keys by setting up an account at https://clerk.dev. Once done, you can start up the local dev server with the following commands:
610

711
```bash
12+
npm install
813
npm run dev
9-
# or
10-
yarn dev
11-
# or
12-
pnpm dev
13-
# or
14-
bun dev
1514
```
1615

17-
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
16+
## Architecture
17+
18+
The app is built using the React library running on the NextJS framework. The homepage is located at [src/app/page.tsx](./src/app/page.tsx) and contains the main `TodoApp` component.
1819

19-
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
20+
The `TodoApp` component and sub-components uses `fetch` to get data from the backend API which is located at [src/app/api/todos/route.ts](./src/app/api/todos/route.ts).
2021

21-
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
22+
The backend API gets a repository instance from [src/repositories/index.ts](./src/repositories/index.ts), using an environment variable to choose between a JSON repository implementation or a Redis version. For more on the repository pattern, [see this article on Medium](https://medium.com/@pererikbergman/repository-design-pattern-e28c0f3e4a30).
2223

23-
## Learn More
24+
## Connecting to Redis
2425

25-
To learn more about Next.js, take a look at the following resources:
26+
By default, the app is configured to store data on the web server in a JSON file (./src/repositories/db.json). You can connect it to a Redis database by creating one on Vercel (called Upstash KV). Then, set the `DB_TYPE` to `redis` in the `.env` file and configure the additional config keys listed in `.env.example.redis`.
2627

27-
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
28-
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
28+
## Deploying live
2929

30-
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
30+
To deploy this app, sign up for an account on Vercel and create a project pointing to your fork of this repo. You'll need to configure the environment variables you setup in your local `.env` file using the Vercel UI.
3131

32-
## Deploy on Vercel
32+
## Tools
3333

34-
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
34+
Here are a list of tools used to compile this demo. You can read the official documentation to learn how various aspects of the demo function.
3535

36-
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
36+
* NextJS (https://nextjs.org)
37+
* Vercel (https://vercel.com)
38+
* Clerk (https://clerk.dev)
39+
* React (https://react.dev)
40+
* LowDB (https://github.com/typicode/lowdb)
41+
* Upstash Redis (https://upstash.com/docs/redis/overall/getstarted)

0 commit comments

Comments
 (0)