GNU General Public License v3.0

技术解读

以下内容由 GitRead 中文社区 编辑团队基于项目 README 与官方资料整理, 结合中文开发者的常见使用场景补充技术选型建议。具体以项目官方文档为准。

NMF-Earth/nmf-app 项目深度技术分析

项目背景与痛点

在倡导绿色低碳的生活方式下,减少个人碳足迹成为全球共识。针对这一需求,NMF-Earth 团队推出了名为 “nmf-app” 的跨平台应用程序,旨在帮助用户详细了解并减少他们的碳足印。该应用覆盖 iOS 和 Android 平台,通过引导用户每日生活方式的选择,来追踪和减少碳排放,如推荐低碳出行方式、引导节能减碳的饮食选择等。

nmf-app 着眼于全球碳减排的迫切需求,引导用户从生活的点滴开始践行可持续发展。面对日益严峻的环境问题,这样一款实用工具,不仅帮助个人贡献于环境保护,也鼓励了一场社会意识的变革。

核心技术揭秘

nmf-app 在技术层面上表现出色,采用了现代化开源技术栈与先进的系统设计思想。其主要的技术栈包括 Kotlin 和 Swift,分别用于构建 Android 和 iOS 版本的应用程序。核心功能模块如碳足迹追踪、出行建议、环保习惯养成等,均在多层架构中得到精心设计与实现。

以下是该应用的高层架构示意图:

graph TD A[用户登录] --> B[启动碳足迹初始化] B --> C[加载用户数据] C --> D[获取位置信息] D --> E[加载当前位置的碳足迹数据] E --> F[更新UI] F --> G[接收用户输入] G --> H{"数据有效性"} H -->|"有效"| I[更新碳足迹数据] H -->|"无效"| J[显示错误提示] I --> K[同步数据到云端] K --> L[展示更新后的足迹]

在架构层面,nmf-app 引入了 MVC (Model-View-Controller) 设计模式,确保了组件间独立性和数据流的清晰转换,同时确保各模块之间通信高效。初始化阶段,用户数据同步、位置信息获取和足迹数据加载都涉及复杂的数据流管理。此外,该应用进一步运用异步通信技术与数据库交互,实现了高效的数据实时更新与加载,确保用户界面上的实时反馈。

功能亮点与差异

对比同类的碳足迹追踪应用,nmf-app 引入了一系列独特功能,使其在功能和用户体验上出类拔萃。例如,nmf-app 提供了个性化的节能减排建议,并根据用户的反馈进行智能调整,以适应不同用户的生活习惯和环境特点。此外,功能上耦合了环境意识教育的内容,加上基于位置的服务推送,能够为用户提供一站式的低碳生活方式指南。

特别值得一提的是,该应用涵盖了跨平台的云同步功能,确保用户在不同设备间的无缝体验。在相似的应用中,这种跨设备的无缝使用体验是非常难得的。此外,它独特的碳足迹目标设定功能,令用户能够设立并追踪减碳活动的目标进度,增强了用户在环保实践中的参与感和成就感。

应用场景与落地建议

nmf-app 的场景适用性广泛,可以被各类个人用户用于日常环境监测与行动。不过,在生产环境使用时,开发者需要注意的几个关键点包括,数据隐私保护机制、多语言支持,以及与环境传感器设备的兼容性。具体来说:

  1. 数据隐私保护:用户的出行和生活习惯数据属于敏感信息,应尽量在本地和加密传输中处理,避免云服务泄露风险。
  2. 多语言与国际化:考虑到全球化使用场景,应用需提供多语言支持,以触达更多国际用户。
  3. 设备兼容性与传感器集成:与手机传感器的高效集成能让数据收集与分析更加精准,提升应用的准确性和用户体验。

本应用最适合于环保意识强、对个人行为影响有高度关注的用户群。此外,它也可以被环保组织或教育机构用作推广绿色环保生活方式的渠道。

