Skip to content

WorkWithAfridi/Moleculist

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧬 Moleculist

A cross-platform Flutter app that allows users to browse, search, and explore chemical compounds with detailed information, powered by the PubChem API.


πŸ“± Features

βœ… Home Screen

  • Displays a curated grid of popular compounds
  • Shows:
    • Common Name
    • Molecular Formula
    • Molecular Weight
    • Hazard Tag (mocked)
    • Compound Image (from CID)

πŸ” Search

  • Search any chemical compound by name
  • Displays results with real-time PubChem API data
  • Handles loading and error states gracefully

πŸ“„ Compound Detail Page

  • IUPAC Name
  • Molecular Formula & Weight
  • Molecular Structure Image
  • CAS Number (if available)
  • Synonyms
  • Hazard Statements (mocked or inferred)
  • Description (if available)

πŸ’Ύ Offline Caching (Bonus)

  • Last 5 compounds viewed are cached using local storage
  • Displays from cache when offline

πŸ“¦ State Management

  • Uses Cubit (Bloc package) and GetIt for DI
  • Modular and scalable architecture

πŸ› οΈ Tech Stack

Tech Purpose
Flutter Cross-platform UI
Dio Networking
Bloc State management
GetIt Dependency injection
Hive / SharedPreferences Local storage (caching)
PubChem API Chemistry data provider

πŸ§ͺ Getting Started

πŸš€ Run the App

git clone https://github.com/your-username/moleculist.git cd moleculist flutter pub get flutter run

✍️ Test Names to Try

Aspirin, Acetone, Benzene, Ethanol, Caffeine, Methane, Chloroform, Sulfuric Acid, Urea, Citric Acid

πŸ—οΈ Project Architecture

Moleculist is built with a clean, layered architecture that ensures separation of concerns, testability, and scalability.

πŸ”§ Layers Overview

lib/ β”œβ”€β”€ common/ β”‚ β”œβ”€β”€ resources/ β†’ App-wide resources (e.g., themes, constants). β”‚ β”œβ”€β”€ services/ β†’ Common services (e.g., logging). β”‚ └── utilities/ β†’ Utility functions and helpers. β”œβ”€β”€ data/ β”‚ β”œβ”€β”€ local/ β†’ Local data sources (e.g., Hive for caching). β”‚ └── remote/ β†’ Remote data sources & API clients (e.g., Dio). β”œβ”€β”€ domain/ β”‚ β”œβ”€β”€ entities/ β†’ Core business objects (plain Dart objects). β”‚ β”œβ”€β”€ models/ β†’ Data models with serialization logic. β”‚ β”œβ”€β”€ repositories/ β†’ Abstract contracts for data layers. β”‚ └── services/ β†’ Business logic and use cases. β”œβ”€β”€ presentation/ β”‚ β”œβ”€β”€ blocs/ β†’ State management (Blocs/Cubits). β”‚ └── views/ β†’ UI screens and widgets. └── main.dart β†’ App entry point.

🧠 State Management: Bloc/Cubit

We use Flutter Bloc for predictable state management. Each UI feature is backed by a dedicated Cubit:

Cubits

Cubit Responsibility CompoundCubit Load default compounds and cache them SearchCubit Perform dynamic search and handle results

πŸ“¦ Repository Pattern

All external data (network or local) is accessed via repositories. Each repository:

Implements an abstract class (AbstractCompoundRepository)

Separates data-fetching logic from UI & business rules

Communicates with services, which are consumed by Cubits

This makes the app testable and ready for change or scale.

πŸ’Ό Service Layer

The service layer coordinates multiple repository calls and composes logic. It contains:

Cache fallback logic

Transformation between raw data and models

Business-specific operations (e.g., batch loading, conditional fallback)

πŸ’‘ Design Principles Followed

βœ… Single Responsibility Principle βœ… Dependency Injection via GetIt βœ… Clean Architecture (Separation of Concerns) βœ… Fail-safe Error Handling βœ… Local caching with override support

About

A cross-platform Flutter app that allows users to **browse**, **search**, and **explore** chemical compounds with detailed information, powered by the **[PubChem API](https://pubchem.ncbi.nlm.nih.gov/docs/pug-rest)**.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors