# oliverschlueter/mauerstrassenloewen architecture

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

- Interactive diagram: https://gitdiagram.com/oliverschlueter/mauerstrassenloewen
- Repository: https://github.com/oliverschlueter/mauerstrassenloewen

## Overview

##### Main Components
- Frontend: Represented by the "frontend" directory, built in Angular. Indicate UI components (views, interactive modules for trading simulations, quizzes, etc.) and client-side configuration (routing, styles, component logic).
- Backend Service: Under "services/backend", this is the main business logic implementation in Go. It likely exposes REST endpoints, handles API routing, and integrates with the frontend. Also note its API communication with the AI worker and data persistence logic.
- AI Worker Service: Located in "services/ai-worker". This service, also built in Go, interacts with AI models from OpenAI and ollama for the virtual coach functionality and simulation feedback.
- Monitoring Service: Found in "services/monitoring". It provides system health checks, logging, and potentially metrics via its own endpoints.
- External Dependencies: Identify databases (MongoDB, Redis) and external data providers (Yahoo Finance, TradingView API). Although not in the file tree directly, these components are mentioned in the README and are critical to understanding data flow.
- API Communication Layers: Highlight usage of REST, Websockets, and CloudEvents for communication between frontend and backend services.

##### Relationships and Interactions
- The AI Worker Service for processing and generating interactive AI responses.
- The databases (MongoDB, Redis) for data persistence.
- External APIs (Yahoo Finance, TradingView API) to fetch market data.
- Similarly, the Monitoring Service should interface with each of the backend services to collect logs, metrics, and event data.
- If applicable, note any bi-directional communication between the frontend and AI worker for real-time chat interactions.

##### Important Architectural Patterns
- Microservices: The separation of backend functionalities across distinct services (backend, AI worker, monitoring) shows a microservices-style architecture.
- Separation of Concerns: Clear division between presentation (Angular frontend), business logic (Go backend), AI processing (AI worker), and monitoring functions.
- Integration Patterns: Emphasize the role of API Gateways or middleware layers (for logging or security) as indicated by the structured placement of routes and middleware in the backend code.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        F["Angular Frontend\n(UI Components, Routing, Styles)"]:::frontend
    end

    %% Backend Microservices
    subgraph "Backend Microservices"
        B["Go Backend Service\n(REST API, Business Logic)"]:::microservice
        A["Go AI Worker Service\n(AI Coach, Simulation Feedback)"]:::microservice
        M["Go Monitoring Service\n(Logs, Metrics, Health Checks)"]:::microservice
    end

    %% External Dependencies
    subgraph "External Dependencies"
        DB_M["MongoDB\n(Data Persistence)"]:::external
        DB_R["Redis\n(Caching)"]:::external
        EX_Yahoo["YahooFinance API"]:::external
        EX_Trading["TradingView API"]:::external
    end

    %% Deployment/Integration Layer
    subgraph "Deployment & Integration"
        DC["Docker Compose\n(Container Orchestration)"]:::container
        CI["CI/CD Workflows\n(Continuous Integration)"]:::cicd
    end

    %% Interactions & Data Flow
    F -->|"REST/WebSocket"| B
    F -->|"Real-time Chat"| A
    B -->|"calls"| A
    B -->|"queries"| DB_M
    B -->|"queries"| DB_R
    B -->|"fetches"| EX_Yahoo
    B -->|"fetches"| EX_Trading
    M -->|"monitors"| B
    M -->|"monitors"| A

    %% Container Orchestration Relationships
    B -->|"orchestrated_by"| DC
    A -->|"orchestrated_by"| DC
    M -->|"orchestrated_by"| DC
    CI -->|"deploys_to"| DC

    %% Styles
    classDef frontend fill:#B3E5FC,stroke:#0277BD,stroke-width:2px;
    classDef microservice fill:#C8E6C9,stroke:#2E7D32,stroke-width:2px;
    classDef external fill:#FFECB3,stroke:#F9A825,stroke-width:2px;
    classDef container fill:#F8BBD0,stroke:#C2185B,stroke-width:2px;
    classDef cicd fill:#E1BEE7,stroke:#8E24AA,stroke-width:2px;

    %% Click Events
    click F "https://github.com/oliverschlueter/mauerstrassenloewen/tree/main/frontend/"
    click B "https://github.com/oliverschlueter/mauerstrassenloewen/tree/main/services/backend/"
    click A "https://github.com/oliverschlueter/mauerstrassenloewen/tree/main/services/ai-worker/"
    click M "https://github.com/oliverschlueter/mauerstrassenloewen/tree/main/services/monitoring/"
    click CI "https://github.com/oliverschlueter/mauerstrassenloewen/tree/main/.github/workflows/"
```
