# briansittmann/caloria_sdk53 architecture

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

- Interactive diagram: https://gitdiagram.com/briansittmann/caloria_sdk53
- Repository: https://github.com/briansittmann/caloria_sdk53

## Overview

##### Project Type and Purpose
- This is a mobile full-stack application (“CalorIA”) built with React Native (Expo SDK 53) for nutritional coaching.
- Its purpose is to let users log meals, automatically calculate macronutrients, receive AI-driven recommendations, and sync data in real time with a Spring Boot backend.

##### File Structure
– Top level
- app.json, package.json, App.js / index.js (entry points)
- assets/ (static images/fonts)
– src/
- components/ (reusable UI: buttons, cards, spinners)
- screens/ (full-screen views: Home, Login, ProfileWizard, Diary, Recipes, Modals)
- navigation/ (navigators & stacks for onboarding, auth, main app flow)
- context/ (React Contexts: AuthContext, MacrosContext for global state)
- services/ (API clients: authService, foodService, macrosService, recipeService, registerService)
- config/api.js (base URLs, endpoints)
– Configuration files for Expo, ESLint/.gitignore, node modules, etc.

##### README for Additional Insights
- Confirms React Native + Expo front end, Axios for HTTP calls, React Navigation for routing, Context API for state.
- Notes real-time sync with a Spring Boot backend that handles authentication, data storage, business logic, and AI food analysis.

##### Diagramming the Architecture
a. Main Components
- Mobile App (React Native)
– UI Layer: screens & components
– State Layer: React Contexts
– Networking Layer: services using Axios → REST API
- Backend (Spring Boot)
– Authentication Service
– Macronutrient Analysis & Business Logic
– Data Layer (e.g., PostgreSQL / MongoDB)
- External AI Service (could be a third-party or custom microservice for food image/ingredient analysis)
- Persistent Storage (Database)
b. Relationships & Interactions
- UI triggers actions → Context updates state → calls service → Axios HTTP request → Spring Boot REST endpoint → database or AI service → response back to app → Context updates UI.
- Auth flow: Login/RegisterScreen → authService → token stored in AuthContext → used in headers for protected routes.
- Navigation flows between welcome, auth wizards, and main app screens.
c. Architectural Patterns & Principles
- Layered architecture (Presentation, State, Network, Backend services, Data)
- Separation of concerns: components vs. screens vs. services vs. context
- Single source of truth for global state (Context API)
- Declarative UI with React Native
d. Key Technologies & Libraries
- Frontend: React Native (Expo), React Navigation, Context API, Axios
- Backend: Spring Boot (REST), Database (SQL/NoSQL)
- External Services: AI/ML food analysis

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend (Mobile App)" 
        direction TB
        AppEntry["App Entry\nApp.js / index.js"]:::frontend
        UI["UI Layer\nScreens & Components"]:::frontend
        Context["State Layer\nAuthContext, MacrosContext"]:::frontend
        Services["Networking Layer\nAPI Services"]:::frontend
        Config["Config\napi.js"]:::frontend
        Theme["Theme\ncolor.js"]:::frontend
        Assets["Static Assets\nassets/"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend (Spring Boot)" 
        direction TB
        AuthService["Authentication Service"]:::backend
        BusinessLogic["Business Logic & Analysis"]:::backend
        DataService["Data Service\nRepositories"]:::backend
    end

    %% External
    ExternalAI["External AI Service"]:::ai
    Database["Persistent Storage\n(PostgreSQL/MongoDB)"]:::db

    %% Connections Frontend
    AppEntry -->|loads| UI
    UI -->|dispatch actions| Context
    Context -->|calls| Services
    Services -->|HTTP requests| AuthService
    Services -->|HTTP requests| BusinessLogic

    %% Backend connections
    AuthService -->|reads/writes| DataService
    BusinessLogic -->|reads/writes| DataService
    BusinessLogic -->|analyze food| ExternalAI
    DataService -->|persist| Database

    %% Click Events Frontend
    click AppEntry "https://github.com/briansittmann/caloria_sdk53/blob/master/src/App.js"
    click AppEntry "https://github.com/briansittmann/caloria_sdk53/blob/master/index.js"
    click UI "https://github.com/briansittmann/caloria_sdk53/tree/master/src/components/"
    click UI "https://github.com/briansittmann/caloria_sdk53/tree/master/src/screens/"
    click Context "https://github.com/briansittmann/caloria_sdk53/blob/master/src/context/AuthContext.js"
    click Context "https://github.com/briansittmann/caloria_sdk53/blob/master/src/context/MacrosContext.js"
    click Services "https://github.com/briansittmann/caloria_sdk53/blob/master/src/services/authService.js"
    click Services "https://github.com/briansittmann/caloria_sdk53/blob/master/src/services/registerService.js"
    click Services "https://github.com/briansittmann/caloria_sdk53/blob/master/src/services/foodService.js"
    click Services "https://github.com/briansittmann/caloria_sdk53/blob/master/src/services/macrosService.js"
    click Services "https://github.com/briansittmann/caloria_sdk53/blob/master/src/services/recipeService.js"
    click Config "https://github.com/briansittmann/caloria_sdk53/blob/master/src/config/api.js"
    click Theme "https://github.com/briansittmann/caloria_sdk53/blob/master/src/theme/color.js"
    click Assets "https://github.com/briansittmann/caloria_sdk53/tree/master/assets/"

    %% Click Events Navigation
    click UI "https://github.com/briansittmann/caloria_sdk53/blob/master/src/navigation/AppNavigator.js"
    click UI "https://github.com/briansittmann/caloria_sdk53/blob/master/src/navigation/AuthNavigator.js"
    click UI "https://github.com/briansittmann/caloria_sdk53/blob/master/src/navigation/MainNavigator.js"
    click UI "https://github.com/briansittmann/caloria_sdk53/blob/master/src/navigation/MainStack.js"
    click UI "https://github.com/briansittmann/caloria_sdk53/blob/master/src/navigation/ProfileWizardStack.js"

    %% Styles
    classDef frontend fill:#E0F7FA,stroke:#006064,color:#006064;
    classDef backend fill:#E8F5E9,stroke:#2E7D32,color:#2E7D32;
    classDef db fill:#FFF3E0,stroke:#EF6C00,color:#E65100;
    classDef ai fill:#F3E5F5,stroke:#6A1B9A,color:#4A148C;
```
