Skip to content

docs: add architecture guidelines and programming standards - #62

Merged
dkhawk merged 6 commits into
mainfrom
docs/architecture-and-gemini-guidelines
Sep 8, 2026
Merged

docs: add architecture guidelines and programming standards#62
dkhawk merged 6 commits into
mainfrom
docs/architecture-and-gemini-guidelines

Conversation

@LoyalAbbas

@LoyalAbbas LoyalAbbas commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

Establishes comprehensive Clean Architecture guidelines and programming standards for android-maps3d-samples:

  • ARCHITECTURE.md:

    • Specifies architectural blueprints for both 3-way parity demos (Maps3DSamples) and standalone showcase modules (PlacesUIKit3D).
    • Standardizes Repository pattern and domain model decoupling for async SDKs/APIs.
    • Mandates coroutine dispatcher injection for deterministic unit testing.
    • Defines Google Maps 3D SDK standards (explicit AltitudeMode, consumable camera animation commands, and lifecycle forwarding).
    • Documents Jetpack Compose state hoisting and collectAsStateWithLifecycle() standards.
    • Expands 4-tier testing definitions (Engine, Controller/Repository, ViewModel, Visual Regression).
    • Includes explicit incremental adoption rules so maintenance of existing code is never blocked.
  • AGENTS.md:

    • Defines AI code generation hygiene (zero wildcard imports, Spotless/ktlint compliance).
    • Establishes modern Kotlin idioms and pragmatic warning hygiene.
    • Sets rules for theme tokens, resource externalization, and cross-module smart casts.

@LoyalAbbas
LoyalAbbas requested review from dkhawk and kikoso September 3, 2026 09:11

@dkhawk dkhawk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this is a fantastic addition! Formalizing Clean Architecture, 3-way parity, the 4-tier testing strategy, and AI pair-programming hygiene is a huge win for maintaining consistency across android-maps3d-samples. The inclusion of the pragmatic, non-blocking incremental adoption rules in GEMINI.md is especially valuable.

Here is some constructive feedback and suggestions for polish:

  1. Clarify StateFlow vs LiveData and the asLiveData() approach:

    • Generally speaking, we should keep StateFlow as the standard for Kotlin and Jetpack Compose implementations, and reserve LiveData for Java implementations. Pure Kotlin/Compose modules should rely solely on StateFlow.
    • The asLiveData() approach is primarily relevant for hybrid solutions (like the shared common module in Maps3DSamples/ApiDemos) where a single ViewModel powers Kotlin, Compose, and Java views.
    • For those hybrid ViewModels, using val liveData: LiveData<T> = _uiState.asLiveData() (as currently done in PathFollowingViewModel and AdvancedCameraAnimationViewModel) is much cleaner than manually managing a dual-state _liveData + updateState function with a try/catch block falling back to postValue(). It automatically handles coroutine thread-dispatching and eliminates redundant mutable backing properties.
  2. Soft Line Count Guideline for Views (<250 lines):

    • In ARCHITECTURE.md Section 2.A, view layers are noted with a <200 lines target, whereas Sections 1, 2.B, 3, 7, and GEMINI.md cite < 250 lines.
    • While arbitrary hard line limits can be overly rigid, setting a consistent "soft" target of ~250 lines across all sections is a good guideline to keep view layers thin and focused while maintaining consistency throughout the documentation.
  3. Markdown / LaTeX Arrow Formatting in ARCHITECTURE.md:

    • In Section 3 (Layer 4), the UDF flow uses LaTeX math syntax $\rightarrow$:
      Views emit user intents $\rightarrow$ ViewModel processes via Repository/Controller $\rightarrow$ Emits immutable State $\rightarrow$ Views render.
    • Replacing $\rightarrow$ with standard Unicode arrows ( or ->) will ensure clean rendering in all markdown viewers, IDE previews, and mobile GitHub views without relying on KaTeX math rendering.
  4. Region Tag Guidance for snippets/ in GEMINI.md:

    • Under Section 4 ("Code Generation Hygiene & Linter Standards"), consider adding a note reminding contributors and AI tools to preserve and utilize region tags (// [START ...] ... // [END ...]) when working in snippets/. This ensures snippet boundaries remain discoverable and compatible with the repository's automated catalog scripts and documentation extractors.

@dkhawk
dkhawk enabled auto-merge (squash) September 3, 2026 17:35
@kikoso

kikoso commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

What if we use an agent neutral markdown file, like AGENTS.md? I assume not everybody will use Gemini.

Comment thread ARCHITECTURE.md
│ ├── kotlin-app/
│ │ └── src/main/java/com/example/maps3dkotlin/<feature>/
│ │ └── <Feature>Activity.kt # Layer 5: Thin View (~250 lines soft guideline) collecting StateFlow
│ └── java-app/

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we align the tree branches for java-app/? It's drawn with └── as the last child of ApiDemos/, but the two lines beneath it still carry the │ │ continuation prefix, which leaves a stray vertical line hanging under a closed branch. Dropping the second pipe would keep the diagram consistent:

│   └── java-app/
│       └── src/main/java/com/example/maps3djava/<feature>/
│           └── <Feature>Activity.java

Purely cosmetic, but since this blueprint is the visual anchor of the doc, it's worth the tidy-up.

@LoyalAbbas

Copy link
Copy Markdown
Collaborator Author

What if we use an agent neutral markdown file, like AGENTS.md? I assume not everybody will use Gemini.

Good point! I kept it as GEMINI.md because the current implementation and guidelines are strictly tailored to Gemini. I figured it's best to be explicit about what is currently supported. If we expand to other agents later on, we can definitely migrate to an AGENTS.md approach. Let me know if that makes sense!

@kikoso

kikoso commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

What if we use an agent neutral markdown file, like AGENTS.md? I assume not everybody will use Gemini.

Good point! I kept it as GEMINI.md because the current implementation and guidelines are strictly tailored to Gemini. I figured it's best to be explicit about what is currently supported. If we expand to other agents later on, we can definitely migrate to an AGENTS.md approach. Let me know if that makes sense!

I think we should go for the standardization rule, there are not that many differences today between agents, and there will be less differences in the future. This is already a field prone to standardization.

@LoyalAbbas

Copy link
Copy Markdown
Collaborator Author

What if we use an agent neutral markdown file, like AGENTS.md? I assume not everybody will use Gemini.

Good point! I kept it as GEMINI.md because the current implementation and guidelines are strictly tailored to Gemini. I figured it's best to be explicit about what is currently supported. If we expand to other agents later on, we can definitely migrate to an AGENTS.md approach. Let me know if that makes sense!

I think we should go for the standardization rule, there are not that many differences today between agents, and there will be less differences in the future. This is already a field prone to standardization.

That makes total sense, @kikoso! You're completely right that standardizing on AGENTS.md is more inclusive and forward-looking for the broader developer community, regardless of which agent or tool they use.
I've renamed GEMINI.md to AGENTS.md. Thanks for the suggestion!

@dkhawk
dkhawk merged commit 8c5446c into main Sep 8, 2026
12 checks passed
@dkhawk
dkhawk deleted the docs/architecture-and-gemini-guidelines branch September 8, 2026 17:29
@googlemaps-bot

Copy link
Copy Markdown

🎉 This PR is included in version 1.12.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants