circularlink 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. circularlink-1.0.0/PKG-INFO +211 -0
  2. circularlink-1.0.0/README.md +187 -0
  3. circularlink-1.0.0/pyproject.toml +46 -0
  4. circularlink-1.0.0/setup.cfg +4 -0
  5. circularlink-1.0.0/src/circularlink/__init__.py +13 -0
  6. circularlink-1.0.0/src/circularlink/__main__.py +24 -0
  7. circularlink-1.0.0/src/circularlink/app.py +349 -0
  8. circularlink-1.0.0/src/circularlink/core/__init__.py +14 -0
  9. circularlink-1.0.0/src/circularlink/core/gemini_agent.py +288 -0
  10. circularlink-1.0.0/src/circularlink/core/geo.py +224 -0
  11. circularlink-1.0.0/src/circularlink/core/gstin.py +150 -0
  12. circularlink-1.0.0/src/circularlink/core/hazard.py +170 -0
  13. circularlink-1.0.0/src/circularlink/core/matcher.py +218 -0
  14. circularlink-1.0.0/src/circularlink/data/hazardous.csv +64 -0
  15. circularlink-1.0.0/src/circularlink/screens/__init__.py +24 -0
  16. circularlink-1.0.0/src/circularlink/screens/buyer.py +354 -0
  17. circularlink-1.0.0/src/circularlink/screens/dashboard.py +223 -0
  18. circularlink-1.0.0/src/circularlink/screens/kyc.py +291 -0
  19. circularlink-1.0.0/src/circularlink/screens/modals.py +263 -0
  20. circularlink-1.0.0/src/circularlink/screens/seller.py +379 -0
  21. circularlink-1.0.0/src/circularlink/screens/welcome.py +284 -0
  22. circularlink-1.0.0/src/circularlink/storage/__init__.py +4 -0
  23. circularlink-1.0.0/src/circularlink/storage/db.py +330 -0
  24. circularlink-1.0.0/src/circularlink/styles.tcss +501 -0
  25. circularlink-1.0.0/src/circularlink.egg-info/PKG-INFO +211 -0
  26. circularlink-1.0.0/src/circularlink.egg-info/SOURCES.txt +28 -0
  27. circularlink-1.0.0/src/circularlink.egg-info/dependency_links.txt +1 -0
  28. circularlink-1.0.0/src/circularlink.egg-info/entry_points.txt +2 -0
  29. circularlink-1.0.0/src/circularlink.egg-info/requires.txt +5 -0
  30. circularlink-1.0.0/src/circularlink.egg-info/top_level.txt +1 -0
