refast 0.0.1__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 (290) hide show
  1. refast-0.0.1/.github/copilot-instructions.md +578 -0
  2. refast-0.0.1/.github/workflows/python-publish.yml +25 -0
  3. refast-0.0.1/.github/workflows/python-pytest.yml +40 -0
  4. refast-0.0.1/.gitignore +79 -0
  5. refast-0.0.1/PKG-INFO +79 -0
  6. refast-0.0.1/README.md +59 -0
  7. refast-0.0.1/docs/COMPONENT_DEVELOPMENT.md +1937 -0
  8. refast-0.0.1/docs/EXTENSION_DEVELOPMENT.md +1246 -0
  9. refast-0.0.1/docs/NAMING_CONVENTIONS.md +264 -0
  10. refast-0.0.1/docs/PROP_STORE_GUIDE.md +314 -0
  11. refast-0.0.1/docs/STREAMING_GUIDE.md +255 -0
  12. refast-0.0.1/docs/STYLING_GUIDE.md +160 -0
  13. refast-0.0.1/docs/TAILWIND_SUPPORT.md +63 -0
  14. refast-0.0.1/examples/basic/README.md +37 -0
  15. refast-0.0.1/examples/basic/app.py +196 -0
  16. refast-0.0.1/examples/charts_showcase/app.py +817 -0
  17. refast-0.0.1/examples/chat_app/app.py +380 -0
  18. refast-0.0.1/examples/colors_showcase/README.md +19 -0
  19. refast-0.0.1/examples/colors_showcase/app.py +223 -0
  20. refast-0.0.1/examples/component_showcase/README.md +38 -0
  21. refast-0.0.1/examples/component_showcase/app.py +1242 -0
  22. refast-0.0.1/examples/connection_status/README.md +125 -0
  23. refast-0.0.1/examples/connection_status/app.py +482 -0
  24. refast-0.0.1/examples/dashboard/app.py +518 -0
  25. refast-0.0.1/examples/data_table/README.md +55 -0
  26. refast-0.0.1/examples/data_table/app.py +530 -0
  27. refast-0.0.1/examples/ecommerce_product/README.md +72 -0
  28. refast-0.0.1/examples/ecommerce_product/app.py +833 -0
  29. refast-0.0.1/examples/file_manager/README.md +94 -0
  30. refast-0.0.1/examples/file_manager/app.py +833 -0
  31. refast-0.0.1/examples/form_validation/README.md +22 -0
  32. refast-0.0.1/examples/form_validation/app.py +164 -0
  33. refast-0.0.1/examples/hello.py +113 -0
  34. refast-0.0.1/examples/input_features/README.md +53 -0
  35. refast-0.0.1/examples/input_features/app.py +166 -0
  36. refast-0.0.1/examples/js_callbacks/README.md +135 -0
  37. refast-0.0.1/examples/js_callbacks/app.py +934 -0
  38. refast-0.0.1/examples/kanban_board/README.md +72 -0
  39. refast-0.0.1/examples/kanban_board/app.py +642 -0
  40. refast-0.0.1/examples/longrunning.py +88 -0
  41. refast-0.0.1/examples/multi_page/README.md +22 -0
  42. refast-0.0.1/examples/multi_page/app.py +151 -0
  43. refast-0.0.1/examples/navigation_showcase/README.md +49 -0
  44. refast-0.0.1/examples/navigation_showcase/app.py +744 -0
  45. refast-0.0.1/examples/prop_store/README.md +81 -0
  46. refast-0.0.1/examples/prop_store/app.py +237 -0
  47. refast-0.0.1/examples/realtime_dashboard/README.md +31 -0
  48. refast-0.0.1/examples/realtime_dashboard/app.py +218 -0
  49. refast-0.0.1/examples/settings_panel/README.md +49 -0
  50. refast-0.0.1/examples/settings_panel/app.py +892 -0
  51. refast-0.0.1/examples/sidebar_showcase/README.md +179 -0
  52. refast-0.0.1/examples/sidebar_showcase/app.py +1488 -0
  53. refast-0.0.1/examples/streaming/app.py +462 -0
  54. refast-0.0.1/examples/theme_showcase/README.md +34 -0
  55. refast-0.0.1/examples/theme_showcase/app.py +441 -0
  56. refast-0.0.1/examples/toast_showcase/README.md +154 -0
  57. refast-0.0.1/examples/toast_showcase/app.py +639 -0
  58. refast-0.0.1/examples/todo_app/app.py +287 -0
  59. refast-0.0.1/examples/weather_dashboard/README.md +22 -0
  60. refast-0.0.1/examples/weather_dashboard/app.py +128 -0
  61. refast-0.0.1/plan/README.md +95 -0
  62. refast-0.0.1/plan/completed/refast-full-integration.md +789 -0
  63. refast-0.0.1/plan/completed/stage-1-core.md +967 -0
  64. refast-0.0.1/plan/completed/stage-10-charts.md +1244 -0
  65. refast-0.0.1/plan/completed/stage-2-components.md +1586 -0
  66. refast-0.0.1/plan/completed/stage-3-events.md +1161 -0
  67. refast-0.0.1/plan/completed/stage-4-sessions.md +1079 -0
  68. refast-0.0.1/plan/completed/stage-5-security.md +1335 -0
  69. refast-0.0.1/plan/completed/stage-6-frontend.md +1609 -0
  70. refast-0.0.1/plan/completed/stage-7-integration.md +1496 -0
  71. refast-0.0.1/plan/completed/stage-9-shadcn-components.md +939 -0
  72. refast-0.0.1/plan/plan-refastExtensionSystem.prompt.md +341 -0
  73. refast-0.0.1/plan/stage-8-docs.md +1071 -0
  74. refast-0.0.1/pyproject.toml +49 -0
  75. refast-0.0.1/scripts/build.py +232 -0
  76. refast-0.0.1/src/refast/__init__.py +32 -0
  77. refast-0.0.1/src/refast/app.py +330 -0
  78. refast-0.0.1/src/refast/components/__init__.py +433 -0
  79. refast-0.0.1/src/refast/components/base.py +264 -0
  80. refast-0.0.1/src/refast/components/registry.py +139 -0
  81. refast-0.0.1/src/refast/components/shadcn/__init__.py +421 -0
  82. refast-0.0.1/src/refast/components/shadcn/button.py +151 -0
  83. refast-0.0.1/src/refast/components/shadcn/card.py +213 -0
  84. refast-0.0.1/src/refast/components/shadcn/charts/__init__.py +100 -0
  85. refast-0.0.1/src/refast/components/shadcn/charts/area.py +212 -0
  86. refast-0.0.1/src/refast/components/shadcn/charts/bar.py +221 -0
  87. refast-0.0.1/src/refast/components/shadcn/charts/base.py +279 -0
  88. refast-0.0.1/src/refast/components/shadcn/charts/composed.py +102 -0
  89. refast-0.0.1/src/refast/components/shadcn/charts/funnel.py +155 -0
  90. refast-0.0.1/src/refast/components/shadcn/charts/line.py +192 -0
  91. refast-0.0.1/src/refast/components/shadcn/charts/pie.py +230 -0
  92. refast-0.0.1/src/refast/components/shadcn/charts/radar.py +197 -0
  93. refast-0.0.1/src/refast/components/shadcn/charts/radial.py +123 -0
  94. refast-0.0.1/src/refast/components/shadcn/charts/sankey.py +125 -0
  95. refast-0.0.1/src/refast/components/shadcn/charts/scatter.py +251 -0
  96. refast-0.0.1/src/refast/components/shadcn/charts/treemap.py +113 -0
  97. refast-0.0.1/src/refast/components/shadcn/charts/utils.py +868 -0
  98. refast-0.0.1/src/refast/components/shadcn/controls.py +828 -0
  99. refast-0.0.1/src/refast/components/shadcn/data_display.py +700 -0
  100. refast-0.0.1/src/refast/components/shadcn/feedback.py +288 -0
  101. refast-0.0.1/src/refast/components/shadcn/form.py +129 -0
  102. refast-0.0.1/src/refast/components/shadcn/icon.py +311 -0
  103. refast-0.0.1/src/refast/components/shadcn/input.py +585 -0
  104. refast-0.0.1/src/refast/components/shadcn/layout.py +226 -0
  105. refast-0.0.1/src/refast/components/shadcn/navigation.py +2349 -0
  106. refast-0.0.1/src/refast/components/shadcn/overlay.py +1777 -0
  107. refast-0.0.1/src/refast/components/shadcn/typography.py +212 -0
  108. refast-0.0.1/src/refast/components/shadcn/utility.py +899 -0
  109. refast-0.0.1/src/refast/components/slot.py +57 -0
  110. refast-0.0.1/src/refast/context.py +1087 -0
  111. refast-0.0.1/src/refast/events/__init__.py +19 -0
  112. refast-0.0.1/src/refast/events/broadcast.py +247 -0
  113. refast-0.0.1/src/refast/events/manager.py +267 -0
  114. refast-0.0.1/src/refast/events/stream.py +322 -0
  115. refast-0.0.1/src/refast/events/types.py +140 -0
  116. refast-0.0.1/src/refast/extensions/__init__.py +9 -0
  117. refast-0.0.1/src/refast/extensions/base.py +184 -0
  118. refast-0.0.1/src/refast/router.py +421 -0
  119. refast-0.0.1/src/refast/security/__init__.py +76 -0
  120. refast-0.0.1/src/refast/security/csp.py +254 -0
  121. refast-0.0.1/src/refast/security/csrf.py +305 -0
  122. refast-0.0.1/src/refast/security/middleware.py +222 -0
  123. refast-0.0.1/src/refast/security/rate_limit.py +312 -0
  124. refast-0.0.1/src/refast/security/sanitizer.py +351 -0
  125. refast-0.0.1/src/refast/session/__init__.py +23 -0
  126. refast-0.0.1/src/refast/session/middleware.py +177 -0
  127. refast-0.0.1/src/refast/session/session.py +231 -0
  128. refast-0.0.1/src/refast/session/stores/__init__.py +13 -0
  129. refast-0.0.1/src/refast/session/stores/base.py +111 -0
  130. refast-0.0.1/src/refast/session/stores/memory.py +184 -0
  131. refast-0.0.1/src/refast/session/stores/redis.py +168 -0
  132. refast-0.0.1/src/refast/state.py +78 -0
  133. refast-0.0.1/src/refast/static/App.d.ts +22 -0
  134. refast-0.0.1/src/refast/static/__init__.py +1 -0
  135. refast-0.0.1/src/refast/static/components/ComponentRenderer.d.ts +13 -0
  136. refast-0.0.1/src/refast/static/components/ToastManager.d.ts +49 -0
  137. refast-0.0.1/src/refast/static/components/__tests__/components.test.d.ts +1 -0
  138. refast-0.0.1/src/refast/static/components/__tests__/registry.test.d.ts +1 -0
  139. refast-0.0.1/src/refast/static/components/base.d.ts +32 -0
  140. refast-0.0.1/src/refast/static/components/charts/area-chart.d.ts +2 -0
  141. refast-0.0.1/src/refast/static/components/charts/bar-chart.d.ts +2 -0
  142. refast-0.0.1/src/refast/static/components/charts/chart.d.ts +48 -0
  143. refast-0.0.1/src/refast/static/components/charts/composed-chart.d.ts +1 -0
  144. refast-0.0.1/src/refast/static/components/charts/funnel-chart.d.ts +4 -0
  145. refast-0.0.1/src/refast/static/components/charts/line-chart.d.ts +2 -0
  146. refast-0.0.1/src/refast/static/components/charts/pie-chart.d.ts +6 -0
  147. refast-0.0.1/src/refast/static/components/charts/radar-chart.d.ts +10 -0
  148. refast-0.0.1/src/refast/static/components/charts/radial-chart.d.ts +4 -0
  149. refast-0.0.1/src/refast/static/components/charts/sankey.d.ts +3 -0
  150. refast-0.0.1/src/refast/static/components/charts/scatter-chart.d.ts +5 -0
  151. refast-0.0.1/src/refast/static/components/charts/treemap.d.ts +3 -0
  152. refast-0.0.1/src/refast/static/components/charts/utils.d.ts +13 -0
  153. refast-0.0.1/src/refast/static/components/registry.d.ts +19 -0
  154. refast-0.0.1/src/refast/static/components/shadcn/ConnectionStatus.d.ts +36 -0
  155. refast-0.0.1/src/refast/static/components/shadcn/button.d.ts +35 -0
  156. refast-0.0.1/src/refast/static/components/shadcn/calendar.d.ts +7 -0
  157. refast-0.0.1/src/refast/static/components/shadcn/card.d.ts +63 -0
  158. refast-0.0.1/src/refast/static/components/shadcn/controls.d.ts +189 -0
  159. refast-0.0.1/src/refast/static/components/shadcn/data_display.d.ts +186 -0
  160. refast-0.0.1/src/refast/static/components/shadcn/feedback.d.ts +86 -0
  161. refast-0.0.1/src/refast/static/components/shadcn/icon.d.ts +25 -0
  162. refast-0.0.1/src/refast/static/components/shadcn/input.d.ts +190 -0
  163. refast-0.0.1/src/refast/static/components/shadcn/layout.d.ts +61 -0
  164. refast-0.0.1/src/refast/static/components/shadcn/navigation.d.ts +493 -0
  165. refast-0.0.1/src/refast/static/components/shadcn/overlay.d.ts +306 -0
  166. refast-0.0.1/src/refast/static/components/shadcn/slot.d.ts +14 -0
  167. refast-0.0.1/src/refast/static/components/shadcn/types.d.ts +24 -0
  168. refast-0.0.1/src/refast/static/components/shadcn/typography.d.ts +113 -0
  169. refast-0.0.1/src/refast/static/components/shadcn/utility.d.ts +127 -0
  170. refast-0.0.1/src/refast/static/events/EventManager.d.ts +32 -0
  171. refast-0.0.1/src/refast/static/events/WebSocketClient.d.ts +40 -0
  172. refast-0.0.1/src/refast/static/index.d.ts +61 -0
  173. refast-0.0.1/src/refast/static/state/PersistentStateManager.d.ts +78 -0
  174. refast-0.0.1/src/refast/static/state/PropStore.d.ts +67 -0
  175. refast-0.0.1/src/refast/static/state/StateManager.d.ts +22 -0
  176. refast-0.0.1/src/refast/static/state/__tests__/StateManager.test.d.ts +1 -0
  177. refast-0.0.1/src/refast/static/test/setup.d.ts +1 -0
  178. refast-0.0.1/src/refast/static/types.d.ts +180 -0
  179. refast-0.0.1/src/refast/static/utils/__tests__/index.test.d.ts +1 -0
  180. refast-0.0.1/src/refast/static/utils/index.d.ts +26 -0
  181. refast-0.0.1/src/refast/store.py +423 -0
  182. refast-0.0.1/src/refast/theme/__init__.py +27 -0
  183. refast-0.0.1/src/refast/theme/presets.py +252 -0
  184. refast-0.0.1/src/refast/theme/theme.py +191 -0
  185. refast-0.0.1/src/refast/utils/__init__.py +15 -0
  186. refast-0.0.1/src/refast/utils/case.py +244 -0
  187. refast-0.0.1/src/refast-client/package-lock.json +11715 -0
  188. refast-0.0.1/src/refast-client/package.json +87 -0
  189. refast-0.0.1/src/refast-client/postcss.config.js +6 -0
  190. refast-0.0.1/src/refast-client/src/App.tsx +215 -0
  191. refast-0.0.1/src/refast-client/src/components/ComponentRenderer.tsx +423 -0
  192. refast-0.0.1/src/refast-client/src/components/ToastManager.tsx +236 -0
  193. refast-0.0.1/src/refast-client/src/components/__tests__/components.test.tsx +167 -0
  194. refast-0.0.1/src/refast-client/src/components/__tests__/registry.test.ts +94 -0
  195. refast-0.0.1/src/refast-client/src/components/base.tsx +73 -0
  196. refast-0.0.1/src/refast-client/src/components/charts/area-chart.tsx +4 -0
  197. refast-0.0.1/src/refast-client/src/components/charts/bar-chart.tsx +4 -0
  198. refast-0.0.1/src/refast-client/src/components/charts/chart.tsx +222 -0
  199. refast-0.0.1/src/refast-client/src/components/charts/composed-chart.tsx +3 -0
  200. refast-0.0.1/src/refast-client/src/components/charts/funnel-chart.tsx +7 -0
  201. refast-0.0.1/src/refast-client/src/components/charts/line-chart.tsx +4 -0
  202. refast-0.0.1/src/refast-client/src/components/charts/pie-chart.tsx +11 -0
  203. refast-0.0.1/src/refast-client/src/components/charts/radar-chart.tsx +13 -0
  204. refast-0.0.1/src/refast-client/src/components/charts/radial-chart.tsx +7 -0
  205. refast-0.0.1/src/refast-client/src/components/charts/sankey.tsx +3 -0
  206. refast-0.0.1/src/refast-client/src/components/charts/scatter-chart.tsx +9 -0
  207. refast-0.0.1/src/refast-client/src/components/charts/treemap.tsx +3 -0
  208. refast-0.0.1/src/refast-client/src/components/charts/utils.tsx +25 -0
  209. refast-0.0.1/src/refast-client/src/components/registry.ts +379 -0
  210. refast-0.0.1/src/refast-client/src/components/shadcn/ConnectionStatus.tsx +223 -0
  211. refast-0.0.1/src/refast-client/src/components/shadcn/button.tsx +156 -0
  212. refast-0.0.1/src/refast-client/src/components/shadcn/calendar.tsx +220 -0
  213. refast-0.0.1/src/refast-client/src/components/shadcn/card.tsx +172 -0
  214. refast-0.0.1/src/refast-client/src/components/shadcn/controls.tsx +1513 -0
  215. refast-0.0.1/src/refast-client/src/components/shadcn/data_display.tsx +759 -0
  216. refast-0.0.1/src/refast-client/src/components/shadcn/feedback.tsx +322 -0
  217. refast-0.0.1/src/refast-client/src/components/shadcn/icon.tsx +577 -0
  218. refast-0.0.1/src/refast-client/src/components/shadcn/input.tsx +963 -0
  219. refast-0.0.1/src/refast-client/src/components/shadcn/layout.tsx +201 -0
  220. refast-0.0.1/src/refast-client/src/components/shadcn/navigation.tsx +2315 -0
  221. refast-0.0.1/src/refast-client/src/components/shadcn/overlay.tsx +1499 -0
  222. refast-0.0.1/src/refast-client/src/components/shadcn/slot.tsx +26 -0
  223. refast-0.0.1/src/refast-client/src/components/shadcn/types.ts +30 -0
  224. refast-0.0.1/src/refast-client/src/components/shadcn/typography.tsx +758 -0
  225. refast-0.0.1/src/refast-client/src/components/shadcn/utility.tsx +1041 -0
  226. refast-0.0.1/src/refast-client/src/events/EventManager.tsx +371 -0
  227. refast-0.0.1/src/refast-client/src/events/WebSocketClient.ts +283 -0
  228. refast-0.0.1/src/refast-client/src/index.css +203 -0
  229. refast-0.0.1/src/refast-client/src/index.tsx +196 -0
  230. refast-0.0.1/src/refast-client/src/state/PersistentStateManager.ts +240 -0
  231. refast-0.0.1/src/refast-client/src/state/PropStore.ts +109 -0
  232. refast-0.0.1/src/refast-client/src/state/StateManager.ts +483 -0
  233. refast-0.0.1/src/refast-client/src/state/__tests__/StateManager.test.ts +157 -0
  234. refast-0.0.1/src/refast-client/src/test/setup.ts +1 -0
  235. refast-0.0.1/src/refast-client/src/types.ts +192 -0
  236. refast-0.0.1/src/refast-client/src/utils/__tests__/index.test.ts +100 -0
  237. refast-0.0.1/src/refast-client/src/utils/index.ts +85 -0
  238. refast-0.0.1/src/refast-client/tailwind.config.js +178 -0
  239. refast-0.0.1/src/refast-client/tsconfig.json +27 -0
  240. refast-0.0.1/src/refast-client/tsconfig.node.json +11 -0
  241. refast-0.0.1/src/refast-client/vite.config.ts +55 -0
  242. refast-0.0.1/tests/__init__.py +1 -0
  243. refast-0.0.1/tests/conftest.py +27 -0
  244. refast-0.0.1/tests/e2e/package.json +16 -0
  245. refast-0.0.1/tests/e2e/playwright.config.ts +71 -0
  246. refast-0.0.1/tests/e2e/specs/basic.spec.ts +120 -0
  247. refast-0.0.1/tests/e2e/specs/events.spec.ts +178 -0
  248. refast-0.0.1/tests/integration/__init__.py +1 -0
  249. refast-0.0.1/tests/integration/test_fastapi_integration.py +247 -0
  250. refast-0.0.1/tests/integration/test_full_flow.py +280 -0
  251. refast-0.0.1/tests/integration/test_static_assets.py +81 -0
  252. refast-0.0.1/tests/integration/test_theme_runtime.py +119 -0
  253. refast-0.0.1/tests/integration/test_websocket.py +121 -0
  254. refast-0.0.1/tests/unit/__init__.py +1 -0
  255. refast-0.0.1/tests/unit/test_app.py +172 -0
  256. refast-0.0.1/tests/unit/test_broadcast.py +247 -0
  257. refast-0.0.1/tests/unit/test_button_card.py +155 -0
  258. refast-0.0.1/tests/unit/test_charts.py +684 -0
  259. refast-0.0.1/tests/unit/test_components.py +187 -0
  260. refast-0.0.1/tests/unit/test_context.py +779 -0
  261. refast-0.0.1/tests/unit/test_controls.py +279 -0
  262. refast-0.0.1/tests/unit/test_csp.py +281 -0
  263. refast-0.0.1/tests/unit/test_csrf.py +298 -0
  264. refast-0.0.1/tests/unit/test_data_display.py +307 -0
  265. refast-0.0.1/tests/unit/test_event_manager.py +307 -0
  266. refast-0.0.1/tests/unit/test_event_types.py +191 -0
  267. refast-0.0.1/tests/unit/test_extensions.py +466 -0
  268. refast-0.0.1/tests/unit/test_feedback.py +257 -0
  269. refast-0.0.1/tests/unit/test_form.py +81 -0
  270. refast-0.0.1/tests/unit/test_init.py +36 -0
  271. refast-0.0.1/tests/unit/test_input.py +408 -0
  272. refast-0.0.1/tests/unit/test_layout.py +112 -0
  273. refast-0.0.1/tests/unit/test_memory_store.py +144 -0
  274. refast-0.0.1/tests/unit/test_navigation.py +232 -0
  275. refast-0.0.1/tests/unit/test_overlay.py +260 -0
  276. refast-0.0.1/tests/unit/test_rate_limit.py +365 -0
  277. refast-0.0.1/tests/unit/test_registry.py +149 -0
  278. refast-0.0.1/tests/unit/test_router.py +157 -0
  279. refast-0.0.1/tests/unit/test_sanitizer.py +348 -0
  280. refast-0.0.1/tests/unit/test_security_middleware.py +342 -0
  281. refast-0.0.1/tests/unit/test_session.py +238 -0
  282. refast-0.0.1/tests/unit/test_session_middleware.py +168 -0
  283. refast-0.0.1/tests/unit/test_slot.py +52 -0
  284. refast-0.0.1/tests/unit/test_state.py +176 -0
  285. refast-0.0.1/tests/unit/test_store.py +413 -0
  286. refast-0.0.1/tests/unit/test_stream.py +251 -0
  287. refast-0.0.1/tests/unit/test_theme.py +311 -0
  288. refast-0.0.1/tests/unit/test_theming.py +271 -0
  289. refast-0.0.1/tests/unit/test_typography.py +190 -0
  290. refast-0.0.1/tests/unit/test_utility.py +318 -0
