Refactor: Project structure to MVVM. Add: Basic scaffolding for data service and gui. Add: Build and Utility scripts.
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
# Study Dashboard – Agent Instructions
|
||||
|
||||
This document summarizes the project conventions and provides a hand-off for the next sprint. When starting new work, follow these steps before touching any code:
|
||||
|
||||
1. **Read the docs**: review `README.md`, `docs/architecture.md`, and this file to understand the stack (PySide6, MVVM, dependency-injector, SQLite seed DB).
|
||||
2. **Prepare the env**: run `bash scripts/bootstrap.sh` to create/update `.venv`. Use the helper scripts (`bash scripts/run-app.sh`, `bash scripts/run-qa.sh`) so env vars and caches are handled automatically.
|
||||
3. **Run tests by default**: `bash scripts/run-qa.sh` executes pytest, mypy, flake8, and black in one go (forward extra pytest args as needed). Add or extend tests alongside code.
|
||||
|
||||
## Guiding Principles
|
||||
|
||||
- **Architecture**: MVVM with a thin PySide6 view (`gui/main_view.py`), a Qt-based ViewModel (`gui/main_view_model.py`), and a repository layer backed by SQLite. All data access goes through `StudyRepository`.
|
||||
- **Dependency injection**: extend `src/study_dashboard/di_container.py` when adding new services or ViewModels. Create providers for configs beforehand.
|
||||
- **Database**: the bootstrapper auto-creates `study.db` with seed data. When schema changes, update `services/database.py` and adjust tests.
|
||||
- **Generated files**: everything temporary belongs under `bin/` (already git-ignored). The PySide deploy spec lives in `deploy/pysidedeploy.spec`, `bash scripts/build.sh` wraps it and writes output to `bin/deploy`.
|
||||
- **Cleanup**: if a task bypassed the helper scripts and left `__pycache__` folders in `src/` or `tests/`, run `bash scripts/clean.sh` before committing.
|
||||
- **UI language**: keep user-facing strings in German.
|
||||
- **Style**: enforce PEP8 via `flake8 src tests`. Keep docstrings and comments concise; prefer descriptive identifiers.
|
||||
|
||||
## Workflow Expectations
|
||||
|
||||
- For every feature: rely on the helper scripts (`run-app`, `run-qa`, `build`) to keep commands consistent, use `bash scripts/clean.sh` whenever cached artefacts slip into tracked folders, and update documentation/tests alongside code.
|
||||
- Update documentation if behavior or setup changes (`README.md` or `docs/architecture.md`).
|
||||
- Prefer smaller commits tied to single concerns.
|
||||
|
||||
## Next Sprint Placeholder
|
||||
|
||||
When kicking off a new sprint:
|
||||
|
||||
1. Identify the next feature or bug fix.
|
||||
2. Write a brief plan (e.g., extend ViewModel for KPI charts, add editing dialogs, etc.).
|
||||
3. List tasks in order inside the todo tool / project tracker.
|
||||
4. Execute while keeping the principles above in mind.
|
||||
|
||||
Add future objectives below as they are defined.
|
||||
@@ -0,0 +1,35 @@
|
||||
# Study Dashboard Architecture
|
||||
|
||||
## Goals
|
||||
- Embrace MVVM to keep views (Qt widgets) dumb and push logic into view models.
|
||||
- Use dependency injection for explicit wiring of repositories, services and view models.
|
||||
- Keep persistence simple with a local SQLite file that the app can create and seed automatically.
|
||||
- Maintain TDD-friendly seams so repositories and view models stay unit-testable without the GUI.
|
||||
|
||||
## Layers
|
||||
| Layer | Responsibilities |
|
||||
|--------------|--------------------------------------------------------------------------------------------------|
|
||||
| View (PySide6)| Defines widgets/layouts, binds to view-model signals/slots, contains German UI text. |
|
||||
| ViewModel | Exposes observable properties and commands (Qt signals/slots), orchestrates services asynchronously if needed. |
|
||||
| Services | Aggregate domain operations (e.g., progress tracking, calendar queries) built on repositories. |
|
||||
| Repositories | Talk to SQLite using `sqlite3`, handle schema migrations/bootstrap and raw queries. |
|
||||
| Infrastructure | Dependency injection container, configuration (paths, environment), logging, bootstrap. |
|
||||
|
||||
## Dependency Injection Flow
|
||||
1. `ApplicationContainer` defines providers for configuration (DB path), SQLite connections, repositories, services and view models.
|
||||
2. `main.py` initialises the container, triggers database bootstrap (create file, apply schema, seed demo data), then builds the QApplication + `MainView`.
|
||||
3. The view receives its view model via DI so it can subscribe to signals and send commands without knowing about repositories.
|
||||
|
||||
## Database Bootstrap
|
||||
- Database file: `study.db` at repo root (configurable via container if needed).
|
||||
- Tables: `modules`, `exams`, `appointments` (calendar tile).
|
||||
- On first launch the bootstrapper:
|
||||
1. Creates the file and tables if they do not exist.
|
||||
2. Inserts demo data (e.g., three modules with credits/status, two upcoming exams, two appointments).
|
||||
- Seeding runs idempotently: existing rows are left intact to avoid wiping user data.
|
||||
|
||||
## Testing Approach
|
||||
- Repository tests use a temporary SQLite database (in-memory or tmp directory) to validate schema + CRUD logic.
|
||||
- View model tests stub repositories/services via dependency injection to simulate responses and assert emitted signals.
|
||||
- GUI level tests stay minimal for now; focus on logic-heavy layers for fast feedback.
|
||||
- Aim for “test-first” when touching new behavior, mirroring a TDD workflow.
|
||||
Reference in New Issue
Block a user