# cosmevalera/fitcal architecture

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

- Interactive diagram: https://gitdiagram.com/cosmevalera/fitcal
- Repository: https://github.com/cosmevalera/fitcal

## Overview

##### Main Components
- Frontend: The Angular application located under the “site” directory. This component is responsible for user interaction and presentation, featuring pages such as Diary, Nutrition, Profile, Food, and additional UI elements like dialogs and navigation.
- Backend: The Java Spring Boot application under the “api” directory. This part follows a layered (MVC or similar) architecture comprising Controllers, Services, Repositories, DTOs, and Domain Models.
- (Implied) Database: While not explicitly seen in the file structure, the usage of repository classes and Spring Boot’s typical configuration (application.properties) indicates that a data storage system (e.g., a relational database) is being used.

##### Architectural Layers and Interactions
- Frontend Layer:
- Routing: The “app-routing.module.ts” indicates navigation logic between these pages.
- External Dependencies: Built via Angular CLI and managed with npm.

- API / Backend Layer:
- Controllers: Controllers such as AuthController, DayController, FoodController, FoodInstanceController, UserController, and WeightDayController expose REST endpoints.
- Service Layer: These classes (DayService, FoodService, GoogleAuthService, etc.) encapsulate business logic.
- Repository Layer: The Repository classes interact with the database to perform CRUD operations on domain models (e.g., Day, Food, FoodInstance, User, WeightDay).
- Domain Models & DTOs: Represent the business entities and transfer objects for data exchange.
- Maven & Java Environment: The project uses Maven for build management.

- Integration Points:
- If there is an external database, include it as a storage component, with the backend’s repository layer interfacing with it.
- Other deployment or build tools (Maven, Node/NPM) can be shown as auxiliary components or build pipeline tools.

##### Detailed Steps for the Principal Software Engineer
1. Start by drawing two major containers: one for the Angular frontend (“site”) and one for the Spring Boot backend (“api”).
2. Within the Angular container, add sub-components (pages like Diary, Food, Nutrition, Profile) and show a routing component that orchestrates navigation.
3. In the backend container, create three nested layers:
- Controllers (include sample names like AuthController, DayController)
- Services (e.g., FoodService, UserService)
- Repositories (e.g., FoodRepository, UserRepository)
5. If applicable, include a database component linked to the backend repositories.
- Angular, Node/npm for the frontend.
- Java, Spring Boot, Maven for the backend.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend (Angular)"
        FE["Angular Frontend"]:::frontend
        FE_Pages["Pages (Diary,Food,Nutrition,Profile)"]:::frontend
        FE_Routing["Core UI & Routing"]:::frontend
        FE_Shared["Shared Components & Services"]:::frontend
        FE --> FE_Pages
        FE --> FE_Routing
        FE --> FE_Shared
    end

    subgraph "Backend (Spring Boot)"
        BE["Spring Boot API"]:::backend
        BE_Controllers["Controllers (AuthController,DayController)"]:::backend
        BE_Services["Services (FoodService,UserService)"]:::backend
        BE_Repositories["Repositories (FoodRepository,UserRepository)"]:::backend
        BE_Models["Domain Models"]:::backend
        BE_DTOs["DTOs"]:::backend
        BE_Maven["Maven Config"]:::backend
        BE_Config["Spring Boot Config"]:::backend
        BE --> BE_Controllers
        BE_Controllers --> BE_Services
        BE_Services --> BE_Repositories
        BE_Services --> BE_Models
        BE_Services --> BE_DTOs
        BE --- BE_Maven
        BE --- BE_Config
    end

    DB["Database"]:::database

    FE -->|"HTTPRESTAPI"| BE_Controllers
    BE_Repositories -->|"CRUDOperations"| DB

    click FE "https://github.com/cosmevalera/fitcal/tree/master/site"
    click FE_Pages "https://github.com/cosmevalera/fitcal/tree/master/site/src/app/pages"
    click FE_Routing "https://github.com/cosmevalera/fitcal/blob/master/site/src/app/app-routing.module.ts"
    click FE_Routing "https://github.com/cosmevalera/fitcal/tree/master/site/src/app/core"
    click FE_Shared "https://github.com/cosmevalera/fitcal/tree/master/site/src/app/shared"
    click BE "https://github.com/cosmevalera/fitcal/tree/master/api"
    click BE_Controllers "https://github.com/cosmevalera/fitcal/tree/master/api/src/main/java/com/fitcal/api/controller"
    click BE_Services "https://github.com/cosmevalera/fitcal/tree/master/api/src/main/java/com/fitcal/api/service"
    click BE_Repositories "https://github.com/cosmevalera/fitcal/tree/master/api/src/main/java/com/fitcal/api/repository"
    click BE_Models "https://github.com/cosmevalera/fitcal/tree/master/api/src/main/java/com/fitcal/api/model"
    click BE_DTOs "https://github.com/cosmevalera/fitcal/tree/master/api/src/main/java/com/fitcal/api/dto"
    click BE_Maven "https://github.com/cosmevalera/fitcal/blob/master/api/pom.xml"
    click BE_Config "https://github.com/cosmevalera/fitcal/blob/master/api/src/main/resources/application.properties"

    classDef frontend fill:#d1e8ff,stroke:#004080,stroke-width:2px;
    classDef backend fill:#ffe0b3,stroke:#a65d0c,stroke-width:2px;
    classDef database fill:#d0f0c0,stroke:#2e7d32,stroke-width:2px;
```
