Conversation
…d adding cheat_sheet code blocks
BREAKING CHANGES: - Rename formula selection to require class + category + formula - API endpoint /api/generate-sheet/ now accepts formulas array NEW FEATURES: - 3-level formula selection: class → category → individual formulas - Updated UI with class checkboxes and category dropdowns - Added CRUD API endpoints for templates, cheatsheets, and problems - Added /api/cheatsheets/from-template/ endpoint - Added ruff and safety to requirements for linting/security CLEANUP: - Removed unused packages: axios, react-router-dom, eslint - Renamed old formula_loader.py to .old - Added AGENTS.md and session files to .gitignore - Simplified CI workflow (removed ESLint step) - Updated README with current dependencies DATA: - Added formula_data/ with 4 classes: PRE-ALGEBRA, ALGEBRA I, ALGEBRA II, GEOMETRY - Each class organized by category with hardcoded formulas FIXES: - All 20 tests now pass - Compile endpoint supports both content and cheat_sheet_id - Fixed PDF generation with proper LaTeX template
Deleted ~206 lines of unused CSS classes that were remnants from the old subject/category/formula tab interface: - .subjects-container, .subject-tabs, .subject_tab - .category-tabs, .category_tab, .formula_btn - .selection_tree, .class_block, .class_header - .category_list, .formula_list, and related styles App.css reduced from 447 lines to 241 lines (~45% reduction).
- Update category selection to always-visible checkboxes, remove dropdowns and secondary scrollbars - Maximize LaTeX and PDF panes, remove width/padding constraints - Fix all race conditions (useRef locks, fresh LaTeX to compile) - Button disabling is robust, no overlapping requests - Add GitHub link to footer - Update .gitignore for secrets, coverage, PDF/TeX, DB, and temp files - Revise README and backend logic for new features and stability
…<br/> and | from node labels)
Removed architecture diagram from the README.
…eanup frontend config - backend: switch DB adapter from PyMySQL to mysqlclient for better native compatibility (requirements.txt, Dockerfile, .env.docker, __init__.py) - docker-compose: add backend healthcheck, cleanup db service port/depends_on config - frontend: remove unused deps (axios, react-router-dom, ESLint plugins) and trim package-lock.json - general: remove dead or unneeded config/ports, reflect changes in compose and build scripts BREAKING: MySQL backend now expects mysqlclient and native driver; PyMySQL removed
There was a problem hiding this comment.
Pull request overview
This PR advances the app from a basic cheat sheet editor toward a “cheat sheet generator” workflow by adding backend-driven formula selection, LaTeX generation, PDF compilation support, and a Docker/CI overhaul to support MariaDB + pytest tooling.
Changes:
- Frontend: replaces hardcoded formula picker with a backend-driven class/category selection UI and adds PDF/TeX download + preview workflow.
- Backend: adds formula data modules, new
/api/classes/+/api/generate-sheet/endpoints, plus CRUD models/serializers/endpoints and pytest-based tests. - Infra/CI: introduces MariaDB in Compose, switches DB config to
DATABASE_URL(dj-database-url), and updates CI to run ruff/safety/pytest.
Reviewed changes
Copilot reviewed 28 out of 31 changed files in this pull request and generated 16 comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/vite.config.js | Updates dev proxy target and binds dev server to 0.0.0.0. |
| frontend/src/components/CreateCheatSheet.jsx | New generator UI: fetch classes, select categories, generate LaTeX, compile/preview, download. |
| frontend/src/App.jsx | Updates app title and adds a GitHub footer link. |
| frontend/src/App.css | Large styling refresh with CSS variables, new selection UI styles, and footer styles. |
| frontend/package.json | Removes ESLint-related dev dependencies. |
| frontend/package-lock.json | Lockfile updates reflecting dependency removals/updates. |
| docker-compose.yml | Adds MariaDB service, wires backend DATABASE_URL, adds backend healthcheck and frontend dependency on healthy backend. |
| backend/requirements.txt | Adds dj-database-url, mysqlclient, pytest tooling, ruff, safety. |
| backend/pytest.ini | Configures pytest-django settings module and test discovery patterns. |
| backend/conftest.py | Adds shared api_client pytest fixture. |
| backend/cheat_sheet/settings.py | Switches DB config to dj_database_url with SQLite fallback; minor env parsing formatting. |
| backend/api/views.py | Adds formula endpoints, LaTeX generation helper, compile enhancements, and CRUD endpoints. |
| backend/api/urls.py | Registers new formula and CRUD routes. |
| backend/api/tests.py | Adds pytest-based model/API tests. |
| backend/api/serializers.py | Implements DRF serializers for new models and compile request validation serializer. |
| backend/api/models.py | Adds Template/CheatSheet/PracticeProblem models and LaTeX assembly logic. |
| backend/api/migrations/0001_initial.py | Initial schema migration for new models. |
| backend/api/formula_loader.py.old | Adds a legacy/unused formula loader (backup-style file). |
| backend/api/formula_data/init.py | Aggregates available classes and formula data helpers. |
| backend/api/formula_data/pre_algebra.py | Adds PRE-ALGEBRA formula definitions. |
| backend/api/formula_data/algebra_i.py | Adds ALGEBRA I formula definitions. |
| backend/api/formula_data/algebra_ii.py | Adds ALGEBRA II formula definitions. |
| backend/api/formula_data/geometry.py | Adds GEOMETRY formula definitions. |
| backend/api/apps.py | Adds API app config. |
| backend/api/admin.py | Adds (commented-out) Django admin registrations. |
| backend/Dockerfile | Installs MySQL build deps and waits for MariaDB before starting Django. |
| backend/.env.docker | Updates docker env defaults and adds DATABASE_URL. |
| README.md | Rewrites docs to match generator workflow, endpoints, and setup guidance. |
| .gitignore | Expands ignores for env/test artifacts and TeX/PDF build outputs. |
| .github/workflows/ci.yml | Updates backend CI to run ruff/safety/pytest and simplifies frontend CI to build-only. |
Files not reviewed (1)
- frontend/package-lock.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const toggleClass = (className) => { | ||
| setSelectedClasses((prev) => { | ||
| const newSelected = { ...prev }; | ||
| if (newSelected[className]) { | ||
| delete newSelected[className]; | ||
| // Clear categories for this class | ||
| Object.keys(selectedCategories).forEach((key) => { | ||
| if (key.startsWith(className + ':')) { | ||
| delete newSelected[key]; | ||
| } | ||
| }); |
There was a problem hiding this comment.
toggleClass tries to clear selected categories when a class is unchecked, but it deletes category keys from newSelected (which is the selected-classes map), so category selections are never removed. This also reads selectedCategories from the outer scope inside a state updater, which can be stale. Clear category keys via setSelectedCategories (using its own functional updater) when a class is deselected.
There was a problem hiding this comment.
@copilot open a new pull request to apply changes based on this feedback
| ### Backend Dependencies | ||
| - django>=6.0 | ||
| - djangorestframework>=3.15 | ||
| - django-cors-headers>=4.4 | ||
| - python-dotenv>=1.0 | ||
| - dj-database-url>=2.1 | ||
| - pymysql>=1.1 | ||
| - pytest>=8.0 | ||
| - pytest-django>=4.8 | ||
| - ruff>=0.4.0 (linting) | ||
| - safety>=2.0 (security) | ||
|
|
There was a problem hiding this comment.
README lists pymysql>=1.1 as a backend dependency, but the actual backend dependency in backend/requirements.txt is mysqlclient (and pymysql is not listed). Update the README dependency list to match the real requirements to avoid confusing setup/install instructions.
There was a problem hiding this comment.
@copilot open a new pull request to apply changes based on this feedback
| <footer className="app-footer"> | ||
| <a href="https://github.com/ChicoState/cheat-sheet" target="_blank" rel="noopener noreferrer" title="View on GitHub"> | ||
| <svg height="24" viewBox="0 0 16 16" width="24" fill="currentColor"> | ||
| <path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"/> | ||
| </svg> | ||
| </a> |
There was a problem hiding this comment.
The footer link is icon-only, so screen readers may not announce a meaningful name. Add an accessible label (e.g., aria-label="View on GitHub") and/or visually-hidden text so the link has a proper accessible name beyond the SVG.
| except subprocess.CalledProcessError as e: | ||
| return Response({"error": "Failed to compile LaTeX", "details": e.stderr}, status=400) | ||
|
|
||
| return Response( | ||
| {"error": "Failed to compile LaTeX", "details": e.stderr}, | ||
| status=400, | ||
| ) |
There was a problem hiding this comment.
compile_latex returns raw Tectonic stderr in the API response (details). This can leak internal paths/environment info and can also produce very large responses on compile failures. Consider logging stderr server-side and returning a shorter, user-friendly error message (optionally gated behind DEBUG).
| import react from '@vitejs/plugin-react' | ||
|
|
||
| const backendTarget = process.env.BACKEND_URL || 'http://localhost:8000' | ||
| const backendTarget = process.env.BACKEND_URL || 'http://backend:8000' |
There was a problem hiding this comment.
Defaulting BACKEND_URL to http://backend:8000 will break local (non-Docker) development where the Django server runs on localhost:8000 (per README). Consider defaulting to http://localhost:8000 and setting BACKEND_URL=http://backend:8000 in docker-compose for container runs (or otherwise detecting Docker env).
There was a problem hiding this comment.
@copilot open a new pull request to apply changes based on this feedback
| # ports: comment out for now we'e not using atm | ||
| # - "3306:3306" |
There was a problem hiding this comment.
The comment we'e is a typo and should be we're.
There was a problem hiding this comment.
@copilot open a new pull request to apply changes based on this feedback
| environment: | ||
| MYSQL_ROOT_PASSWORD: rootpass | ||
| MYSQL_DATABASE: cheatsheet_db | ||
| MYSQL_USER: cheatsheet_user | ||
| MYSQL_PASSWORD: cheatsheet_pass |
There was a problem hiding this comment.
Database credentials are hard-coded directly in docker-compose.yml (including the root password). Even if intended for local dev, this pattern makes it easy to accidentally reuse weak credentials elsewhere and encourages copying secrets into source control. Prefer using a .env file (not committed) or compose variable substitution with documented defaults for local development.
| ### Frontend (ESLint) | ||
|
|
||
| ```bash | ||
| cd frontend | ||
| npx eslint src/ # Lint source files | ||
| npx eslint --fix src/ # Auto-fix lint issues | ||
| ``` | ||
|
|
||
| ### CI Pipeline | ||
|
|
||
| The project includes GitHub Actions CI that runs: | ||
| - Backend: Ruff linting, Safety security scan, pytest | ||
| - Frontend: ESLint, build verification | ||
| - Docker: Image build verification |
There was a problem hiding this comment.
README states the CI pipeline and local instructions use ESLint (npx eslint …) and that CI runs ESLint, but the workflow currently only runs npm run build and eslint packages were removed from frontend/package.json. Either re-add/configure ESLint (and a CI lint step) or update the README section to reflect the current tooling.
There was a problem hiding this comment.
@copilot open a new pull request to apply changes based on this feedback
| <button | ||
| type="button" | ||
| onClick={handlePreview} | ||
| className="btn compile-circle" | ||
| disabled={isCompiling || !content} | ||
| title={isCompiling ? 'Compiling...' : 'Compile & Preview'} | ||
| > | ||
| {isCompiling ? '...' : '↻'} | ||
| </button> |
There was a problem hiding this comment.
The compile/preview button uses only the ↻ character as its visible label. For accessibility, add an aria-label (or include visually-hidden text) so screen readers can announce the button purpose.
| EXPOSE 8000 | ||
|
|
||
| CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"] | ||
| CMD ["sh", "-c", "until mysqladmin ping -hdb -ucheatsheet_user -pcheatsheet_pass --silent; do sleep 2; done && python manage.py runserver 0.0.0.0:8000"] |
There was a problem hiding this comment.
The Docker CMD hard-codes DB credentials in the image (mysqladmin ping ... -ucheatsheet_user -pcheatsheet_pass). This leaks credentials into the image history and process list. Prefer reading credentials from environment variables (or relying on DATABASE_URL) when waiting for DB readiness.
There was a problem hiding this comment.
@copilot open a new pull request to apply changes based on this feedback
|
@bdtran2002 I've opened a new pull request, #21, to work on those changes. Once the pull request is ready, I'll request review from you. |
|
@bdtran2002 I've opened a new pull request, #22, to work on those changes. Once the pull request is ready, I'll request review from you. |
|
@bdtran2002 I've opened a new pull request, #23, to work on those changes. Once the pull request is ready, I'll request review from you. |
|
@bdtran2002 I've opened a new pull request, #24, to work on those changes. Once the pull request is ready, I'll request review from you. |
|
@bdtran2002 I've opened a new pull request, #25, to work on those changes. Once the pull request is ready, I'll request review from you. |
|
@bdtran2002 I've opened a new pull request, #26, to work on those changes. Once the pull request is ready, I'll request review from you. |
|
@bdtran2002 I've opened a new pull request, #27, to work on those changes. Once the pull request is ready, I'll request review from you. |
We movin fellas we making it out of chico w this one 🔥
READ THE README AND THIS CHANGELOG BEFORE MAKING CHANGES
Major Changes:
Bugfixes & Known Issues (added in this PR or roadmap)
Documentation & Dev-Ex
Breaking/Deprecating
How to Review