Coding Standards Document Demo 2 - COS301-SE-2026/Mealchemy GitHub Wiki
This document defines the coding conventions, styles and repository structure for Mealchemy. Compliance with this document ensures uniformity, clarity, flexibility, reliability and efficiency in the codebase.
- Core Engineering Principles
- Frontend (Flutter/Dart)
- Backend (Spring Boot/Java)
- Recommendation Engine (Python)
- Best Practices & Guidelines
- Repository Structure
- Maintenance
DRY (Don't Repeat Yourself)
- Avoid duplication of logic by encouraging reusable components and code. This improves maintainability by ensuring changes are made in one place. DRY works well with modular design.
KISS (Keep It Simple, Stupid)
- Encourages simplicity in design and development. Simple solutions are easier to understand, implement, maintain and use.
-
Variables and functions: lowerCamelCase (e.g.
loadPantryItems()) -
Files: lowercase_with_underscores (e.g.
guided_discovery_provider.dart) -
Feature folders: lowercase_with_underscores (e.g.
shopping_lists) -
Subfolder structure per feature: lowercase (e.g.
models/,providers/,repositories/,screens/,widgets/) -
Test files: mirror source files followed by
_test.dart(e.g. source -recipe_provider.dartcorresponding test -recipe_provider_test.dart)
- Feature-first, under
lib/features/<feature>/, following MVVM (Model, View, ViewModel via Riverpod providers, Repository). - Shared code lives in
lib/core/.
βββ frontend/ β Flutter mobile app
β βββ lib/core/ β constants, providers, routes, services, shared_widgets, theme, utils
β βββ lib/features/
β β βββ auth/
β β βββ dashboard/
β β βββ discovery/
β β βββ guided_discovery/
β β βββ ingredients/
β β βββ pantry/
β β βββ preference/
β β βββ recipe/
β β βββ shopping_lists/
β β βββ vault/
β β βββ shared/
-
flutter analyzemust pass with no warnings before commit. - Ruleset: default
flutter_lints(analysis_options.yaml).
-
flutter testwith lcov, 80% line coverage enforced.
-
Variables and functions: lowerCamelCase (e.g.
getPantryIngredientById()) -
Classes: PascalCase (e.g.
PreferenceService,VaultService) -
Packages: lowercase, no underscores (e.g.
shoppinglist,cuisinetype) -
DTO suffixes: for incoming requests, dto file ends in
Request.javaand for outgoing responses, dto files end inResponse.java -
Test files: mirror source class name followed by
Test.java(e.g. source -PantryService.javacorresponding test -PantryServiceTest.java) -
Integration test files: mirror source controller name followed by
IntegrationTest.java(e.g. source -PantryController.javacorresponding test -PantryControllerIntegrationTest.java)
- Feature-based packages under
com.mealchemy, each following Controller β DTO β Model β Repository β Service . - Non-feature specific shared code (e.g. enums and exception handling) live in
config/andshared/instead of in a feature package. - Database migrations live in a top level
database/directory and have version numbers via Flyway (e.g.V<number>__description.sql).
βββ backend/ β Backend logic
β βββ src/main/java/com/mealchemy/
β β βββ shoppinglist/
β β β βββ controller/
β β β βββ dto/
β β β βββ model/
β β β βββ repository/
β β β βββ service/
| βββ src/test/ β Backend unit tests
βββdatabase/ β Flyway migration files
- Google Java Style, enforced via the Maven Checkstyle plugin.
- Build fails on any violation.
- JUnit via Maven, JaCoCo, coverage enforced with JaCoCo rules:
- 80% module wide minimum coverage across instruction, branch and method coverage.
- Zero-coverage gate - every class that has not been excluded must have at least one covered line.
- Note: to be revised upon implementation
- snake_case for files/functions/variables, PascalCase for classes.
- Ruff for linting/formatting, Mypy for static type checking.
- pytest with pytest-cov, 80% line coverage enforced.
- Consistency: follow all naming conventions, module layout and style across entire codebase
- Code review and CI/CD: no code merges without passing CI (lint + test + coverage) and peer review.
- Security: no secrets or credentials committed to source.
- Error Handling: provide user-friendly, descriptive error messages.
-
Dependency management:
- dependency versions should be explicitly pinned in the configuration files.
- unused dependencies should be removed during refactoring.
The Mealchemy repository is a monorepo. Everything lives in one repository under the cos301-se-2026 organisation. The top-level structure is:
Mealchemy/
βββ .github/
β βββ workflows/ β CI/CD pipeline and automation workflows
β βββ codecov.yml β Codecov coverage thresholds and flags
β βββ labeler.yml β PR auto-label rules
β βββ pull_request_template.md
βββ .vscode/
β βββ settings.json
βββ backend/ β Backend logic
β βββ src/main/java/com/mealchemy/
β β βββ auth/
β β βββ category/
β β βββ config/
β β βββ cuisinetype/
β β βββ ingredient/
β β βββ pantry/
β β βββ preference/
β β βββ recipe/
β β βββ shared/
β β βββ shoppinglist/
β β βββ unit/
β β βββ vault/
β β βββ MealchemyApplication.java
β βββ src/main/resources/
β βββ src/test/ β Backend unit tests
β βββ pom.xml
β βββ mvnw / mvnw.cmd β Maven Wrapper
βββ engine/ β Python 3.12 recommendation engine
βββ frontend/ β Flutter mobile app
β βββ lib/core/ β constants, providers, routes, services, shared_widgets, theme, utils
β βββ lib/features/
β β βββ auth/
β β βββ dashboard/
β β βββ discovery/
β β βββ guided_discovery/
β β βββ ingredients/
β β βββ pantry/
β β βββ preference/
β β βββ recipe/
β β βββ shopping_lists/
β β βββ vault/
β β βββ shared/
β βββ lib/main.dart
β βββ test/ β core, features, widget_test.dart
β βββ android/, ios/, macos/ β platform runner directories (auto-generated by Flutter)
β βββ pubspec.yaml
βββ database/ β Flyway SQL migration files
βββ design-spec/ β Brand guide and wireframes (deployed to GitHub Pages)
βββ diagrams/
βββ docs/
βββ infrastructure/ β Dockerfiles and docker-compose.yml
βββ landing-page/ β Static site (assets, scripts, styles, index.html)
βββ wiki/ β Git submodule pointing at Mealchemy.wiki.git
βββ .env.example β Template for local Docker credentials
βββ .secrets.example β Template for local act CI secrets
βββ .gitleaks.toml β Gitleaks scan configuration
βββ .gitmodules β Registers the wiki submodule
βββ firebase.json β Firebase Hosting / App Distribution config
βββ sonar-project.properties
βββ README.md
This is a living document - sections will be expanded on or updated as the codebase changes in future sprints.