A full-stack web application built for the Nomination Task Challenge to showcase backend efficiency, frontend responsiveness, and intelligent data handling.
This project demonstrates how to design a Dynamic Filtering System using FastAPI, PostgreSQL, Redis, and Next.js (React) β capable of handling 10,000+ records, supporting real-time dependent filters, and offering a fast, responsive UI.
- Supports filtering on all 50+ columns.
- Dependent filter options: When a user applies one filter (e.g., price range), all other filters update dynamically to reflect valid options.
- Realistic data generation with 10,000 records.
- PostgreSQL for structured and indexed data.
- Redis caching to store and serve repeated queries efficiently.
- Optimized query builder for dynamic
WHEREclauses.
- RESTful APIs built with FastAPI.
- primary endpoints:
GET /dataβ Returns filtered and paginated records.GET /filtersβ Returns dynamic filter options based on current filters.
- Scalable structure with clean modular code and dependency injection.
- Responsive and interactive UI built with Next.js and TailwindCSS.
- DataTable with pagination, sorting, and search.
- Dynamic filter panel that updates intelligently.
- Smooth loading and transition effects with Framer Motion.
| Layer | Technology |
|---|---|
| Frontend | Next.js (React), TailwindCSS, Framer Motion |
| Backend | FastAPI (Python) |
| Database | PostgreSQL |
| Caching | Redis |
π¦ Dynamic_filter_system
β
βββ π Backend
β βββ π app
β β βββ π api
β β β βββ π routes
β β β β βββ data.py
β β β β βββ filters.py
β β β βββ __init__.py
β β β βββ router.py
β β βββ π core
β β β βββ config.py
β β β βββ constants.py
β β βββ π db
β β β βββ connection.py
β β βββ π middleware
β β β βββ cors.py
β β βββ π utils
β β β βββ __init__.py
β β β βββ cache.py
β β β βββ json_encoder.py
β β β βββ query_builder.py
β β βββ main.py
β βββ requirements.txt
β
βββ π frontend
| βββ π types
| β βββ routes.d.ts
| β βββ validator.ts
| βββ π components
| β βββ DataTable.js
| β βββ FilterPanel.js
| βββ π public
| β βββ favicon.ico
| β βββ file.svg
| β βββ globe.svg
| β βββ next.svg
| β βββ vercel.svg
| β βββ window.svg
| βββ π src
| β βββ π pages
| β β βββ π api
| β β β βββ Dynamic_filter_sys_API.js
| β β βββ _app.js
| β β βββ _document.js
| β β βββ index.js
| β βββ π styles
| β βββ globals.css
| |
| βββ .env.local.example
| βββ .gitignore
| βββ jsconfig.json
| βββ next.config.mjs
| βββ package-lock.json
| βββ package.json
| βββ postcss.config.mjs
| βββ README.md
|
βββ .env.example
βββ .gitignore
βββ README.md
-
Clone the repository:
git clone https://github.com/Jethva-Parthiv/Dynamic_Filter_System.git cd Dynamic_Filter_System/backend -
Create a virtual environment and install dependencies:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install -r requirements.txt
-
Configure environment variables in a .env file:
DATABASE_URL=postgresql://user:password@localhost:5432/filters_db REDIS_URL=redis://localhost:6379
Before running the backend, set up your PostgreSQL database and populate it with 10,000 records.
-
Create Database psql -U youruser -d postgres;
Once inside, create your project database:
CREATE DATABASE your_DB; \q
-
Run Schema
Navigate to the backend/Data_Generation folder and run the schema:
cd backend/Data_Generation psql -U youruser -d yourdb -f schema.sql
-
Generate Data
Update the credentials in data_gen.py:
conn = psycopg2.connect(dbname='yourdb', user='youruser', password='yourpass', host='localhost', port=5432)
Then run:
python data_gen.py
This will insert 10,000+ random car records into your database in batches of 1,000.
-
Run the FastAPI server:
uvicorn app.main:app --reload
Redis will be used for caching, rate limiting, or temporary filter results β boosting your API speed.
If you donβt have it installed:
πͺ Windows (via WSL or Scoop) sudo apt update && sudo apt install redis-server sudo service redis-server start
or
scoop install redis
redis-server
π§ Linux / macOS sudo apt install redis-server sudo systemctl enable redis-server sudo systemctl start redis-server
Run in terminal: redis-cli ping
Expected output: PONG
REDIS_URL=redis://localhost:<port>
# Example
REDIS_URL=redis://localhost:6379
1. Change to the frontend directory
```bash
cd ../frontend
```
2. Install dependencies
```bash
npm install
```
3. Create .env.local (example)
```env
NEXT_PUBLIC_API_URL=http://localhost:8000
```
4. Run the development server
```bash
npm run dev
```
=============================================================================
- Method: GET
- Description: Fetch filtered and paginated data.
- Query Parameters:
filters: JSON string of filterslimit: Number of records per pageoffset: Starting record index
- Example:
GET /data?filters={"brand":"Toyota","fuel_type":"Petrol"}&limit=20&offset=0
- Method: GET
- Description: Fetch dynamic filter options based on currently applied filters.
- Example:
GET /filters?filters={"price_range":[10000,30000]}
- Each unique filter combination is hashed and stored in Redis.
- Repeated requests serve instantly from cache.
- Automatic cache invalidation when database updates occur.
- Real-time filter updates using React hooks and memoization.
- Responsive DataTable with pagination and sorting.
- Smooth animations with Framer Motion.
- Efficient query building and dynamic data handling.
- Full-stack integration between FastAPI and Next.js.
- Scalable architecture design with caching and pagination.
- Clean, modular, and production-ready codebase.
π Project Showcase
- Goal: Demonstrate a real-world scalable filtering system for large datasets.
- Keywords: FastAPI Β· PostgreSQL Β· Redis Β· Next.js Β· Dynamic Filters Β· Pagination Β· Performance Optimization
π¨βπ» Author
- Name: Parthiv Jethva
- Role: Computer Science Student Β· Backend & Full-Stack Developer - Python
- GitHub Profile: Jethva-Parthiv
- Contact: Email
- Feel free to reach out for collaborations or inquiries!