# adi765/scheme-setu-frontend architecture

> Architecture diagram of the GitHub repository adi765/scheme-setu-frontend, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/adi765/scheme-setu-frontend
- Repository: https://github.com/adi765/scheme-setu-frontend

## Overview

1. **Overall shape**
   - This repo is a **multi-page frontend application** with a **small Flask backend**.
   - The browser does most of the work: rendering pages, handling auth state, searching, swiping, saving wishlist items, and showing scheme details.
   - The backend is narrowly scoped to one job: **scheme matching**.

2. **UI surfaces / pages**
   - The app is split across dedicated HTML pages: `index`, `login`, `dashboard`, `profile`, `find`, `search`, `swipe`, and `wishlist`.
   - `index.html` is the public landing page.
   - `login.html` and the other protected pages use the same local auth gate, so access control is handled in the browser rather than on the server.

3. **Presentation layer**
   - Styling is a mix of **Tailwind CSS via CDN** and custom styles in `css/styles.css`.
   - `styles.css` carries the project-specific visuals that affect architecture: auth overlay behavior, modal styling, swipe-card animation, and other reusable component styles.
   - There is no frontend build pipeline in the repo.

4. **Client-side application modules**
   - The JavaScript is split by feature into small modules under `js/`:
     - `auth.js` for login/signup and auth overlay
     - `api.js` for backend/local data access
     - `form.js` for profile validation and submission
     - `search.js` for keyword search and filtering
     - `swipe.js` for swipe-card interactions
     - `wishlist.js` for saved-scheme views
     - `modal.js` for scheme detail display
     - `utils.js` for shared helpers
   - This is a browser-side modular architecture, not a framework-based SPA.

5. **Authentication boundary**
   - Authentication is **localStorage-based**, not server-managed.
   - `auth.js` controls sign-in state and shows an auth overlay on protected pages when needed.
   - This means the frontend decides whether a user can interact with protected experiences like dashboard, profile matching, wishlist, and swipe.

6. **Scheme discovery and matching flow**
   - The main value path is: user fills profile data on `profile.html` or `find.html` → the frontend validates input in `form.js` → the app calls the matching API through `api.js`.
   - The response becomes the matched-scheme set used by downstream views like swipe, results, and detail modal.
   - `find.html` is intentionally ephemeral: it supports matching for another person without persisting that profile to the user account state.

7. **Backend service boundary**
   - `app.py` is a Flask API that exposes scheme matching, described in the README as `POST /api/match-schemes`.
   - `requirements.txt` shows the backend runtime dependencies: Flask and Flask-CORS.
   - `DATA_CONTRACT.md` documents the request/response shape, which is the contract between frontend and backend.

8. **Local data and fallback behavior**
   - The repository includes `data/schemes_schemesetu_v3.json`, the scheme dataset used for search/matching content.
   - `js/dummyData.js` provides mock API responses.
   - `api.js` can switch between real API calls and dummy/local fallback, so the app can still function when the backend is unavailable.
   - This makes the architecture **local-first and resilient to API failure**.

9. **Search and browse subsystem**
   - `search.html` uses `search.js` for debounced keyword lookup, result highlighting, and tag-based filtering.
   - This part of the app is mostly client-side and likely reads from local dataset/API output rather than requiring server round-trips for every keystroke.
   - It is a distinct browsing path from the eligibility matching flow.

10. **Swipe and wishlist subsystem**
   - `swipe.html` presents matched schemes as swipeable cards using `swipe.js` and custom animation styles.
   - Users can save or skip schemes; saved items feed into `wishlist.html`.
   - `wishlist.js` renders and manages the shortlist, with shared persistence/helpers likely coming from `utils.js`.

11. **Shared detail modal**
   - `modal.js` is a reusable overlay for scheme details such as eligibility, benefits, documents, and apply links.
   - It acts as a cross-cutting UI component used from search, swipe, and wishlist contexts.