@@ -0,0 +1,578 @@
1
+ # Refast Framework - AI Coding Agent Instructions
2
+
3
+ > **IMPORTANT**: This file must be kept up-to-date with the current project structure. When making structural changes to the codebase, update this file accordingly.
4
+
5
+ ## Project Overview
6
+
7
+ **Refast** is a Python + React UI framework that enables building reactive web applications with Python-first development. It uses FastAPI for the backend and React with shadcn/ui for the frontend.
8
+
9
+ ### Core Principles
10
+
11
+ 1. **Explicit over Magic** - Every callback, event, and state change is explicitly defined
12
+ 2. **Type Safety** - Full type hints and Pydantic validation throughout
13
+ 3. **Pluggable Architecture** - Can be added to any existing FastAPI app via `include_router`
14
+ 4. **Component Isolation** - Each component package is independent
15
+ 5. **Security First** - CSRF, rate limiting, input sanitization built-in
16
+
17
+ ---
18
+
19
+ ## Current Project Structure
20
+
21
+ ```
22
+ refast/
23
+ ├── .github/
24
+ │ ├── copilot-instructions.md # THIS FILE - AI agent instructions
25
+ │ ├── workflows/ # GitHub Actions CI/CD
26
+ │ │ ├── test.yml
27
+ │ │ ├── lint.yml
28
+ │ │ └── docs.yml
29
+ │ └── CODEOWNERS
30
+ ├── plan/ # Development plans and roadmaps
31
+ │ ├── README.md
32
+ │ ├── stage-1-core.md
33
+ │ ├── stage-2-components.md
34
+ │ ├── stage-3-events.md
35
+ │ ├── stage-4-sessions.md
36
+ │ ├── stage-5-security.md
37
+ │ ├── stage-6-frontend.md
38
+ │ ├── stage-7-integration.md
39
+ │ └── stage-8-docs.md
40
+ ├── src/
41
+ │ └── refast/ # Main Python package
42
+ │ ├── __init__.py
43
+ │ ├── app.py # RefastApp main class
44
+ │ ├── router.py # FastAPI router integration
45
+ │ ├── context.py # Context class for callbacks
46
+ │ ├── state.py # State management
47
+ │ ├── components/
48
+ │ │ ├── __init__.py
49
+ │ │ ├── base.py # Base component classes
50
+ │ │ ├── registry.py # Component registry
51
+ │ │ ├── slot.py # Slot component for placeholders
52
+ │ │ └── shadcn/ # shadcn-based components
53
+ │ │ ├── __init__.py
54
+ │ │ ├── button.py
55
+ │ │ ├── card.py
56
+ │ │ ├── input.py
57
+ │ │ ├── form.py
58
+ │ │ ├── layout.py
59
+ │ │ ├── feedback.py
60
+ │ │ └── data_display.py
61
+ │ ├── events/
62
+ │ │ ├── __init__.py
63
+ │ │ ├── manager.py # Event routing and handling
64
+ │ │ ├── stream.py # WebSocket streaming
65
+ │ │ ├── broadcast.py # Broadcast to all clients
66
+ │ │ └── types.py # Event type definitions
67
+ │ ├── session/
68
+ │ │ ├── __init__.py
69
+ │ │ ├── session.py # Session management
70
+ │ │ ├── stores/
71
+ │ │ │ ├── __init__.py
72
+ │ │ │ ├── base.py # Abstract base store
73
+ │ │ │ ├── memory.py # In-memory store
74
+ │ │ │ └── redis.py # Redis store
75
+ │ │ └── middleware.py # Session middleware
76
+ │ ├── security/
77
+ │ │ ├── __init__.py
78
+ │ │ ├── csrf.py # CSRF protection
79
+ │ │ ├── rate_limit.py # Rate limiting
80
+ │ │ ├── sanitizer.py # Input sanitization
81
+ │ │ ├── csp.py # Content Security Policy
82
+ │ │ └── middleware.py # Security middleware
83
+ │ ├── theme/
84
+ │ │ ├── __init__.py
85
+ │ │ ├── theme.py # Theme configuration
86
+ │ │ └── defaults.py # Default themes
87
+ │ └── updates/
88
+ │ ├── __init__.py
89
+ │ ├── operations.py # Update operations enum
90
+ │ └── messages.py # Update message types
91
+ ├── src/refast-client/ # React frontend package
92
+ │ ├── package.json
93
+ │ ├── tsconfig.json
94
+ │ ├── vite.config.ts
95
+ │ ├── tailwind.config.js # Tailwind CSS configuration
96
+ │ ├── postcss.config.js # PostCSS configuration
97
+ │ ├── src/
98
+ │ │ ├── index.tsx # Entry point (imports CSS)
99
+ │ │ ├── index.css # Tailwind directives + CSS variables
100
+ │ │ ├── App.tsx
101
+ │ │ ├── components/
102
+ │ │ │ ├── ComponentRenderer.tsx
103
+ │ │ │ └── shadcn/ # shadcn component wrappers
104
+ │ │ ├── events/
105
+ │ │ │ ├── EventManager.ts
106
+ │ │ │ ├── WebSocketClient.ts
107
+ │ │ │ └── types.ts
108
+ │ │ ├── session/
109
+ │ │ │ └── SessionManager.ts
110
+ │ │ ├── state/
111
+ │ │ │ └── StateManager.ts
112
+ │ │ └── utils/
113
+ │ │ └── index.ts
114
+ │ └── dist/ # Built assets (generated)
115
+ ├── tests/
116
+ │ ├── __init__.py
117
+ │ ├── conftest.py # Pytest fixtures
118
+ │ ├── unit/
119
+ │ │ ├── test_app.py
120
+ │ │ ├── test_components.py
121
+ │ │ ├── test_context.py
122
+ │ │ ├── test_events.py
123
+ │ │ ├── test_session.py
124
+ │ │ └── test_security.py
125
+ │ ├── integration/
126
+ │ │ ├── test_websocket.py
127
+ │ │ ├── test_full_flow.py
128
+ │ │ └── test_fastapi_integration.py
129
+ │ └── e2e/
130
+ │ ├── playwright.config.ts
131
+ │ └── specs/
132
+ │ ├── basic.spec.ts
133
+ │ └── events.spec.ts
134
+ ├── docs/ # Documentation (built with Refast!)
135
+ │ ├── app.py # Documentation app
136
+ │ ├── pages/
137
+ │ │ ├── index.py
138
+ │ │ ├── getting_started.py
139
+ │ │ ├── components.py
140
+ │ │ ├── events.py
141
+ │ │ ├── sessions.py
142
+ │ │ ├── security.py
143
+ │ │ └── api_reference.py
144
+ │ └── components/
145
+ │ ├── code_block.py
146
+ │ ├── api_doc.py
147
+ │ └── example.py
148
+ ├── examples/
149
+ │ ├── basic/
150
+ │ │ └── app.py
151
+ │ ├── todo_app/
152
+ │ │ └── app.py
153
+ │ ├── chat_app/
154
+ │ │ └── app.py
155
+ │ └── dashboard/
156
+ │ └── app.py
157
+ ├── pyproject.toml
158
+ ├── README.md
159
+ ├── LICENSE
160
+ └── CHANGELOG.md
161
+ ```
162
+
163
+ ---
164
+
165
+ ## AI Agent Guidelines
166
+
167
+ ### Before Starting Any Task
168
+
169
+ 1. **Read the relevant plan file** in `./plan/` for the stage you're working on
170
+ 2. **Check existing code** to understand current implementations
171
+ 3. **Review test files** to understand expected behavior
172
+ 4. **Check this file** for any recent structural changes
173
+
174
+ ### Code Style Requirements
175
+
176
+ #### Python Code
177
+
178
+ ```python
179
+ # Use type hints everywhere
180
+ from typing import Any, Callable, TypeVar, Generic
181
+
182
+ # Use Pydantic for data models
183
+ from pydantic import BaseModel, Field
184
+
185
+ class MyModel(BaseModel):
186
+ """Always include docstrings."""
187
+ name: str = Field(..., description="The name field")
188
+ value: int = Field(default=0, ge=0)
189
+
190
+ # Use async/await for all I/O operations
191
+ async def my_function(param: str) -> dict[str, Any]:
192
+ """
193
+ Brief description.
194
+
195
+ Args:
196
+ param: Description of param
197
+
198
+ Returns:
199
+ Description of return value
200
+
201
+ Raises:
202
+ ValueError: When param is invalid
203
+ """
204
+ pass
205
+
206
+ # Use explicit imports, not star imports
207
+ from refast.components import Button, Card, Container # Good
208
+ from refast.components import * # Bad
209
+ ```
210
+
211
+ #### TypeScript/React Code
212
+
213
+ ```typescript
214
+ // Use TypeScript strict mode
215
+ // Use functional components with hooks
216
+ // Use explicit prop types
217
+
218
+ interface ButtonProps {
219
+ label: string;
220
+ onClick?: () => void;
221
+ variant?: 'primary' | 'secondary' | 'ghost';
222
+ }
223
+
224
+ export function Button({ label, onClick, variant = 'primary' }: ButtonProps) {
225
+ return (
226
+ <button className={`btn-${variant}`} onClick={onClick}>
227
+ {label}
228
+ </button>
229
+ );
230
+ }
231
+ ```
232
+
233
+ #### Frontend Styling Requirements
234
+
235
+ > **CRITICAL**: The frontend must be production-ready. No bandaid fixes or workarounds.
236
+
237
+ 1. **Use Tailwind CSS** - All styling must use Tailwind CSS utility classes
238
+ 2. **Use shadcn/ui patterns** - Follow shadcn/ui component patterns and design tokens
239
+ 3. **No inline styles** - Never use inline `style` props for styling (except for truly dynamic values like calculated positions)
240
+ 4. **CSS Variables** - Use CSS custom properties for theming (defined in `src/index.css`)
241
+ 5. **Bundle CSS** - Tailwind CSS must be properly bundled with the build output
242
+
243
+ **Frontend Build Output Requirements:**
244
+ - `refast-client.js` - IIFE bundle with React and all dependencies included
245
+ - `refast-client.css` - Compiled Tailwind CSS with all used classes
246
+
247
+ **CSS Architecture:**
248
+ ```
249
+ src/refast-client/
250
+ ├── src/
251
+ │ ├── index.css # Tailwind directives + CSS variables
252
+ │ ├── index.tsx # Must import index.css
253
+ │ └── components/
254
+ │ └── shadcn/ # Components use Tailwind classes via cn() utility
255
+ ├── tailwind.config.js # Tailwind configuration with shadcn theme
256
+ ├── postcss.config.js # PostCSS with Tailwind plugin
257
+ └── vite.config.ts # Configured to output separate CSS file
258
+ ```
259
+
260
+ **Example Component (Correct):**
261
+ ```typescript
262
+ import { cn } from '../../utils';
263
+
264
+ export function Button({ variant = 'default', className, ...props }: ButtonProps) {
265
+ return (
266
+ <button
267
+ className={cn(
268
+ 'inline-flex items-center justify-center rounded-md font-medium',
269
+ 'bg-primary text-primary-foreground hover:bg-primary/90',
270
+ className
271
+ )}
272
+ {...props}
273
+ />
274
+ );
275
+ }
276
+ ```
277
+
278
+ **Example Component (WRONG - Never do this):**
279
+ ```typescript
280
+ // ❌ WRONG: Inline styles
281
+ export function Button({ ...props }: ButtonProps) {
282
+ return (
283
+ <button
284
+ style={{ backgroundColor: '#2563eb', color: 'white' }}
285
+ {...props}
286
+ />
287
+ );
288
+ }
289
+ ```
290
+
291
+ ### Testing Requirements
292
+
293
+ 1. **Unit Tests**: Every function/class must have unit tests
294
+ 2. **Integration Tests**: Test component interactions and WebSocket flows
295
+ 3. **E2E Tests**: Use Playwright for browser-based testing
296
+ 4. **Coverage**: Maintain >80% code coverage
297
+
298
+ ```python
299
+ # Test file naming: test_<module>.py
300
+ # Test function naming: test_<function>_<scenario>
301
+
302
+ import pytest
303
+ from refast import RefastApp
304
+
305
+ class TestRefastApp:
306
+ """Group related tests in classes."""
307
+
308
+ def test_create_app_with_defaults(self):
309
+ """Test description as docstring."""
310
+ app = RefastApp()
311
+ assert app.title == "Refast App"
312
+
313
+ @pytest.mark.asyncio
314
+ async def test_page_registration(self):
315
+ """Async tests need the marker."""
316
+ app = RefastApp()
317
+
318
+ @app.page("/")
319
+ def home(ctx):
320
+ return Container()
321
+
322
+ assert "/" in app.pages
323
+ ```
324
+
325
+ ### Documentation Requirements
326
+
327
+ 1. **Docstrings**: All public functions, classes, and modules
328
+ 2. **Type Hints**: Complete type annotations
329
+ 3. **Examples**: Include usage examples in docstrings
330
+ 4. **API Docs**: Auto-generated from docstrings
331
+ 5. **Guides**: Written in the docs app using Refast itself
332
+
333
+ ### When Making Changes
334
+
335
+ 1. **Update tests first** (TDD approach when possible)
336
+ 2. **Implement the feature**
337
+ 3. **Run all tests**: `pytest tests/`
338
+ 4. **Run linting**: `ruff check src/`
339
+ 5. **Update documentation** if API changes
340
+ 6. **Update this file** if structure changes
341
+
342
+ ---
343
+
344
+ ## Stage-by-Stage Implementation
345
+
346
+ See `./plan/` directory for detailed implementation plans:
347
+
348
+ | Stage | File | Description |
349
+ |-------|------|-------------|
350
+ | 1 | `stage-1-core.md` | Core framework (App, Router, Context) |
351
+ | 2 | `stage-2-components.md` | Component system and base components |
352
+ | 3 | `stage-3-events.md` | Event handling and WebSocket |
353
+ | 4 | `stage-4-sessions.md` | Session management |
354
+ | 5 | `stage-5-security.md` | Security features |
355
+ | 6 | `stage-6-frontend.md` | React frontend client |
356
+ | 7 | `stage-7-integration.md` | Full integration and examples |
357
+ | 8 | `stage-8-docs.md` | Documentation app |
358
+
359
+ ---
360
+
361
+ ## Common Patterns
362
+
363
+ ### Creating a New Component
364
+
365
+ ```python
366
+ # src/refast/components/shadcn/my_component.py
367
+
368
+ from refast.components.base import Component
369
+ from refast.events.types import Callback
370
+ from typing import Any
371
+
372
+ class MyComponent(Component):
373
+ """
374
+ Brief description of the component.
375
+
376
+ Example:
377
+ ```python
378
+ MyComponent(
379
+ title="Hello",
380
+ on_click=ctx.callback(handle_click)
381
+ )
382
+ ```
383
+
384
+ Args:
385
+ title: The title to display
386
+ on_click: Optional click callback
387
+ """
388
+
389
+ component_type: str = "MyComponent"
390
+
391
+ def __init__(
392
+ self,
393
+ title: str,
394
+ on_click: Callback | None = None,
395
+ id: str | None = None,
396
+ class_name: str = "",
397
+ **props: Any,
398
+ ):
399
+ super().__init__(id=id, class_name=class_name)
400
+ self.title = title
401
+ self.on_click = on_click
402
+ self.props = props
403
+
404
+ def render(self) -> dict[str, Any]:
405
+ return {
406
+ "type": self.component_type,
407
+ "id": self.id,
408
+ "props": {
409
+ "title": self.title,
410
+ "className": self.class_name,
411
+ "onClick": self.on_click.serialize() if self.on_click else None,
412
+ **self.props,
413
+ },
414
+ "children": self._render_children(),
415
+ }
416
+ ```
417
+
418
+ ### Creating a New Event Handler
419
+
420
+ ```python
421
+ # In the app definition
422
+
423
+ @ui.on_event("my:event")
424
+ async def handle_my_event(ctx: Context, event: Event):
425
+ """
426
+ Handle the my:event event.
427
+
428
+ Args:
429
+ ctx: The request context
430
+ event: The event data
431
+ """
432
+ # Process event
433
+ result = await process_event(event.data)
434
+
435
+ # Push update to client
436
+ await ctx.push_event("my:result", result)
437
+ ```
438
+
439
+ ### Adding a New Session Store
440
+
441
+ ```python
442
+ # src/refast/session/stores/my_store.py
443
+
444
+ from refast.session.stores.base import SessionStore
445
+ from typing import Any
446
+
447
+ class MyStore(SessionStore):
448
+ """Custom session store implementation."""
449
+
450
+ async def get(self, session_id: str) -> dict[str, Any] | None:
451
+ """Retrieve session data."""
452
+ pass
453
+
454
+ async def set(self, session_id: str, data: dict[str, Any], ttl: int) -> None:
455
+ """Store session data."""
456
+ pass
457
+
458
+ async def delete(self, session_id: str) -> None:
459
+ """Delete session data."""
460
+ pass
461
+
462
+ async def exists(self, session_id: str) -> bool:
463
+ """Check if session exists."""
464
+ pass
465
+ ```
466
+
467
+ ---
468
+
469
+ ## Updating This File
470
+
471
+ When the project structure changes:
472
+
473
+ 1. Update the "Current Project Structure" section
474
+ 2. Update any affected patterns or examples
475
+ 3. Update the stage plan files if needed
476
+ 4. Commit with message: `docs: update copilot instructions for [change]`
477
+
478
+ ### Structure Change Checklist
479
+
480
+ - [ ] Updated directory tree in this file
481
+ - [ ] Updated relevant plan stage file
482
+ - [ ] Updated examples if affected
483
+ - [ ] Updated test structure if affected
484
+ - [ ] Added migration notes if breaking change
485
+
486
+ ---
487
+
488
+ ## Environment Setup
489
+
490
+ Before running any commands, ensure uv is in your PATH:
491
+
492
+ ```powershell
493
+ $env:PATH = "t:\cae\ETT\pygkn-uv\;" + $env:PATH
494
+ ```
495
+
496
+ Then create and activate the virtual environment:
497
+
498
+ ```bash
499
+ # Create virtual environment
500
+ uv venv
501
+
502
+ # Install with dev dependencies
503
+ uv pip install -e ".[dev]"
504
+ ```
505
+
506
+ ---
507
+
508
+ ## Quick Reference
509
+
510
+ ### Running Tests
511
+
512
+ ```bash
513
+ # All tests (using uv)
514
+ uv run pytest tests/ tests/
515
+
516
+ # Specific stage
517
+ uv run pytest tests/unit/test_app.py
518
+
519
+ # With coverage
520
+ uv run pytest tests/ --cov=src/refast --cov-report=html
521
+
522
+ # E2E tests
523
+ cd src/refast-client && npx playwright test
524
+ ```
525
+
526
+ ### Running Linting
527
+
528
+ ```bash
529
+ # Python (using uv)
530
+ uv run ruff check src/
531
+ uv run ruff format src/
532
+
533
+ # TypeScript
534
+ cd src/refast-client && npm run lint
535
+ ```
536
+
537
+ ### Building
538
+
539
+ ```bash
540
+ # Python package
541
+ python -m build
542
+
543
+ # Frontend
544
+ cd src/refast-client && npm run build
545
+ ```
546
+
547
+ ### Running Documentation
548
+
549
+ ```bash
550
+ cd docs && uvicorn app:app --reload
551
+ ```
552
+
553
+ ---
554
+
555
+ ## Current Implementation Status
556
+
557
+ <!-- This section should be updated as stages are completed -->
558
+
559
+ | Stage | Status | Notes |
560
+ |-------|--------|-------|
561
+ | 1 - Core | 🟢 Complete | RefastApp, Router, Context, State implemented with 74 tests |
562
+ | 2 - Components | 🟢 Complete | Base, Registry, Slot, Layout, Input, Form, Feedback, Data Display, Typography - 154 tests |
563
+ | 3 - Events | 🟢 Complete | Event types, EventManager, WebSocket stream, BroadcastManager - 79 tests |
564
+ | 4 - Sessions | 🟢 Complete | Session, SessionData, MemoryStore, RedisStore, SessionMiddleware - 58 tests |
565
+ | 5 - Security | 🟢 Complete | CSRFProtection, RateLimiter, InputSanitizer, ContentSecurityPolicy, SecurityMiddleware - 125 tests |
566
+ | 6 - Frontend | 🟢 Complete | React client with ComponentRenderer, EventManager, WebSocket, StateManager, shadcn components - 60 tests |
567
+ | 7 - Integration | 🟢 Complete | Integration tests (26), asset bundling, 4 example apps (basic, todo, chat, dashboard), E2E test setup - 516 total tests |
568
+ | 8 - Documentation | 🔴 Not Started | |
569
+
570
+ Legend: 🔴 Not Started | 🟡 In Progress | 🟢 Complete
571
+
572
+ ---
573
+
574
+ ## Contact and Resources
575
+
576
+ - **Repository**: [GitHub URL]
577
+ - **Documentation**: Built with Refast (see `/docs`)
578
+ - **Examples**: See `/examples` directory
@@ -0,0 +1,25 @@
1
+ name: Upload Python Package
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ permissions:
8
+ contents: read
9
+
10
+ jobs:
11
+ deploy:
12
+
13
+ runs-on: ubuntu-latest
14
+ permissions:
15
+ id-token: write
16
+
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+
20
+ - name: Install uv and set the python version
21
+ uses: astral-sh/setup-uv@v5
22
+ - name: Build and Package
23
+ run: |
24
+ uv build
25
+ uv publish
@@ -0,0 +1,40 @@
1
+ # This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2
+ # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3
+
4
+ name: Python package
5
+
6
+ on:
7
+ push:
8
+ branches: [ "main" ]
9
+ pull_request:
10
+ branches: [ "main" ]
11
+
12
+ jobs:
13
+ build:
14
+ name: continuous-integration
15
+ runs-on: ubuntu-latest
16
+ strategy:
17
+ matrix:
18
+ python-version:
19
+ - "3.11"
20
+ - "3.12"
21
+ - "3.13"
22
+ - "3.14"
23
+ - "3.15"
24
+
25
+ steps:
26
+ - uses: actions/checkout@v4
27
+
28
+ - name: Install uv and set the python version
29
+ uses: astral-sh/setup-uv@v5
30
+ with:
31
+ python-version: ${{ matrix.python-version }}
32
+ - name: Install dependencies
33
+ run: |
34
+ uv sync
35
+ - name: Lint with ruff
36
+ run: |
37
+ uvx ruff check src/refast
38
+ - name: Test with pytest
39
+ run: |
40
+ uv run pytest tests