With "react-query-demo", you can browse through fictional posts made by fictional users, explore by tags, and create your own post. Main features are infinite scrolling, pagination, and skeleton loading. The app follows a design similar to Dev.to or other developer blogs, but with a much simpler data model.
- React: A JavaScript library for building user interfaces
- Bootstrap: A popular CSS framework for responsive web design
- Tanstack Query: A powerful state management solution for React, used to be called React-Query
- Faker.js: A library for creating all kinds of test data which I use to seed the database
- Typescript: A statically typed superset of JavaScript that compiles to plain JavaScript
- Express: A web application framework for Node.js
- Prisma ORM: A modern database toolkit that allows you to query your database using a type-safe and intuitive API
- PostgreSQL: A powerful, open source object-relational database system
- Browse through posts made by users, sorted by tags
- Create your own post
- Infinite scrolling
- Pagination
- Skeleton loading
- seeding the database using Faker.js
- the main list of posts (PostList) uses infinite scroll (fetches automatically when scrolling)
- you can read a post (PostDetails)
- or get all posts with tag (PostListByTag)
- uses pagination
- or get a user's details and their posts (UserDetails)
- after writing a post, the user is redirected to the post details page and the post data is read directly from cache / no refetching
This project is currently unmaintained, but it still works when run locally. There is no live demo hosted at the moment.
To run the project locally, follow these steps:
-
Clone the repository
-
Starting the database
- Make sure you have a
.env
file in thebackend/
directory with the following content (has to match the connection data defined in thedocker-compose.yml
file):
DATABASE_URL="postgresql://postgres:mysecret@localhost:5432/postgres?schema=public" PORT=7000
- Start the database using
docker-compose up
- Make sure you have a
-
Preparing the backend and database (if you are starting the project for the first time)
cd backend/
- Install dependencies using
npm install
- Migrate db schema using
npx prisma migrate dev --name init
- Seed the database using
npx prisma db seed
-
Start the backend using
npm run dev
-
Starting the frontend
cd frontend/
- Make sure you have a
.env
file in thefrontend/
directory with the following content (has to match the port defined earlier in/backend/.env
):
VITE_API_BASE_URL="localhost:7000"
-
npm run dev
-
Open your browser and navigate to the url given in the console output by Vite (probably
http://localhost:5173
) -
You can now explore the app, and even use the React Query Devtools (bottom left corner) to explore the state of the app