12. **State storage model**
   - Persistent browser state appears to be handled primarily in **localStorage** for auth and saved user-facing state.
   - Scheme content itself lives in JSON/local data, while generated match results come from the Flask API or dummy data.
   - The architecture therefore separates:
     - **static content**: HTML/CSS/JS and scheme JSON
     - **client state**: auth/wishlist/session in localStorage
     - **computed results**: matched schemes from API

13. **Key architectural takeaway**
   - This is not a monolithic server-rendered app; it is a **static, modular frontend with lightweight service integration**.
   - The critical diagram boundaries are:
     - browser UI pages
     - client-side feature modules
     - local browser state
     - local scheme dataset / dummy API data
     - Flask matching API
   - The main data flow is user input → frontend validation → matching API or fallback data → search/swipe/modal/wishlist presentation.

Main entry points: [`js/wishlist.js`](https://github.com/adi765/scheme-setu-frontend/blob/main/js/wishlist.js) (Wishlist logic), [`js/auth.js`](https://github.com/adi765/scheme-setu-frontend/blob/main/js/auth.js) (Auth), [`js/search.js`](https://github.com/adi765/scheme-setu-frontend/blob/main/js/search.js) (Search logic), [`js/swipe.js`](https://github.com/adi765/scheme-setu-frontend/blob/main/js/swipe.js) (Swipe logic)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_pages["Browser pages"]
  node_index["Landing<br/>html page<br/>[index.html]"]
  node_login["Login<br/>html page<br/>[login.html]"]
  node_dashboard["Dashboard<br/>html page<br/>[dashboard.html]"]
  node_profile["Profile<br/>html page<br/>[profile.html]"]
  node_find["Find<br/>html page<br/>[find.html]"]
  node_searchpage["Search<br/>html page<br/>[search.html]"]
  node_swipepage["Swipe<br/>html page<br/>[swipe.html]"]
  node_wishlistpage["Wishlist<br/>html page<br/>[wishlist.html]"]
end

subgraph group_client["Client modules"]
  node_authjs["Auth<br/>browser module<br/>[auth.js]"]
  node_apijs["API<br/>browser module<br/>[api.js]"]
  node_formjs["Form<br/>browser module<br/>[form.js]"]
  node_searchjs["Search logic<br/>browser module<br/>[search.js]"]
  node_swipejs["Swipe logic<br/>browser module<br/>[swipe.js]"]
  node_wishlistjs["Wishlist logic<br/>browser module<br/>[wishlist.js]"]
  node_modaljs["Detail modal<br/>browser module<br/>[modal.js]"]
  node_utilsjs["Shared utils<br/>browser module<br/>[utils.js]"]
end

subgraph group_data["Data and state"]
  node_dummydata[("Dummy data<br/>fallback data<br/>[dummyData.js]")]
  node_schemes[("Scheme data<br/>json dataset")]
  node_localstorage[("Local storage<br/>browser state")]
end

subgraph group_server["Backend service"]
  node_app["Flask app<br/>api service<br/>[app.py]"]
end

node_index -->|"entry to auth"| node_login
node_login -->|"auth UI"| node_authjs
node_dashboard -->|"protects access"| node_authjs
node_profile -->|"protects access"| node_authjs
node_find -->|"protects access"| node_authjs
node_searchpage -->|"search UI"| node_searchjs
node_swipepage -->|"swipe UI"| node_swipejs
node_wishlistpage -->|"wishlist UI"| node_wishlistjs
node_profile -->|"submit profile"| node_formjs
node_find -->|"submit profile"| node_formjs
node_formjs -->|"match request"| node_apijs
node_apijs -->|"POST match"| node_app
node_apijs -.->|"fallback data"| node_dummydata
node_searchjs -->|"browse catalog"| node_schemes
node_swipejs -->|"open details"| node_modaljs
node_searchjs -->|"open details"| node_modaljs
node_wishlistjs -->|"view details"| node_modaljs
node_swipejs -->|"save item"| node_wishlistjs
node_authjs -->|"persist auth"| node_localstorage
node_wishlistjs -->|"persist saved"| node_localstorage
node_formjs -->|"shared helpers"| node_utilsjs
node_searchjs -->|"shared helpers"| node_utilsjs
node_swipejs -->|"shared helpers"| node_utilsjs
node_wishlistjs -->|"shared helpers"| node_utilsjs
node_app -->|"match against"| node_schemes
node_app -.->|"none"| node_localstorage

click node_index "https://github.com/adi765/scheme-setu-frontend/blob/main/index.html"
click node_login "https://github.com/adi765/scheme-setu-frontend/blob/main/login.html"
click node_dashboard "https://github.com/adi765/scheme-setu-frontend/blob/main/dashboard.html"
click node_profile "https://github.com/adi765/scheme-setu-frontend/blob/main/profile.html"
click node_find "https://github.com/adi765/scheme-setu-frontend/blob/main/find.html"
click node_searchpage "https://github.com/adi765/scheme-setu-frontend/blob/main/search.html"
click node_swipepage "https://github.com/adi765/scheme-setu-frontend/blob/main/swipe.html"
click node_wishlistpage "https://github.com/adi765/scheme-setu-frontend/blob/main/wishlist.html"
click node_authjs "https://github.com/adi765/scheme-setu-frontend/blob/main/js/auth.js"
click node_apijs "https://github.com/adi765/scheme-setu-frontend/blob/main/js/api.js"
click node_formjs "https://github.com/adi765/scheme-setu-frontend/blob/main/js/form.js"
click node_searchjs "https://github.com/adi765/scheme-setu-frontend/blob/main/js/search.js"
click node_swipejs "https://github.com/adi765/scheme-setu-frontend/blob/main/js/swipe.js"
click node_wishlistjs "https://github.com/adi765/scheme-setu-frontend/blob/main/js/wishlist.js"
click node_modaljs "https://github.com/adi765/scheme-setu-frontend/blob/main/js/modal.js"
click node_utilsjs "https://github.com/adi765/scheme-setu-frontend/blob/main/js/utils.js"
click node_dummydata "https://github.com/adi765/scheme-setu-frontend/blob/main/js/dummyData.js"
click node_schemes "https://github.com/adi765/scheme-setu-frontend/blob/main/data/schemes_schemesetu_v3.json"
click node_app "https://github.com/adi765/scheme-setu-frontend/blob/main/app.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_index,node_login,node_dashboard,node_profile,node_find,node_searchpage,node_swipepage,node_wishlistpage toneBlue
class node_authjs,node_apijs,node_formjs,node_searchjs,node_swipejs,node_wishlistjs,node_modaljs,node_utilsjs toneAmber
class node_dummydata,node_schemes,node_localstorage toneMint
class node_app toneRose
```

## Components

### Browser pages

Standalone HTML entry points for public, protected, and discovery flows.

- [Landing](https://github.com/adi765/scheme-setu-frontend/blob/main/index.html): html page · Public home page. · `index.html`
- [Login](https://github.com/adi765/scheme-setu-frontend/blob/main/login.html): html page · Authentication entry page. · `login.html`
- [Dashboard](https://github.com/adi765/scheme-setu-frontend/blob/main/dashboard.html): html page · Protected overview page. · `dashboard.html`
- [Profile](https://github.com/adi765/scheme-setu-frontend/blob/main/profile.html): html page · Saved profile input for matching. · `profile.html`
- [Find](https://github.com/adi765/scheme-setu-frontend/blob/main/find.html): html page · Ephemeral matching flow for another person. · `find.html`
- [Search](https://github.com/adi765/scheme-setu-frontend/blob/main/search.html): html page · Scheme browsing and filtering page. · `search.html`
- [Swipe](https://github.com/adi765/scheme-setu-frontend/blob/main/swipe.html): html page · Matched-scheme swipe interaction page. · `swipe.html`
- [Wishlist](https://github.com/adi765/scheme-setu-frontend/blob/main/wishlist.html): html page · Saved schemes shortlist page. · `wishlist.html`

### Client modules

Browser-side JavaScript features and shared UI logic.

- [Auth](https://github.com/adi765/scheme-setu-frontend/blob/main/js/auth.js): browser module · Local sign-in state and auth overlay. · `js/auth.js`
- [API](https://github.com/adi765/scheme-setu-frontend/blob/main/js/api.js): browser module · Backend calls and local fallback routing. · `js/api.js`
- [Form](https://github.com/adi765/scheme-setu-frontend/blob/main/js/form.js): browser module · Profile validation and submission logic. · `js/form.js`
- [Search logic](https://github.com/adi765/scheme-setu-frontend/blob/main/js/search.js): browser module · Keyword search, highlighting, and filtering. · `js/search.js`
- [Swipe logic](https://github.com/adi765/scheme-setu-frontend/blob/main/js/swipe.js): browser module · Card swipe interactions and match handling. · `js/swipe.js`
- [Wishlist logic](https://github.com/adi765/scheme-setu-frontend/blob/main/js/wishlist.js): browser module · Saved-scheme rendering and management. · `js/wishlist.js`
- [Detail modal](https://github.com/adi765/scheme-setu-frontend/blob/main/js/modal.js): browser module · Reusable scheme detail overlay. · `js/modal.js`
- [Shared utils](https://github.com/adi765/scheme-setu-frontend/blob/main/js/utils.js): browser module · Common browser helpers used across features. · `js/utils.js`

### Data and state

Local browser state, bundled scheme data, and fallback response data.

- [Dummy data](https://github.com/adi765/scheme-setu-frontend/blob/main/js/dummyData.js): fallback data · Mock API responses used when backend access is unavailable. · `js/dummyData.js`
- [Scheme data](https://github.com/adi765/scheme-setu-frontend/blob/main/data/schemes_schemesetu_v3.json): json dataset · Local scheme catalog used for search and matching content. · `data/schemes_schemesetu_v3.json`
- **Local storage**: browser state · Client-persisted auth and user-facing state.

### Backend service

Flask API boundary for scheme matching.

- [Flask app](https://github.com/adi765/scheme-setu-frontend/blob/main/app.py): api service · Scheme matching API boundary. · `app.py`

## Connections

- Landing → Login: entry to auth · Public users move from landing into authentication.
- Login → Auth: auth UI · Login page is driven by local auth state and overlay logic.
- Dashboard → Auth: protects access · Protected pages use browser-side auth gating.
- Profile → Auth: protects access · Profile page is gated by local authentication.
- Find → Auth: protects access · Find flow is guarded in the browser.
- Search → Search logic: search UI · Search page delegates filtering and highlighting to the search module.
- Swipe → Swipe logic: swipe UI · Swipe page uses the swipe interaction module.
- Wishlist → Wishlist logic: wishlist UI · Wishlist page renders saved items through the wishlist module.
- Profile → Form: submit profile · Profile data is validated and prepared for matching.
- Find → Form: submit profile · Ephemeral find flow also uses the shared form pipeline.
- Form → API: match request · Validated profile data is sent to the matching API layer.
- API → Flask app: POST match · Backend receives the matching request.
- API → Dummy data: fallback data · Client can switch to mock responses when the backend is unavailable.
- Search logic → Scheme data: browse catalog · Search/filtering works over the local scheme dataset or derived data.
- Swipe logic → Detail modal: open details · Swipe cards can reveal scheme details in the shared modal.
- Search logic → Detail modal: open details · Search results reuse the shared detail overlay.
- Wishlist logic → Detail modal: view details · Wishlist items open in the same detail modal.
- Swipe logic → Wishlist logic: save item · Swiped-saved schemes flow into the shortlist.
- Auth → Local storage: persist auth · Authentication state is stored in the browser.
- Wishlist logic → Local storage: persist saved · Saved schemes are kept in local browser state.
- Form → Shared utils: shared helpers · Form handling uses common utility functions.
- Search logic → Shared utils: shared helpers · Search feature reuses browser helpers.
- Swipe logic → Shared utils: shared helpers · Swipe interactions reuse common utilities.
- Wishlist logic → Shared utils: shared helpers · Wishlist rendering reuses common utilities.
- Flask app → Scheme data: match against · Backend matching logic consumes the scheme dataset.
- Flask app → Local storage: none · No direct server-side state persistence; client state remains local.