综合评价

  • 优点:

    • 个性化的碳足迹追踪与分析。
    • 智能推荐与持续反馈机制增强了用户参与感。
    • 强效的数据保护策略提升了用户信任。
    • 多平台云同步能力支持多设备无缝切换。
    • 环环相扣的界面设计,为用户创造了优秀的使用体验。
  • 缺点:

    • 用户数据处理的隐私策略需要进一步强化。
    • 跨平台的兼容性问题仍需优化,以确保不同设备上的稳定运行。
    • 在某些地区支持较少的语言版本,受限于国际化推广。

总体而言,nmf-app 在复杂的应用设计中巧妙结合了环境优化理念与现代化技术,创造出独具匠心的用户交互体验。其优秀的数据处理能力、个性化的操作模式以及跨平台支持,使其具备广泛的适用性和使用前景。

关于

GitHub 原始描述(英文)

Understand and reduce your carbon footprint 🌱 iOS & Android.

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

语言占比

Batchfile
JavaScript
TypeScript

Release

README

🌱 NMF.earth app

Understand and reduce your carbon footprint


app-store google-play


figma


screenshots

Depfu Contributor Covenant Build Status runs with expo

Repository for the NMF.earth React Native application, built with Expo, Redux Toolkit and Typescript. Design can be found on Figma.


📊 Data source

Carbon data comes from NMF’s carbon footprint repo while barcode product scanned data comes from Open Food Facts api.


📦 Getting started

Installing Dependencies:

$ yarn

Running the app:

$ yarn start

For starting the app on a specific OS:

$ yarn ios | yarn android

👩🏾‍💻 Development

  • Eslint is used in the project to enforce code style and should be configured in your editor.

  • Prettier is also used and apply automatically by eslint

  • Typescript is used in the project for type-checking and should be configured in your editor.

You can check this manually by running:

$ yarn lint

or

$ yarn typescript

You can ask eslint to fix issues by running:

$ yarn lint:fix

🛠 Testing

Use the following command to run unit tests with coverage:

$ yarn test

Use the following to update unit tests

$ yarn test -u

Use the following to run unit tests in watch mode while developing:

$ yarn test --watch

🎨 Storybook

Stories (*.story.tsx) can be automatically added to storyLoader.js with :

$ yarn prestorybook

📗 Sustainable guide

To place new .md files inside guides folder or modify existing guide and then run node scripts/generate-guides.js to generate a new sustainable guide. Images can be used in the .md as follow: ![Earth](earth.png) and should be place in assets/images/guide.


For methodology screen, just run node scripts/generate-methodology.js to update methodology.json from methodology.md.


For emission info screen, just run node scripts/generate-emission-info.js to update emission-info.json from assets/emission-info/markdown/*.md.


🗣 Translations

You can help us with translate the app with our online tool POEditor. Any help is appreciate and no coding skills are needed 🤗

PS: please do not use send translations made by Google translate or similar.


Generate

Run node scripts/generate-translation-files.js in order to create the files needed for the new language you want to add to the app.

Manage Files

Run node scripts/poeditor/group-translation-files.js to generate 1 JSON file per language, with all the translation vars in it. From there, you can easily make any edit you want. When you’re done, you can run node scripts/poeditor/spread-translation-files.js to merge your edits and spread them into all the translation files across the repo.


🚀 Deployment

Any tag starting with v will runs expo publish. During this step app.example.json is used to generate an app.json file for expo’s deployment, this is done with the following script scripts/generate-app-json.js.


🏗 Build

First you need to configure SENTRY_AUTH_TOKEN and SENTRY_DSN secrets on expo.dev and then define projectId in app.config.js. Then run npm install dotenv and place your secrets inside .env file that you need to create with SENTRY_AUTH_TOKEN and SENTRY_DSN, like in .env.example.

Run eas build -p ios to build for the App Store Connect and eas build -p android for the Google Play Console.


👨‍💻 Contribute ❤️

More than 40 developers have contribute to the app, thanks a lot to them!

Have a look to contributing.md if you want to contribute!


🏆 Backers

A big thank you to Christopher Gwilliams and to the Phelps family for their amazing contribution to the Kickstarter!


©️ Open source - licence

Repository and contributions are under GNU General Public License v3.0

评论

暂无评论