A small full-stack project for learning and practicing TanStack React Query with a Django REST API.
This repository includes a backend API for managing advertisements and a frontend React app that demonstrates fetching, caching, pagination, infinite scrolling, create/update/delete flows, and optimistic updates using React Query.
- Fetch and display ads from a Django API
- Server state caching with TanStack React Query
- Pagination and infinite scrolling
- Create, update, and delete ads
- Optimistic UI updates
- Basic search and ad-type filtering
- Real backend integration with SQLite database
- React
- TypeScript
- Vite
- TanStack React Query
- React Hook Form
- Django
- Django REST Framework
- SQLite
- django-cors-headers
- django-filter
react-query-course/
├── back/
│ ├── ads/
│ ├── queries/
│ ├── media/
│ ├── db.sqlite3
│ ├── manage.py
│ └── requirements.txt
├── front/
│ └── react query/
│ ├── src/
│ ├── package.json
│ ├── vite.config.ts
│ └── index.html
├── README.md
└── .gitignoreBefore running the project, make sure you have installed:
- Node.js 18+
- npm or yarn
- Python 3.10+
- pip
Open a terminal in the back folder:
cd back
python -m venv .venv.venv\Scripts\activatesource .venv/bin/activateThen install the dependencies:
pip install -r requirements.txtApply database migrations:
python manage.py migrateCreate a superuser if you want to access Django admin:
python manage.py createsuperuserRun the backend server:
python manage.py runserverThe API will be available at:
- http://127.0.0.1:8000
- http://127.0.0.1:8000/ads/advertises/
- http://127.0.0.1:8000/ads/advertises/paged/
Open a new terminal in the frontend folder:
cd "front/react query"Install dependencies:
npm installStart the app:
npm run devBy default, Vite runs on:
To run the frontend on a specific port, for example 3000:
npm run dev -- --port 3000The backend exposes a Django REST API for advertisements with actions such as:
- List ads
- Filter by ad type
- Search ads by title
- Paginated ads listing
- Create a new ad
- Update an ad
- Delete an ad
- The frontend expects the backend to be running before using the app.
- The repository includes a pre-seeded SQLite database (
db.sqlite3) with sample real-world ads and their images (back/media/), so the app has real data to display right after setup — no manual seeding required. - If you'd rather start with a clean database, just delete
db.sqlite3and re-runpython manage.py migratebefore starting the server. - The project is designed as a learning/demo app, so the structure is intentionally simple and educational.
This project is intended for educational purposes.
This repository is mainly for learning and practice, but improvements and cleanup are welcome.