# michal-szadkowski/coffee-inventory architecture

> Architecture diagram of the GitHub repository michal-szadkowski/coffee-inventory, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/michal-szadkowski/coffee-inventory
- Repository: https://github.com/michal-szadkowski/coffee-inventory

## Overview

Based on our analysis of the file structure and README content, this coffee-inventory project is a full-stack application designed to manage coffee brewing and inventory data. It combines a .NET-based backend API (with a clear separation between API controllers, business services, and a separate data access library) and two separate frontend implementations – one using React (in the “frontend” folder) and another using Svelte (in the “frontend-svelte” folder). There are also Docker and GitHub Actions (CI/CD) configurations that suggest containerized deployment and automated builds.

##### Main Components
- Frontend Components:
– “React Frontend” (located in the “frontend” directory)
– “Svelte Frontend” (located in “frontend-svelte”)
- Backend Component:
– “Coffee-Inventory API” (in the backend/coffee-inventory-api folder)
– “Data Access Layer” (in backend/coffee-inventory-data-access) which includes Repository classes and MongoDB access functionality.
- Database:
– An external MongoDB instance (as indicated by the “MongoAccess.cs” file in the data-access folder).
- CI/CD/Deployment:
– GitHub Actions workflows (in the .github/workflows folder) for building and publishing both frontend and backend.
– Docker configurations (Dockerfile in each major component and compose.yml) indicating containerized deployment.

##### Inter-Component Relationships
- Inside the Backend, show a separation into:
– The API Layer (Controllers that expose endpoints),
– The Service Layer (business logic such as InventoryService and UsageService),
– The Data Access Layer (repositories interfacing with MongoDB).
- Optionally, illustrate Docker containers for each component and how docker-compose ties the services together.

##### Architectural Patterns and Design Principles
- Layered Architecture: Clearly partition the backend into controller (API), service/business logic, and repository (data access) layers.
- Separation of Concerns: Show how each layer or component has a distinct role, e.g., frontends handle user interactions, the API layer processes requests, and data-access handles persistence.
- Microservice-like Separation (if desired): Although this project is mostly monolithic, differentiating frontend and backend as separate deployable units can be emphasized.
- Containerization: Note the presence of Docker files and compose configurations that govern deployment.

##### Relevant Technologies and Frameworks
- . NET (C#) for the backend API.
- MongoDB for the data store, as evidenced by MongoAccess and repository patterns.
- React (TypeScript) for one frontend implementation.
- Svelte for the alternative frontend.
- GitHub Actions and Docker for CI/CD and deployment automation.
- Additionally, highlight any tooling (like ESLint, Tailwind CSS, etc.) visible in the frontend configurations if deemed relevant.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "CI/CD / Deployment"
        CICD["GitHub Actions Workflows"]:::cicd
        click CICD "https://github.com/michal-szadkowski/coffee-inventory/tree/main/.github/workflows/"
    end

    subgraph "Docker Containers"
        DOCKER["Docker Compose (Container Orchestration)"]:::docker
        click DOCKER "https://github.com/michal-szadkowski/coffee-inventory/blob/main/compose.yml"
    end

    subgraph "Frontend Services"
        React["React Frontend"]:::frontend
        click React "https://github.com/michal-szadkowski/coffee-inventory/tree/main/frontend/"
        Svelte["Svelte Frontend"]:::frontend
        click Svelte "https://github.com/michal-szadkowski/coffee-inventory/tree/main/frontend-svelte/"
    end

    subgraph "Coffee-Inventory API"
        API["Coffee-Inventory API"]:::backendMain
        click API "https://github.com/michal-szadkowski/coffee-inventory/tree/main/backend/coffee-inventory-api/"
        Controllers["API Controllers"]:::backend
        Services["Business Services"]:::backend
        DAL["Data Access Layer / Repositories"]:::backend
        API -->|"routes"| Controllers
        Controllers -->|"calls"| Services
        Services -->|"uses"| DAL
        Mongo["MongoDB"]:::db
        DAL -->|"interacts"| Mongo
        click DAL "https://github.com/michal-szadkowski/coffee-inventory/tree/main/backend/coffee-inventory-data-access/"
        click Mongo "https://github.com/michal-szadkowski/coffee-inventory/blob/main/backend/coffee-inventory-data-access/MongoAccess.cs"
    end

    React -->|"RESTcall"| API
    Svelte -->|"RESTcall"| API
    
    CICD -->|"triggers"| React
    CICD -->|"triggers"| Svelte
    CICD -->|"triggers"| API

    DOCKER --> React
    DOCKER --> Svelte
    DOCKER --> API

    classDef frontend fill:#cfe2f3,stroke:#0b5394,stroke-width:2px;
    classDef backend fill:#d9ead3,stroke:#38761d,stroke-width:2px;
    classDef backendMain fill:#e06666,stroke:#cc0000,stroke-width:2px;
    classDef db fill:#fff2cc,stroke:#bf9000,stroke-width:2px;
    classDef cicd fill:#f9cb9c,stroke:#e69138,stroke-width:2px;
    classDef docker fill:#ead1dc,stroke:#8e7cc3,stroke-width:2px;
```