@@ -0,0 +1,211 @@
1
+ Metadata-Version: 2.4
2
+ Name: circularlink
3
+ Version: 1.0.0
4
+ Summary: AI-Driven Marketplace for Industrial Circular Economy — Terminal UI
5
+ Author-email: Akshay Jha <akshay@circularlink.io>, Bandhan Sawant <bandhan@circularlink.io>, Devansh Jollani <devansh@circularlink.io>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/circularlink/circularlink
8
+ Project-URL: Documentation, https://github.com/circularlink/circularlink#readme
9
+ Keywords: circular-economy,AI,marketplace,TUI,Gemini,NLP
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Manufacturing
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
17
+ Requires-Python: >=3.11
18
+ Description-Content-Type: text/markdown
19
+ Requires-Dist: textual>=0.80.0
20
+ Requires-Dist: google-generativeai>=0.8.0
21
+ Requires-Dist: rapidfuzz>=3.9.0
22
+ Requires-Dist: rich>=13.7.0
23
+ Requires-Dist: geopy>=2.4.0
24
+
25
+ # CircuLink Terminal
26
+
27
+ > **AI-Driven Marketplace for Industrial Circular Economy**
28
+ > A production-quality Python TUI (Terminal User Interface) that connects industrial buyers and sellers of waste materials, by-products, and recyclables using intelligent fuzzy matching, real-time GSTIN compliance, and Gemini 2.5 Flash AI reasoning.
29
+
30
+ ---
31
+
32
+ ## Features
33
+
34
+ | Feature | Detail |
35
+ |---|---|
36
+ | **GSTIN-gated KYC** | Full 15-character GSTIN regex validation with Indian state-code lookup |
37
+ | **AI Byproduct Prediction** | Seller describes a process → Gemini 2.5 Flash predicts likely marketable byproducts |
38
+ | **Hazardous Screening** | 57-substance database (CAS + name); CAS match → exact → substring → RapidFuzz ≥85 — blocked listings never appear in search |
39
+ | **Intelligent Search** | Buyer enters a query → Gemini expands synonyms → RapidFuzz ensemble scoring → ranked results |
40
+ | **Weighted Scoring** | `final_score = 0.7 × fuzzy_score + 0.3 × location_score` |
41
+ | **Location Proximity** | Haversine distance + exponential decay; 100+ Indian industrial cities pre-geocoded |
42
+ | **Persistent Storage** | `~/.circularlink/` flat-JSON store; JSONL audit trail for every LLM call |
43
+ | **Full TUI** | Rich color scheme, sidebar navigation, modal dialogs — zero browser required |
44
+
45
+ ---
46
+
47
+ ## Quick Start
48
+
49
+ ```bash
50
+ pip install circularlink
51
+ circularlink
52
+ ```
53
+
54
+ ### From source (editable install)
55
+
56
+ ```bash
57
+ git clone https://github.com/your-org/circularlink.git
58
+ cd circularlink
59
+ pip install -e .
60
+ circularlink
61
+ ```
62
+
63
+ Requires **Python 3.11+**.
64
+
65
+ ---
66
+
67
+ ## First Run
68
+
69
+ 1. On launch you will see the **Welcome / Login** screen.
70
+ 2. Switch to the **Register** tab.
71
+ 3. Enter your company details — GSTIN is validated live.
72
+ 4. Paste your **Google AI Studio API key** (from [aistudio.google.com](https://aistudio.google.com)).
73
+ 5. Register → you enter the main application.
74
+
75
+ Subsequent launches auto-restore your session via `~/.circularlink/config.json`.
76
+
77
+ > **💡 Need test data?** See [SAMPLE_DATA.md](SAMPLE_DATA.md) for ready-to-use company credentials and testing scenarios.
78
+
79
+ ---
80
+
81
+ ## Navigation
82
+
83
+ | Key | Screen |
84
+ |---|---|
85
+ | `F1` | Dashboard — stats, recent matches, LLM audit log |
86
+ | `F2` | Buy: Intelligent Sourcing — search / browse / history |
87
+ | `F3` | Sell: Inventory — AI scan, manual add, hazard status |
88
+ | `F4` | KYC / Settings — edit profile, change API key, logout |
89
+ | `Ctrl+Q` | Quit |
90
+
91
+ ---
92
+
93
+ ## Architecture
94
+
95
+ ```
96
+ src/circularlink/
97
+ ├── app.py # Root App — LoginEvent, LogoutEvent, screen routing
98
+ ├── __main__.py # CLI entry point → circularlink
99
+ ├── styles.tcss # Textual CSS — Industrial Earth & Tech palette
100
+
101
+ ├── core/
102
+ │ ├── gstin.py # GSTIN regex validator + state-code lookup
103
+ │ ├── geo.py # City geocoding, haversine, location scoring
104
+ │ ├── hazard.py # 4-strategy hazardous material checker
105
+ │ ├── matcher.py # FuzzyMatcher: ensemble NLP + weighted geo scoring
106
+ │ └── gemini_agent.py # Gemini 2.5 Flash: byproduct prediction + keyword expansion
107
+
108
+ ├── storage/
109
+ │ └── db.py # JSON persistence layer (companies, products, matches, logs)
110
+
111
+ ├── screens/
112
+ │ ├── welcome.py # Login + Registration + live GSTIN validation
113
+ │ ├── dashboard.py # F1 — stats, match table, LLM log
114
+ │ ├── buyer.py # F2 — search, Gemini expansion, ranked results
115
+ │ ├── seller.py # F3 — AI byproduct scan, hazard check, inventory
116
+ │ ├── kyc.py # F4 — profile management, logout, account delete
117
+ │ └── modals.py # MessageModal, ConfirmModal, AddProductModal, SearchModal
118
+
119
+ └── data/
120
+ └── hazardous.csv # 57 hazardous substances (CAS + name + UN number)
121
+ ```
122
+
123
+ ### Scoring Formula
124
+
125
+ $$\text{final\_score} = 0.7 \times \text{fuzzy\_score} + 0.3 \times \text{location\_score}$$
126
+
127
+ - **fuzzy\_score** = ensemble average of RapidFuzz `token_set_ratio`, `token_sort_ratio`, `partial_ratio` across product name and description
128
+ - **location\_score** = $e^{-d / (R/5)}$ where $d$ is Haversine distance in km and $R$ is `max_radius_km` (default 2000 km)
129
+
130
+ ### Hazard Check Strategy (defence-in-depth)
131
+
132
+ 1. CAS number regex match against CSV
133
+ 2. Exact name match (case-insensitive)
134
+ 3. Substring containment (both directions)
135
+ 4. RapidFuzz `token_set_ratio` ≥ 85
136
+
137
+ Any hit → product status set to `blocked`; never returned in buyer search.
138
+
139
+ ---
140
+
141
+ ## Environment Variables
142
+
143
+ | Variable | Purpose |
144
+ |---|---|
145
+ | `GOOGLE_API_KEY` | Fallback API key if none stored in DB |
146
+
147
+ Recommended: set key via the **KYC / Settings** screen (stored locally, never transmitted outside Gemini API calls).
148
+
149
+ ---
150
+
151
+ ## Storage
152
+
153
+ All data is stored under `~/.circularlink/`:
154
+
155
+ ```
156
+ ~/.circularlink/
157
+ ├── config.json # api_key, current_company_id
158
+ ├── companies.json # Registered companies
159
+ ├── products.json # Product listings (approved / blocked / pending)
160
+ ├── matches.json # Saved search results
161
+ └── llm_logs/
162
+ └── YYYY-MM-DD.jsonl # Append-only Gemini call audit log
163
+ ```
164
+
165
+ ---
166
+
167
+ ## Dependencies
168
+
169
+ | Package | Version | Purpose |
170
+ |---|---|---|
171
+ | `textual` | ≥0.80.0 | TUI framework |
172
+ | `google-generativeai` | ≥0.8.0 | Gemini 2.5 Flash API |
173
+ | `rapidfuzz` | ≥3.9.0 | Fuzzy NLP matching |
174
+ | `rich` | ≥13.7.0 | Terminal rendering |
175
+ | `geopy` | ≥2.4.0 | Geocoding utilities |
176
+
177
+ ---
178
+
179
+ ## Color Scheme
180
+
181
+ | Role | Hex | Usage |
182
+ |---|---|---|
183
+ | Background Deep | `#1A1B26` | Screen background |
184
+ | Background Panel | `#24253A` | Sidebar, cards |
185
+ | Seller / Red | `#E06C75` | Seller UI, warnings |
186
+ | Buyer / Green | `#98C379` | Buyer UI, success |
187
+ | AI / Blue | `#61AFEF` | Gemini highlights |
188
+ | Hazard / Amber | `#D19A66` | Hazard banners |
189
+ | Accent / Purple | `#C678DD` | Hotkeys, accents |
190
+
191
+ ---
192
+
193
+ ## Publishing to PyPI
194
+
195
+ ```bash
196
+ pip install build twine
197
+ python -m build
198
+ twine upload dist/*
199
+ ```
200
+
201
+ ---
202
+
203
+ ## License
204
+
205
+ MIT — see [LICENSE](LICENSE) for details.
206
+
207
+ ---
208
+
209
+ ## Acknowledgements
210
+
211
+ Built with [Textual](https://github.com/Textualize/textual) by Textualize, [Google Generative AI](https://ai.google.dev/), and [RapidFuzz](https://github.com/maxbachmann/RapidFuzz).
@@ -0,0 +1,187 @@
1
+ # CircuLink Terminal
2
+
3
+ > **AI-Driven Marketplace for Industrial Circular Economy**
4
+ > A production-quality Python TUI (Terminal User Interface) that connects industrial buyers and sellers of waste materials, by-products, and recyclables using intelligent fuzzy matching, real-time GSTIN compliance, and Gemini 2.5 Flash AI reasoning.
5
+
6
+ ---
7
+
8
+ ## Features
9
+
10
+ | Feature | Detail |
11
+ |---|---|
12
+ | **GSTIN-gated KYC** | Full 15-character GSTIN regex validation with Indian state-code lookup |
13
+ | **AI Byproduct Prediction** | Seller describes a process → Gemini 2.5 Flash predicts likely marketable byproducts |
14
+ | **Hazardous Screening** | 57-substance database (CAS + name); CAS match → exact → substring → RapidFuzz ≥85 — blocked listings never appear in search |
15
+ | **Intelligent Search** | Buyer enters a query → Gemini expands synonyms → RapidFuzz ensemble scoring → ranked results |
16
+ | **Weighted Scoring** | `final_score = 0.7 × fuzzy_score + 0.3 × location_score` |
17
+ | **Location Proximity** | Haversine distance + exponential decay; 100+ Indian industrial cities pre-geocoded |
18
+ | **Persistent Storage** | `~/.circularlink/` flat-JSON store; JSONL audit trail for every LLM call |
19
+ | **Full TUI** | Rich color scheme, sidebar navigation, modal dialogs — zero browser required |
20
+
21
+ ---
22
+
23
+ ## Quick Start
24
+
25
+ ```bash
26
+ pip install circularlink
27
+ circularlink
28
+ ```
29
+
30
+ ### From source (editable install)
31
+
32
+ ```bash
33
+ git clone https://github.com/your-org/circularlink.git
34
+ cd circularlink
35
+ pip install -e .
36
+ circularlink
37
+ ```
38
+
39
+ Requires **Python 3.11+**.
40
+
41
+ ---
42
+
43
+ ## First Run
44
+
45
+ 1. On launch you will see the **Welcome / Login** screen.
46
+ 2. Switch to the **Register** tab.
47
+ 3. Enter your company details — GSTIN is validated live.
48
+ 4. Paste your **Google AI Studio API key** (from [aistudio.google.com](https://aistudio.google.com)).
49
+ 5. Register → you enter the main application.
50
+
51
+ Subsequent launches auto-restore your session via `~/.circularlink/config.json`.
52
+
53
+ > **💡 Need test data?** See [SAMPLE_DATA.md](SAMPLE_DATA.md) for ready-to-use company credentials and testing scenarios.
54
+
55
+ ---
56
+
57
+ ## Navigation
58
+
59
+ | Key | Screen |
60
+ |---|---|
61
+ | `F1` | Dashboard — stats, recent matches, LLM audit log |
62
+ | `F2` | Buy: Intelligent Sourcing — search / browse / history |
63
+ | `F3` | Sell: Inventory — AI scan, manual add, hazard status |
64
+ | `F4` | KYC / Settings — edit profile, change API key, logout |
65
+ | `Ctrl+Q` | Quit |
66
+
67
+ ---
68
+
69
+ ## Architecture
70
+
71
+ ```
72
+ src/circularlink/
73
+ ├── app.py # Root App — LoginEvent, LogoutEvent, screen routing
74
+ ├── __main__.py # CLI entry point → circularlink
75
+ ├── styles.tcss # Textual CSS — Industrial Earth & Tech palette
76
+
77
+ ├── core/
78
+ │ ├── gstin.py # GSTIN regex validator + state-code lookup
79
+ │ ├── geo.py # City geocoding, haversine, location scoring
80
+ │ ├── hazard.py # 4-strategy hazardous material checker
81
+ │ ├── matcher.py # FuzzyMatcher: ensemble NLP + weighted geo scoring
82
+ │ └── gemini_agent.py # Gemini 2.5 Flash: byproduct prediction + keyword expansion
83
+
84
+ ├── storage/
85
+ │ └── db.py # JSON persistence layer (companies, products, matches, logs)
86
+
87
+ ├── screens/
88
+ │ ├── welcome.py # Login + Registration + live GSTIN validation
89
+ │ ├── dashboard.py # F1 — stats, match table, LLM log
90
+ │ ├── buyer.py # F2 — search, Gemini expansion, ranked results
91
+ │ ├── seller.py # F3 — AI byproduct scan, hazard check, inventory
92
+ │ ├── kyc.py # F4 — profile management, logout, account delete
93
+ │ └── modals.py # MessageModal, ConfirmModal, AddProductModal, SearchModal
94
+
95
+ └── data/
96
+ └── hazardous.csv # 57 hazardous substances (CAS + name + UN number)
97
+ ```
98
+
99
+ ### Scoring Formula
100
+
101
+ $$\text{final\_score} = 0.7 \times \text{fuzzy\_score} + 0.3 \times \text{location\_score}$$
102
+
103
+ - **fuzzy\_score** = ensemble average of RapidFuzz `token_set_ratio`, `token_sort_ratio`, `partial_ratio` across product name and description
104
+ - **location\_score** = $e^{-d / (R/5)}$ where $d$ is Haversine distance in km and $R$ is `max_radius_km` (default 2000 km)
105
+
106
+ ### Hazard Check Strategy (defence-in-depth)
107
+
108
+ 1. CAS number regex match against CSV
109
+ 2. Exact name match (case-insensitive)
110
+ 3. Substring containment (both directions)
111
+ 4. RapidFuzz `token_set_ratio` ≥ 85
112
+
113
+ Any hit → product status set to `blocked`; never returned in buyer search.
114
+
115
+ ---
116
+
117
+ ## Environment Variables
118
+
119
+ | Variable | Purpose |
120
+ |---|---|
121
+ | `GOOGLE_API_KEY` | Fallback API key if none stored in DB |
122
+
123
+ Recommended: set key via the **KYC / Settings** screen (stored locally, never transmitted outside Gemini API calls).
124
+
125
+ ---
126
+
127
+ ## Storage
128
+
129
+ All data is stored under `~/.circularlink/`:
130
+
131
+ ```
132
+ ~/.circularlink/
133
+ ├── config.json # api_key, current_company_id
134
+ ├── companies.json # Registered companies
135
+ ├── products.json # Product listings (approved / blocked / pending)
136
+ ├── matches.json # Saved search results
137
+ └── llm_logs/
138
+ └── YYYY-MM-DD.jsonl # Append-only Gemini call audit log
139
+ ```
140
+
141
+ ---
142
+
143
+ ## Dependencies
144
+
145
+ | Package | Version | Purpose |
146
+ |---|---|---|
147
+ | `textual` | ≥0.80.0 | TUI framework |
148
+ | `google-generativeai` | ≥0.8.0 | Gemini 2.5 Flash API |
149
+ | `rapidfuzz` | ≥3.9.0 | Fuzzy NLP matching |
150
+ | `rich` | ≥13.7.0 | Terminal rendering |
151
+ | `geopy` | ≥2.4.0 | Geocoding utilities |
152
+
153
+ ---
154
+
155
+ ## Color Scheme
156
+
157
+ | Role | Hex | Usage |
158
+ |---|---|---|
159
+ | Background Deep | `#1A1B26` | Screen background |
160
+ | Background Panel | `#24253A` | Sidebar, cards |
161
+ | Seller / Red | `#E06C75` | Seller UI, warnings |
162
+ | Buyer / Green | `#98C379` | Buyer UI, success |
163
+ | AI / Blue | `#61AFEF` | Gemini highlights |
164
+ | Hazard / Amber | `#D19A66` | Hazard banners |
165
+ | Accent / Purple | `#C678DD` | Hotkeys, accents |
166
+
167
+ ---
168
+
169
+ ## Publishing to PyPI
170
+
171
+ ```bash
172
+ pip install build twine
173
+ python -m build
174
+ twine upload dist/*
175
+ ```
176
+
177
+ ---
178
+
179
+ ## License
180
+
181
+ MIT — see [LICENSE](LICENSE) for details.
182
+
183
+ ---
184
+
185
+ ## Acknowledgements
186
+
187
+ Built with [Textual](https://github.com/Textualize/textual) by Textualize, [Google Generative AI](https://ai.google.dev/), and [RapidFuzz](https://github.com/maxbachmann/RapidFuzz).
@@ -0,0 +1,46 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "circularlink"
7
+ version = "1.0.0"
8
+ description = "AI-Driven Marketplace for Industrial Circular Economy — Terminal UI"
9
+ readme = "README.md"
10
+ license = { text = "MIT" }
11
+ authors = [
12
+ { name = "Akshay Jha", email = "akshay@circularlink.io" },
13
+ { name = "Bandhan Sawant", email = "bandhan@circularlink.io" },
14
+ { name = "Devansh Jollani", email = "devansh@circularlink.io" },
15
+ ]
16
+ keywords = ["circular-economy", "AI", "marketplace", "TUI", "Gemini", "NLP"]
17
+ classifiers = [
18
+ "Development Status :: 4 - Beta",
19
+ "Environment :: Console",
20
+ "Intended Audience :: Manufacturing",
21
+ "License :: OSI Approved :: MIT License",
22
+ "Programming Language :: Python :: 3.11",
23
+ "Programming Language :: Python :: 3.12",
24
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
25
+ ]
26
+ requires-python = ">=3.11"
27
+ dependencies = [
28
+ "textual>=0.80.0",
29
+ "google-generativeai>=0.8.0",
30
+ "rapidfuzz>=3.9.0",
31
+ "rich>=13.7.0",
32
+ "geopy>=2.4.0",
33
+ ]
34
+
35
+ [project.scripts]
36
+ circularlink = "circularlink.__main__:main"
37
+
38
+ [project.urls]
39
+ Homepage = "https://github.com/circularlink/circularlink"
40
+ Documentation = "https://github.com/circularlink/circularlink#readme"
41
+
42
+ [tool.setuptools.packages.find]
43
+ where = ["src"]
44
+
45
+ [tool.setuptools.package-data]
46
+ "circularlink" = ["data/*.csv", "*.tcss"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,13 @@
1
+ """
2
+ CircuLink Terminal — AI-Driven Marketplace for Industrial Circular Economy
3
+ ==========================================================================
4
+ Connects industrial entities to close the loop on material waste.
5
+
6
+ Version: 1.0.0
7
+ Authors: Akshay Jha, Bandhan Sawant, Devansh Jollani
8
+ Guide: Prof. Samiran Maity
9
+ Institution: Dwarkadas J. Sanghvi College of Engineering, University of Mumbai
10
+ """
11
+
12
+ __version__ = "1.0.0"
13
+ __app_name__ = "CircuLink Terminal"
@@ -0,0 +1,24 @@
1
+ """Entry point — invoked via `circularlink` CLI command."""
2
+ from __future__ import annotations
3
+
4
+ import sys
5
+
6
+
7
+ def main() -> None:
8
+ """Launch the CircuLink Terminal application."""
9
+ # Guard: Python 3.11+ required for match-statements and TaskGroup
10
+ if sys.version_info < (3, 11):
11
+ print(
12
+ "CircuLink requires Python 3.11 or later.\n"
13
+ f"You are running Python {sys.version}."
14
+ )
15
+ sys.exit(1)
16
+
17
+ from circularlink.app import CircuLinkApp
18
+
19
+ app = CircuLinkApp()
20
+ app.run()
21
+
22
+
23
+ if __name__ == "__main__":
24
+ main()