Skip to content

Commit d6e9c73

Browse files
authored
Add support to obfuscate the code (#148)
* Add support to obfuscate the code When building the native application, the code is now obfuscated * Support disable obfuscation if needed
1 parent 733a5f0 commit d6e9c73

File tree

9 files changed

+369
-151
lines changed

9 files changed

+369
-151
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ portfolio-performance/*.csv
153153
portfolio-performance/*.pdf
154154

155155
/src/stonks_overwatch/static/
156+
/src/obfuscated/
156157
/src/stonks_overwatch.dist-info
157158

158159
# Ignore IBKR certificates

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
### Changed
1313

14+
* Improved License dialog
15+
1416
### Deprecated
1517

1618
### Removed

Makefile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ DEBUG_MODE := $(if $(debug),true,false)
2222
PROFILE_MODE := $(if $(profile),true,false)
2323
DEMO_MODE := $(if $(demo),true,false)
2424

25+
# Obfuscation flag (default: true, can be overridden with obfuscate=false)
26+
OBFUSCATE_MODE := $(if $(obfuscate),$(obfuscate),true)
27+
2528
# Export variables for child processes
26-
export DEBUG_MODE PROFILE_MODE DEMO_MODE
29+
export DEBUG_MODE PROFILE_MODE DEMO_MODE OBFUSCATE_MODE
2730

2831
# Color codes for output
2932
BOLD := \033[1m
@@ -217,7 +220,12 @@ _create-wheels: ## Internal: Create wheel files for Briefcase
217220
done; \
218221
done
219222

220-
briefcase-create: install collectstatic _create-wheels ## Create Briefcase project
223+
obfuscate: ## Obfuscate code for Briefcase packaging (use obfuscate=false to disable)
224+
@echo -e "$(BOLD)$(BLUE)Obfuscating code for Briefcase...$(RESET)"
225+
@echo -e "$(YELLOW)Obfuscate Code: $(OBFUSCATE_MODE)$(RESET)"
226+
bash scripts/obfuscate.sh
227+
228+
briefcase-create: install collectstatic _create-wheels obfuscate ## Create Briefcase project
221229
@echo -e "$(BOLD)$(GREEN)Creating Briefcase project...$(RESET)"
222230
rm -rf build
223231
poetry run briefcase create

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ See [Wiki - Developing Stonks Overwatch](./docs/Developing-Stonks-Overwatch)
7777
* Bitvavo - Known Bugs:
7878
* When an asset is Staking, the balance value is the 'available' value, not the 'total' value
7979
* Transactions done with the RFQ system are not returned by the Bitvavo Transactions API
80+
* Pyarmor:
81+
* Logs show an odd `<frozen stonks_overwatch.utils.core` in the logs.
8082

8183
## TODOs
8284

docs/Developing-Stonks-Overwatch.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,3 +187,5 @@ the code will create files in the next paths:
187187
- STONKS_OVERWATCH_CACHE_DIR: `/Users/$USER/Library/Caches/com.caribay.stonks_overwatch`
188188

189189
It's possible to easily delete them with `make briefcase-clean`
190+
191+
The Briefcase application is obfuscated with Pyarmor by default, if needed, you can disable it with `make briefcase-package obfuscate=false`

instructions.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Project Overview
2+
3+
This project is a Python-based application that allows users to manage their investment portfolios across multiple brokers, including DEGIRO, Bitvavo, and IBKR.
4+
5+
## Project Setup
6+
- Install [Poetry](https://python-poetry.org/) if not already installed.
7+
- Run `poetry install` to install dependencies.
8+
- Copy `config/config.json.template` to `config/config.json` and update as needed.
9+
- Set up environment variables as described in `docs/Configuration-Integration.md`.
10+
- To run the application:
11+
- For the web app: `poetry run python src/manage.py runserver`
12+
- For scripts: `poetry run python scripts/<script_name>.py`
13+
- To run tests: `poetry run pytest`
14+
15+
## Folder Structure
16+
- `config/`: Configuration files. Used only for local development.
17+
- `data/`: Database, logs and data files
18+
- `docs/`: Project documentation
19+
- `scripts/`: Utility scripts
20+
- `tests/`: Unit and integration tests
21+
- `src/`: Main application code
22+
- `src/icons/`: Folder with the icons to use in the local application
23+
- `src/stonks_overwatch/`: Main application package
24+
- `src/stonks_overwatch/app/`: Folder for the local application logic and UI. This folder mainly uses Toga for the UI.
25+
- `src/stonks_overwatch/config/`: Configuration data for the different brokers
26+
- `src/stonks_overwatch/core/`: Core logic of the application
27+
- `src/stonks_overwatch/staticfiles/`: Static files for the web application. Includes icons, stylesheets, and JavaScript files.
28+
- `src/stonks_overwatch/templates/`: Django HTML templates for the web application.
29+
- `src/stonks_overwatch/utils/`: Utility functions and classes.
30+
- `src/stonks_overwatch/views/`: Views for the web application.
31+
32+
## Coding Standards
33+
- **Language:** Python 3.9+
34+
- **Formatting:** Use [PEP8](https://www.python.org/dev/peps/pep-0008/) style. Auto-format with `ruff`.
35+
- **Type Hints:** Use type annotations where possible.
36+
- **Naming:**
37+
- Variables/functions: `snake_case`
38+
- Classes: `PascalCase`
39+
- Constants: `UPPER_CASE`
40+
- **Comments:** Write clear, concise docstrings for all public functions and classes.
41+
42+
## Libraries and Frameworks
43+
- **Web Framework:** Django (for web application)
44+
- **Database:** SQLite (default), can be changed to PostgreSQL or MySQL if needed
45+
- **Asynchronous Tasks:** Celery (if needed for background tasks)
46+
- **API Requests:** `requests` for HTTP requests
47+
- **Data Processing:** `pandas` for data manipulation and analysis
48+
- **Logging:** Use Python's built-in `logging` module for logging errors and information.
49+
- **Environment Variables:** Use `python-dotenv` to manage environment variables in development.
50+
- **Testing:** Use `pytest` for unit and integration tests.
51+
- **Dependency Management:** Use [Poetry](https://python-poetry.org/) for managing project dependencies.
52+
- **Linting:** Use `ruff` for linting the codebase.
53+
- **HTML Framework:** Use Bootstrap for HTML widgets and styling.
54+
- **UI Framework:** Use Toga for the native application UI.
55+
56+
## Best Practices
57+
- Write tests for all new features and bug fixes.
58+
- Handle exceptions gracefully and log errors.
59+
- Use environment variables for secrets and credentials.
60+
- Keep functions small and focused.
61+
- Document all public APIs and modules.
62+
63+
## Copilot Usage
64+
- Use Copilot to generate code, tests, and documentation following the standards above.
65+
- Example prompts:
66+
- "Add a function to fetch account balance from the database."
67+
- "Write a pytest for the currency converter service."
68+
- "Document the Bitvavo integration module."
69+
- Avoid using deprecated libraries or hardcoding secrets.
70+
- Prefer modular, well-documented code and small, focused functions.
71+
72+
## Contribution Guidelines
73+
- Fork the repository and create a feature branch.
74+
- Write or update tests for all new features.
75+
- Ensure all tests pass with `pytest` before submitting a PR.
76+
- Open a pull request and request review.
77+
- Follow the coding standards and best practices outlined above.
78+
79+
## Restrictions
80+
- Do not use deprecated or unmaintained libraries.
81+
- Avoid hardcoding secrets or credentials.
82+
- Do not commit generated data or secrets to version control.
83+
- Follow the existing project structure and conventions.
84+
85+
---

0 commit comments

Comments
 (0)