-
Notifications
You must be signed in to change notification settings - Fork 3
Brandon sprint1 #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Brandon sprint1 #20
Changes from all commits
f3d9bfd
99fe247
acc4abc
67403bc
edf4b2a
d80d5eb
dfc720d
3c3678d
b37be2d
490fa5c
09085b1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,32 +1,129 @@ | ||
| # cheat-sheet | ||
| # Cheat Sheet Generator | ||
|
|
||
| [](https://github.com/ChicoState/cheat-sheet/actions/workflows/ci.yml) | ||
|
|
||
| A full-stack web application built with **React** (frontend) and **Django** (backend). | ||
| A full-stack web application for generating LaTeX-based cheat sheets. Users select math classes and formula categories, then view the generated LaTeX code alongside a live PDF preview. | ||
|
|
||
| ## Features | ||
|
|
||
| - **Class Selection**: Choose from PRE-ALGEBRA, ALGEBRA I, ALGEBRA II, and GEOMETRY | ||
| - **Category Selection**: Select categories with checkboxes (no Ctrl/Cmd needed) | ||
| - **Live Preview**: Split-view interface with LaTeX code and PDF preview | ||
| - **Auto-compile**: PDF generates automatically when you generate a cheat sheet | ||
| - **PDF Export**: Compile to PDF using Tectonic LaTeX engine on the backend | ||
| - **Download Options**: Download as .tex source or .pdf | ||
|
|
||
|
|
||
| ## To-Do / Known Issues | ||
|
|
||
| - Fix bugs: | ||
| - Dark mode (complete variable coverage, remove hardcoded colors) | ||
| - Compile button not working after changes | ||
| - Implement or migrate database (currently MariaDB; consider migration if needed) | ||
| - Increase formatting options (columns, margins, text sizing, etc.) | ||
|
|
||
|
|
||
| ## Planned Features | ||
|
|
||
| > These features are not yet implemented | ||
|
|
||
| - **Formatting Options**: | ||
| - Column layout (single, two, three columns) | ||
| - Text sizes (font scaling) | ||
| - Margin adjustments | ||
| - **Image Insertion**: | ||
| - Allow users to insert images, store them in the database | ||
| - Embed images in PDF and keep code reference in exported .tex | ||
| - **User Accounts**: Register and log in with username and password | ||
| - **Database Storage**: Save and manage cheat sheets in database | ||
| - **Autosave & Version History**: Every compile is saved automatically; revert to any previous version | ||
| - **Custom LaTeX Syntax Shortcuts**: Allow users to use shortcuts for custom LaTeX commands | ||
|
|
||
| ## Tech Stack | ||
|
|
||
| | Layer | Technology | | ||
| |-------|------------| | ||
| | Frontend | React 18 + Vite + npm | | ||
| | Backend | Django 6 + Django REST Framework | | ||
| | LaTeX Engine | Tectonic | | ||
| | Database | SQLite (dev) / MariaDB (prod) | | ||
| | Container | Docker Compose | | ||
|
|
||
| ### 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) | ||
|
|
||
| ### Frontend Dependencies | ||
| - react, react-dom | ||
| - vite | ||
|
|
||
| ## Project Structure | ||
|
|
||
| ``` | ||
| ├── backend/ # Django REST API | ||
| │ ├── cheat_sheet/ # Django project settings | ||
| │ ├── api/ # Main API app | ||
| │ ├── manage.py | ||
| │ └── requirements.txt | ||
| ├── frontend/ # React + Vite | ||
| ├── backend/ # Django REST API | ||
| │ ├── cheat_sheet/ # Django project settings | ||
| │ ├── api/ # API app | ||
| │ │ ├── views.py # API endpoints | ||
| │ │ ├── models.py # Database models | ||
| │ │ ├── formula_data/ # Hardcoded formula data | ||
| │ │ │ ├── pre_algebra.py | ||
| │ │ │ ├── algebra_i.py | ||
| │ │ │ ├── algebra_ii.py | ||
| │ │ │ └── geometry.py | ||
| │ ├── requirements.txt # Python dependencies | ||
| │ ├── Dockerfile # Backend container | ||
| │ └── manage.py | ||
| ├── frontend/ # React + Vite | ||
| │ ├── src/ | ||
| │ │ ├── App.jsx # Main app component | ||
| │ │ ├── components/ | ||
| │ │ │ └── CreateCheatSheet.jsx # Main UI | ||
| │ │ └── App.css | ||
| │ ├── package.json | ||
| │ └── vite.config.js | ||
| │ ├── vite.config.js | ||
| │ └── Dockerfile | ||
| ├── docker-compose.yml # Container orchestration | ||
| └── README.md | ||
| ``` | ||
|
|
||
| ## API Endpoints | ||
|
|
||
| | Method | Endpoint | Description | | ||
| |--------|----------|-------------| | ||
| | GET | `/api/health/` | Health check | | ||
| | GET | `/api/classes/` | List available classes with categories and formulas | | ||
| | POST | `/api/generate-sheet/` | Generate LaTeX for selected formulas | | ||
| | POST | `/api/compile/` | Compile LaTeX to PDF | | ||
|
|
||
| ### Available Formula Classes | ||
|
|
||
| - **PRE-ALGEBRA** - Order of Operations, Fractions, Ratios, Properties, Area/Perimeter, Solving Equations | ||
| - **ALGEBRA I** - Linear Equations, Inequalities, Integer Rules, Decimals/Percents, Mean/Median/Mode, Quadratics, Polynomials, Exponents, Radicals, Functions, Absolute Value, Rational Expressions | ||
| - **ALGEBRA II** - Complex Numbers, Logarithms, Exponential Functions, Polynomial Theorems, Conic Sections, Sequences/Series, Matrices, Binomial Theorem | ||
| - **GEOMETRY** - Angle Relationships, Parallel Lines, Triangles, Pythagorean Theorem, Similar/Congruent Triangles, Quadrilaterals, Polygons, Circles, Circle Theorems, Coordinate Geometry, Surface Area/Volume, Transformations | ||
|
|
||
| ## Getting Started | ||
|
|
||
| ### Prerequisites | ||
|
|
||
| - Python 3.13+ | ||
| - Node.js 20+ | ||
| - Tectonic (for PDF compilation) | ||
|
|
||
| ### Backend | ||
|
|
||
| ```bash | ||
| cd backend | ||
| python -m venv venv | ||
| source venv/bin/activate | ||
| source venv/bin/activate # On Windows: venv\Scripts\activate | ||
| pip install -r requirements.txt | ||
| python manage.py migrate | ||
| python manage.py runserver | ||
|
|
@@ -42,12 +139,48 @@ npm install | |
| npm run dev | ||
| ``` | ||
|
|
||
| The frontend will be available at `http://localhost:5173/`. | ||
|
|
||
| ### Docker | ||
|
|
||
| ```bash | ||
| docker compose up --build | ||
| ``` | ||
|
|
||
| This will build and start both the Django backend and the React frontend services using Docker. | ||
| This builds and starts the Django backend, React frontend, and MariaDB database. | ||
|
|
||
| The app will be available at `http://localhost:5173/`. API requests are proxied to the Django backend. | ||
|
|
||
| ## Running Tests | ||
|
|
||
| ### Backend (pytest) | ||
|
|
||
| ```bash | ||
| cd backend | ||
| pytest -v # Run with verbose output | ||
| pytest -k "test_name" # Run tests matching pattern | ||
| ``` | ||
|
|
||
| ### 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 | ||
|
Comment on lines
+164
to
+177
|
||
|
|
||
| ## User Flow | ||
|
|
||
| 1. **Enter Title**: Give your cheat sheet a name | ||
| 2. **Select Class**: Click on a class (PRE-ALGEBRA, ALGEBRA I, ALGEBRA II, GEOMETRY) | ||
| 3. **Select Categories**: Check the categories you want (no Ctrl/Cmd needed) | ||
| 4. **Generate**: Click "Generate Cheat Sheet" - LaTeX generates and PDF compiles automatically | ||
| 5. **Preview**: View the PDF in the preview pane, or click the circular button to recompile | ||
| 6. **Download**: Download as .tex or .pdf | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,8 @@ | ||
| # Example Docker environment configuration for Django. | ||
| # Set a strong, unique value for DJANGO_SECRET_KEY via environment variables in each environment. | ||
| # Docker environment configuration for Django. | ||
| DJANGO_SECRET_KEY= | ||
| DJANGO_DEBUG=True | ||
| DJANGO_ALLOWED_HOSTS=localhost,127.0.0.1,0.0.0.0 | ||
| DJANGO_ALLOWED_HOSTS=localhost,127.0.0.1,0.0.0.0,backend | ||
| CORS_ALLOWED_ORIGINS=http://localhost:3000,http://localhost:5173 | ||
|
|
||
| # MariaDB connection (matches the db service in docker-compose.yml) | ||
| DATABASE_URL=mysql://cheatsheet_user:cheatsheet_pass@db:3306/cheatsheet_db |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| wget \ | ||
| tar \ | ||
| fontconfig \ | ||
| default-libmysqlclient-dev \ | ||
| pkg-config \ | ||
| gcc \ | ||
| default-mysql-client \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Download and extract the appropriate Tectonic binary | ||
|
|
@@ -31,4 +35,4 @@ COPY . . | |
|
|
||
| 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"] | ||
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
|
|
||
|
|
||
|
|
||
| #from django.contrib import admin | ||
| #from .models import Template, CheatSheet, PracticeProblem | ||
| # | ||
| # | ||
| #@admin.register(Template) | ||
| #class TemplateAdmin(admin.ModelAdmin): | ||
| # list_display = ("name", "subject", "default_columns", "default_margins", "updated_at") | ||
| # list_filter = ("subject",) | ||
| # search_fields = ("name", "description") | ||
|
Comment on lines
+1
to
+12
|
||
| # | ||
| # | ||
| #class PracticeProblemInline(admin.TabularInline): | ||
| # model = PracticeProblem | ||
| # extra = 1 | ||
| # | ||
| # | ||
| #@admin.register(CheatSheet) | ||
| #class CheatSheetAdmin(admin.ModelAdmin): | ||
| # list_display = ("title", "template", "columns", "margins", "font_size", "updated_at") | ||
| # list_filter = ("template",) | ||
| # search_fields = ("title",) | ||
| # inlines = [PracticeProblemInline] | ||
| # | ||
| # | ||
| #@admin.register(PracticeProblem) | ||
| #class PracticeProblemAdmin(admin.ModelAdmin): | ||
| # list_display = ("cheat_sheet", "order", "question_latex") | ||
| # list_filter = ("cheat_sheet",) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| from django.apps import AppConfig | ||
|
|
||
|
|
||
| class ApiConfig(AppConfig): | ||
| default_auto_field = "django.db.models.BigAutoField" | ||
| name = "api" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| """ | ||
| Formula data organized by class and category. | ||
| Each module exports FORMULAS dict and CLASS_NAME. | ||
| """ | ||
|
|
||
| from .pre_algebra import FORMULAS as PRE_ALGEBRA, CLASS_NAME as PRE_ALGEBRA_NAME | ||
| from .algebra_i import FORMULAS as ALGEBRA_I, CLASS_NAME as ALGEBRA_I_NAME | ||
| from .algebra_ii import FORMULAS as ALGEBRA_II, CLASS_NAME as ALGEBRA_II_NAME | ||
| from .geometry import FORMULAS as GEOMETRY, CLASS_NAME as GEOMETRY_NAME | ||
|
|
||
| AVAILABLE_CLASSES = [PRE_ALGEBRA_NAME, ALGEBRA_I_NAME, ALGEBRA_II_NAME, GEOMETRY_NAME] | ||
|
|
||
| FORMULA_DATA = { | ||
| PRE_ALGEBRA_NAME: PRE_ALGEBRA, | ||
| ALGEBRA_I_NAME: ALGEBRA_I, | ||
| ALGEBRA_II_NAME: ALGEBRA_II, | ||
| GEOMETRY_NAME: GEOMETRY, | ||
| } | ||
|
|
||
|
|
||
| def get_formula_data(): | ||
| """Return the full formula data structure.""" | ||
| return FORMULA_DATA | ||
|
|
||
|
|
||
| def get_available_classes(): | ||
| """Return list of available class names.""" | ||
| return AVAILABLE_CLASSES | ||
|
|
||
|
|
||
| def get_classes_with_details(): | ||
| """Return full structure with classes, categories, and formulas.""" | ||
| return [ | ||
| { | ||
| "name": class_name, | ||
| "categories": [ | ||
| {"name": cat_name, "formulas": formulas} | ||
| for cat_name, formulas in categories.items() | ||
| ] | ||
| } | ||
| for class_name, categories in FORMULA_DATA.items() | ||
| ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
README lists
pymysql>=1.1as a backend dependency, but the actual backend dependency inbackend/requirements.txtismysqlclient(andpymysqlis 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot open a new pull request to apply changes based on this feedback