# soblechero/monkeys-together-strong architecture

> Architecture diagram of the GitHub repository soblechero/monkeys-together-strong, 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/soblechero/monkeys-together-strong
- Repository: https://github.com/soblechero/monkeys-together-strong

## Overview

##### Main Components
- Mobile App (Frontend):
- Located in the mobile-app folder.
- Built with Ionic, Capacitor, and Vue.
- Contains views, components, services (API and preferences), configuration, and tests (unit and end-to-end).
- Interacts with users via a mobile interface and possibly with an emulated environment.
- Backend API (Backend):
- Located in the backend folder.
- Developed with FastAPI (for routing and endpoints) and SQLModel (for ORM/database interactions).
- Organized into layers such as API routes, core configuration/security, models (representing users, games, genres, messages), persistence (CRUD operations), and external services (e.g., igdb_client, hltb_client).
- Uses environmental configuration files for different environments (development, testing, production).
- Database:
- Configured using different environment files.
- In development: a SQLite database is auto-generated in the data folder.
- In production and testing: connects to PostgreSQL (with the assumption that the instance is pre-created).
- External Services:
- The backend has dedicated services (under app/services/external) for integrating with external clients (like IGDB and HLTB).
- Supporting Components:
- Tests (both for mobile-app and backend) are included to validate behavior and integration.
- Shared configuration and environment management across both projects (using .env files and build scripts).

##### Relationships and Interactions
- The mobile app communicates with the backend API via HTTP requests.
- The backend API processes incoming requests, performs operations (using the defined CRUD routes and business logic), and interacts with the database.
- The backend may also call external services to fetch additional data or perform specific tasks.
- In development, the mobile app can use API mocks (controlled by the VITE_USE_MOCKS flag) or the real backend, based on the environment.
- Testing components for both projects ensure that communication and functionality remain as expected.

##### Architectural Patterns and Design Principles
- Separation of Concerns:
- Frontend (mobile-app) is clearly separated from backend services.
- The backend itself is organized into layers (API, core/configuration, models, persistence, external services).
- API-Driven Architecture:
- Using FastAPI ensures that the backend provides a RESTful (or OpenAPI-based) service with embedded interactive documentation (Swagger UI/Redoc).
- Environment Configuration and Dependency Injection:
- Multiple .env configurations allow the system to adapt to different deployment environments.
- Modular Structure:
- Both projects have well-defined directories (e.g., separate directories for routes, models, services in the backend; dedicated directories for components, views, and tests in the mobile app).

##### Relevant Technologies
- Frontend: Ionic, Capacitor, Vue.js, Tailwind CSS.
- Backend: FastAPI, SQLModel, Uvicorn, Poetry for package management.
- Databases: SQLite (for development), PostgreSQL (for production/testing).
- Additional integrations: External game data services via dedicated API clients.
- Testing: Cypress and unit tests for the mobile app; unit tests (e.g., test_crud operations) for the backend.

##### Final Checklist for the Principal Software Engineer
- Clearly distinguish between the mobile app and backend services.
- Integration points (external APIs) and environment/configuration dependencies.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Section
    subgraph "Mobile App (Frontend)"
        ME["Mobile App (Ionic + Vue)"]:::frontend
        subgraph "Mobile App Components"
            V["Views"]:::frontend
            C["Components"]:::frontend
            S1["API Service"]:::frontend
            S2["Preferences Service"]:::frontend
            T1["Tests (Unit & E2E)"]:::frontend
        end
    end

    %% Backend Section
    subgraph "Backend API"
        B["Backend API (FastAPI + SQLModel)"]:::backend
        subgraph "API Layer"
            AR["API Routes"]:::backend
        end
        subgraph "Core"
            CC["Core Config & Security"]:::backend
            EC["Environment Configuration (.env files)"]:::backend
        end
        subgraph "Business Logic"
            M["Models"]:::backend
            P["Persistence Layer"]:::backend
        end
        subgraph "External Integrations"
            ES1["IGDB Client"]:::external
            ES2["HLTB Client"]:::external
        end
        subgraph "Testing"
            T2["Backend Tests"]:::backend
        end
    end

    %% Database Component
    D["Database (SQLite/PostgreSQL)"]:::database

    %% Connections: Frontend
    ME -->|"renders"| V
    ME -->|"renders"| C
    ME -->|"invokes"| S1

    %% Frontend to Backend Communication
    S1 -->|"HTTP_request"| AR

    %% Backend Internal Communication
    AR -->|"uses"| CC
    AR -->|"calls_CRUD"| P
    AR -->|"external_call"| ES1
    AR -->|"external_call"| ES2

    %% Database Interaction
    P -->|"persists_data"| D

    %% Class Definitions for Colors
    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef backend fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef external fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef database fill:#f8d7da,stroke:#721c24,stroke-width:2px;

    %% Click Events Frontend
    click ME "https://github.com/soblechero/monkeys-together-strong/tree/main/mobile-app"
    click V "https://github.com/soblechero/monkeys-together-strong/tree/main/mobile-app/src/views"
    click C "https://github.com/soblechero/monkeys-together-strong/tree/main/mobile-app/src/components"
    click S1 "https://github.com/soblechero/monkeys-together-strong/tree/main/mobile-app/src/services/api"
    click S2 "https://github.com/soblechero/monkeys-together-strong/tree/main/mobile-app/src/services/preferences"
    click T1 "https://github.com/soblechero/monkeys-together-strong/tree/main/mobile-app/tests"

    %% Click Events Backend
    click AR "https://github.com/soblechero/monkeys-together-strong/tree/main/backend/app/api/routes"
    click CC "https://github.com/soblechero/monkeys-together-strong/tree/main/backend/app/core"
    click EC "https://github.com/soblechero/monkeys-together-strong/tree/main/backend"
    click M "https://github.com/soblechero/monkeys-together-strong/tree/main/backend/app/models"
    click P "https://github.com/soblechero/monkeys-together-strong/tree/main/backend/app/persistence"
    click ES1 "https://github.com/soblechero/monkeys-together-strong/tree/main/backend/app/services/external"
    click ES2 "https://github.com/soblechero/monkeys-together-strong/tree/main/backend/app/services/external"
    click T2 "https://github.com/soblechero/monkeys-together-strong/tree/main/backend/tests"

    %% Click Event Database
    click D "https://github.com/soblechero/monkeys-together-strong/tree/main/backend/data"
```
