# ange25-ca/cosmic_explorer architecture

> Architecture diagram of the GitHub repository ange25-ca/cosmic_explorer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ange25-ca/cosmic_explorer
- Repository: https://github.com/ange25-ca/cosmic_explorer

## Overview

##### Project type and purpose
- Cosmic Explorer is a cross-platform (mobile + web) application built with React Native and Expo.
- It follows Clean Architecture and the MVVM (Model-View-ViewModel) pattern to fetch and display data from five NASA APIs (APOD, EPIC, INSIGHT, SSD/NEOS, Mars Rovers).

##### File structure
- Top-level files: configuration (babel.config.js, tsconfig.json, app.json), entry points (index.ts, App.tsx), assets folder for static assets, .env reference.
- src/ splits into:
- data (datasources, models, local storage)
- domain (entities, repositories, use cases)
- services (API-calling wrappers for each NASA endpoint)
- presentation (screens, components, hooks, view models)
- navigation (Drawer, Stack, Tab navigators)
- store (Redux slices for theme and global state)
- types/typings (shared TypeScript interfaces)
- This clearly reflects a layered (Clean) architecture: Presentation → Domain → Data → External APIs + Storage.

##### README for additional insights
- Confirms Clean Architecture + MVVM.
- Emphasizes the need for an API key (.env) and Expo start.
- Mentions no backend server: the app directly consumes NASA REST APIs.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer" 
        direction TB
        Screens["Screens"]:::presentation
        Components["Components"]:::presentation
        ViewModels["ViewModels"]:::presentation
        Navigation["Navigation"]:::presentation
    end

    %% State Management
    subgraph "State Management" 
        direction TB
        Store["Redux Store"]:::state
        ThemeSlice["Theme Slice"]:::state
    end

    %% Domain Layer
    subgraph "Domain Layer"
        direction TB
        Entities["Entities"]:::domain
        Repositories["Repositories (interfaces)"]:::domain
        UseCases["Use Cases"]:::domain
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        RemoteDS["AppApis.tsx (Remote DataSource)"]:::data
        LocalDS["storagedata.ts (Local Storage)"]:::data
        Models["Models/DTOs"]:::data
    end

    %% External Systems
    subgraph "External Systems"
        direction TB
        NASA["NASA APIs"]:::external
        Storage["Device Storage"]:::external
        EnvConfig[".env Config"]:::external
    end

    %% Entry & Assets
    Entry["App.tsx / index.ts"]:::config
    ConfigFiles["babel.config.js, tsconfig.json, app.json"]:::config
    Assets["assets/"]:::config

    %% Relationships
    Screens -->|"binds to"| ViewModels
    Components -->|"uses"| ViewModels
    Navigation -->|"routes to"| Screens

    ViewModels -->|"invokes"| UseCases
    UseCases -->|"uses interface"| Repositories
    Repositories -->|"implemented by"| RemoteDS
    Repositories -->|"implemented by"| LocalDS

    RemoteDS -->|"fetches from"| NASA
    LocalDS -->|"reads/writes"| Storage
    RemoteDS -->|"maps to"| Models
    Models -->|"converted to"| Entities
    Entities -->|"consumed by"| ViewModels

    ViewModels -->|"updates"| Store
    Store -->|"holds theme"| ThemeSlice
    EnvConfig -.-> RemoteDS

    Entry -->|"launches"| Navigation
    Entry -->|"loads assets"| Assets
    Entry -->|"applies config"| ConfigFiles

    %% Click Events
    click Screens "https://github.com/ange25-ca/cosmic_explorer/tree/main/src/presentation/screens"
    click Components "https://github.com/ange25-ca/cosmic_explorer/tree/main/src/presentation/components"
    click ViewModels "https://github.com/ange25-ca/cosmic_explorer/tree/main/src/presentation/viewModels"
    click Navigation "https://github.com/ange25-ca/cosmic_explorer/blob/main/src/navigation/DrawerNavigator.tsx"
    click Navigation "https://github.com/ange25-ca/cosmic_explorer/blob/main/src/navigation/StackNavigator.tsx"
    click Navigation "https://github.com/ange25-ca/cosmic_explorer/blob/main/src/navigation/TabsNavigator.tsx"
    click Store "https://github.com/ange25-ca/cosmic_explorer/blob/main/src/store/store.ts"
    click ThemeSlice "https://github.com/ange25-ca/cosmic_explorer/blob/main/src/store/slices/theme/themeSlice.ts"
    click ThemeSlice "https://github.com/ange25-ca/cosmic_explorer/blob/main/src/store/slices/theme/themeColors.ts"
    click Entities "https://github.com/ange25-ca/cosmic_explorer/blob/main/src/domain/entities/AstronomyEntities.ts"
    click Entities "https://github.com/ange25-ca/cosmic_explorer/blob/main/src/domain/entities/EarthEntities.ts"
    click Entities "https://github.com/ange25-ca/cosmic_explorer/blob/main/src/domain/entities/MarsEntities.ts"
    click Entities "https://github.com/ange25-ca/cosmic_explorer/blob/main/src/domain/entities/MarsREntities.ts"
    click Entities "https://github.com/ange25-ca/cosmic_explorer/blob/main/src/domain/entities/NerbyObjEntities.ts"
    click Repositories "https://github.com/ange25-ca/cosmic_explorer/blob/main/src/domain/repositories/AstronmyRepository.ts"
    click Repositories "https://github.com/ange25-ca/cosmic_explorer/blob/main/src/domain/repositories/EartgRepository.ts"
    click Repositories "https://github.com/ange25-ca/cosmic_explorer/blob/main/src/domain/repositories/MarsRepository.ts"
    click Repositories "https://github.com/ange25-ca/cosmic_explorer/blob/main/src/domain/repositories/MarsRRepository.ts"
    click Repositories "https://github.com/ange25-ca/cosmic_explorer/blob/main/src/domain/repositories/NerbyObjtRepository.ts"
    click UseCases "https://github.com/ange25-ca/cosmic_explorer/blob/main/src/domain/usecases/AstronomyUse.ts"
    click UseCases "https://github.com/ange25-ca/cosmic_explorer/blob/main/src/domain/usecases/EarthUseCase.ts"
    click UseCases "https://github.com/ange25-ca/cosmic_explorer/blob/main/src/domain/usecases/MarsUseCase.ts"
    click UseCases "https://github.com/ange25-ca/cosmic_explorer/blob/main/src/domain/usecases/MarsRuseCase.ts"
    click UseCases "https://github.com/ange25-ca/cosmic_explorer/blob/main/src/domain/usecases/NerbyObjetcUse.ts"
    click RemoteDS "https://github.com/ange25-ca/cosmic_explorer/blob/main/src/data/datasources/AppApis.tsx"
    click LocalDS "https://github.com/ange25-ca/cosmic_explorer/blob/main/src/data/storage/storagedata.ts"
    click Models "https://github.com/ange25-ca/cosmic_explorer/blob/main/src/data/models/FormField.ts"
    click NASA "https://github.com/ange25-ca/cosmic_explorer/blob/main/src/services/AstronomyServices.ts"
    click NASA "https://github.com/ange25-ca/cosmic_explorer/blob/main/src/services/EarthServicies.ts"
    click NASA "https://github.com/ange25-ca/cosmic_explorer/blob/main/src/services/MarsService.ts"
    click NASA "https://github.com/ange25-ca/cosmic_explorer/blob/main/src/services/MarsRRservice.ts"
    click NASA "https://github.com/ange25-ca/cosmic_explorer/blob/main/src/services/NerbyObjService.ts"
    click NASA "https://github.com/ange25-ca/cosmic_explorer/blob/main/src/services/FormService.ts"
    click EnvConfig "https://github.com/ange25-ca/cosmic_explorer/blob/main/src/typings/env.d.ts"
    click Entry "https://github.com/ange25-ca/cosmic_explorer/blob/main/App.tsx"
    click Entry "https://github.com/ange25-ca/cosmic_explorer/blob/main/index.ts"
    click ConfigFiles "https://github.com/ange25-ca/cosmic_explorer/blob/main/babel.config.js"
    click ConfigFiles "https://github.com/ange25-ca/cosmic_explorer/blob/main/tsconfig.json"
    click ConfigFiles "https://github.com/ange25-ca/cosmic_explorer/blob/main/app.json"
    click Assets "https://github.com/ange25-ca/cosmic_explorer/tree/main/assets/"

    %% Styles
    classDef presentation fill:#AED6F1,stroke:#1B4F72,stroke-width:1px
    classDef state fill:#A9DFBF,stroke:#145A32,stroke-width:1px
    classDef domain fill:#ABEBC6,stroke:#196F3D,stroke-width:1px
    classDef data fill:#FAD7A0,stroke:#7D6608,stroke-width:1px
    classDef external fill:#D5D8DC,stroke:#424949,stroke-width:1px
    classDef config fill:#D6EAF8,stroke:#1A5276,stroke-width:1px
```
