# nakakakilig/my_tinder_clone architecture

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

- Interactive diagram: https://gitdiagram.com/nakakakilig/my_tinder_clone
- Repository: https://github.com/nakakakilig/my_tinder_clone

## Overview

##### Overall System Components
- Microservices: Show the three main services – deck-service, profile-service, and swipe-service. Each of these encapsulates its own business logic, domain models, and presentation layer (HTTP endpoints/routes).
- Infrastructure Components:
– Database: Each service has its own database models, migrations, and DB helper components.
– Caching Layer: Particularly in the deck-service, where you see multiple caching implementations.
– Event Streaming: Kafka is integrated, with dedicated consumer/producer components in different services. Additionally, there are docker-compose files under a “kafka” directory.
– External Integrations: The services might interact with each other through messaging or REST APIs.
– Containerization & Orchestration: Docker compose files are present for each service, so indicate the deployment context (containers/services can be run in isolated containers coordinated by Docker compose).

##### Architectural Layers Within Each Microservice
- Domain: Contains core business models and domain logic (e.g., models and enums).
- Application: Contains business use cases, schemas, and service implementations (e.g., handling deck, profile, swipe logic).
- Infrastructure: Handles persistence (DB connections, DB models) and integration with external systems (Kafka, caching factories).
- Presentation: Exposes API endpoints and dependencies for handling HTTP requests (routes and dependency injection).

##### Relationships and Interactions Between Components
- How the Presentation layer (API routes) interacts with the Application layer (services) which then manipulates the Domain models.
- Infrastructure layer (database access, caching, Kafka messaging) demonstrating how data and events are persisted and shared.
- Inter-service communication: For example, indicate that profile-service and swipe-service may subscribe or produce messages using Kafka for eventual consistency and data propagation.

##### Design Patterns and Principles
- Microservices architecture: Each service is an independent unit with its own layered structure.
- Separation of Concerns / Clean Architecture: Clear divisions (domain, application, infrastructure, presentation) are visible.
- Event-driven / Messaging: Kafka integration plays a significant role in ensuring asynchronous communication between components.
- Database Migrations: Use Alembic for version control of DB schemas, indicating good practices in database evolution.
- Configuration Management: Notice the .env.template files and settings modules, which serve as configuration entry points.

##### Integrate Technology and Framework Information
- Document Python as the primary language.
- Use libraries/frameworks for API handling (likely FastAPI or Flask given the structure in the presentation layer), database management (via SQLAlchemy using Alembic migrations), and message queuing (Kafka).
- Caching frameworks (Redis or memory-based caching).

## Diagram (Mermaid)

```mermaid
flowchart TB

    %% Deck Service
    subgraph "deck-service"
        d_pres("Deck Presentation"):::presentation
        d_app("Deck Application"):::application
        d_dom("Deck Domain"):::domain
        subgraph "Deck Infrastructure"
            d_db("Deck Database"):::database
            d_cache("Deck Caching"):::cache
            d_kafka("Deck Kafka Integration"):::kafka
        end
        d_pres -->|"calls"| d_app
        d_app -->|"uses"| d_dom
        d_app -->|"persists"| d_db
        d_app -->|"caches"| d_cache
        d_app -->|"publishes"| d_kafka
        d_alembic("Deck Alembic (Migrations)"):::migration
        d_app -->|"migrates"| d_alembic
        d_dcompose("Deck Docker Compose"):::docker
    end

    %% Profile Service
    subgraph "profile-service"
        p_pres("Profile Presentation"):::presentation
        p_app("Profile Application"):::application
        p_dom("Profile Domain"):::domain
        subgraph "Profile Infrastructure"
            p_db("Profile Database"):::database
            p_kafka("Profile Kafka Integration"):::kafka
        end
        p_pres -->|"calls"| p_app
        p_app -->|"uses"| p_dom
        p_app -->|"persists"| p_db
        p_app -->|"publishesSubscribes"| p_kafka
        p_alembic("Profile Alembic (Migrations)"):::migration
        p_app -->|"migrates"| p_alembic
        p_dcompose("Profile Docker Compose"):::docker
    end

    %% Swipe Service
    subgraph "swipe-service"
        s_pres("Swipe Presentation"):::presentation
        s_app("Swipe Application"):::application
        s_dom("Swipe Domain"):::domain
        subgraph "Swipe Infrastructure"
            s_db("Swipe Database"):::database
            s_mappers("Swipe Mappers"):::mapper
        end
        s_pres -->|"calls"| s_app
        s_app -->|"uses"| s_dom
        s_app -->|"persists"| s_db
        s_app -->|"maps"| s_mappers
        s_alembic("Swipe Alembic (Migrations)"):::migration
        s_app -->|"migrates"| s_alembic
        s_dcompose("Swipe Docker Compose"):::docker
        subgraph "Swipe Presentation Extra"
            s_pres_dep("Routes & Dependencies"):::presentation
            s_pres_map("Presentation Mappers"):::mapper
        end
        s_pres --> s_pres_dep
        s_pres --> s_pres_map
    end

    %% External Kafka Coordination
    kafka_cluster("Kafka Cluster"):::external
    d_kafka -->|"streamsToFrom"| kafka_cluster
    p_kafka -->|"streamsToFrom"| kafka_cluster
    kafka_dcompose("Kafka Docker Compose"):::docker
    kafka_cluster -->|"orchestratedBy"| kafka_dcompose

    %% Management & Deployment Scripts
    mgmt("Management & Deployment Scripts"):::external
    mgmt --> d_dcompose
    mgmt --> p_dcompose
    mgmt --> s_dcompose
    mgmt -->|"runs"| scripts("Scripts"):::external

    %% Configuration Management
    subgraph "Configuration Management"
        d_env(".env (deck-service)"):::config
        d_settings("Settings (deck-service)"):::config
        p_env(".env (profile-service)"):::config
        p_settings("Settings (profile-service)"):::config
        s_env(".env (swipe-service)"):::config
        s_settings("Settings (swipe-service)"):::config
    end
    d_pres -->|"configures"| d_settings
    p_pres -->|"configures"| p_settings
    s_pres -->|"configures"| s_settings

    %% Click Events
    click d_pres "https://github.com/nakakakilig/my_tinder_clone/tree/main/deck-service/app/presentation/"
    click d_app "https://github.com/nakakakilig/my_tinder_clone/tree/main/deck-service/app/application/"
    click d_dom "https://github.com/nakakakilig/my_tinder_clone/tree/main/deck-service/app/domain/"
    click d_db "https://github.com/nakakakilig/my_tinder_clone/tree/main/deck-service/app/infrastructure/db/"
    click d_cache "https://github.com/nakakakilig/my_tinder_clone/tree/main/deck-service/app/infrastructure/cache/"
    click d_kafka "https://github.com/nakakakilig/my_tinder_clone/tree/main/deck-service/app/infrastructure/kafka/"
    click d_alembic "https://github.com/nakakakilig/my_tinder_clone/tree/main/deck-service/app/alembic/"
    click d_dcompose "https://github.com/nakakakilig/my_tinder_clone/blob/main/deck-service/docker-compose.yml"

    click p_pres "https://github.com/nakakakilig/my_tinder_clone/tree/main/profile-service/app/presentation/"
    click p_app "https://github.com/nakakakilig/my_tinder_clone/tree/main/profile-service/app/application/"
    click p_dom "https://github.com/nakakakilig/my_tinder_clone/tree/main/profile-service/app/domain/"
    click p_db "https://github.com/nakakakilig/my_tinder_clone/tree/main/profile-service/app/infrastructure/db/"
    click p_kafka "https://github.com/nakakakilig/my_tinder_clone/tree/main/profile-service/app/infrastructure/kafka/"
    click p_alembic "https://github.com/nakakakilig/my_tinder_clone/tree/main/profile-service/app/alembic/"
    click p_dcompose "https://github.com/nakakakilig/my_tinder_clone/blob/main/profile-service/docker-compose.yml"

    click s_pres "https://github.com/nakakakilig/my_tinder_clone/tree/main/swipe-service/app/presentation/"
    click s_app "https://github.com/nakakakilig/my_tinder_clone/tree/main/swipe-service/app/application/"
    click s_dom "https://github.com/nakakakilig/my_tinder_clone/tree/main/swipe-service/app/domain/"
    click s_db "https://github.com/nakakakilig/my_tinder_clone/tree/main/swipe-service/app/infrastructure/db/"
    click s_mappers "https://github.com/nakakakilig/my_tinder_clone/tree/main/swipe-service/app/infrastructure/mappers/"
    click s_alembic "https://github.com/nakakakilig/my_tinder_clone/tree/main/swipe-service/app/alembic/"
    click s_dcompose "https://github.com/nakakakilig/my_tinder_clone/blob/main/swipe-service/docker-compose.yml"
    click s_pres_dep "https://github.com/nakakakilig/my_tinder_clone/tree/main/swipe-service/app/presentation/"
    click s_pres_map "https://github.com/nakakakilig/my_tinder_clone/tree/main/swipe-service/app/presentation/mappers/"

    click kafka_dcompose "https://github.com/nakakakilig/my_tinder_clone/blob/main/kafka/docker-compose.yml"
    click d_env "https://github.com/nakakakilig/my_tinder_clone/blob/main/deck-service/.env.template"
    click d_settings "https://github.com/nakakakilig/my_tinder_clone/blob/main/deck-service/app/config/settings.py"
    click p_env "https://github.com/nakakakilig/my_tinder_clone/blob/main/profile-service/.env.template"
    click p_settings "https://github.com/nakakakilig/my_tinder_clone/blob/main/profile-service/app/config/settings.py"
    click s_env "https://github.com/nakakakilig/my_tinder_clone/blob/main/swipe-service/.env.template"
    click s_settings "https://github.com/nakakakilig/my_tinder_clone/blob/main/swipe-service/app/config/settings.py"
    click mgmt "https://github.com/nakakakilig/my_tinder_clone/tree/main/scripts/"

    %% Styles
    classDef presentation fill:#f9f,stroke:#333,stroke-width:2px;
    classDef application fill:#bbf,stroke:#333,stroke-width:2px;
    classDef domain fill:#bfb,stroke:#333,stroke-width:2px;
    classDef database fill:#ffb,stroke:#333,stroke-width:2px;
    classDef cache fill:#fc9,stroke:#333,stroke-width:2px;
    classDef kafka fill:#cff,stroke:#333,stroke-width:2px;
    classDef migration fill:#ddd,stroke:#333,stroke-width:2px;
    classDef docker fill:#fdd,stroke:#333,stroke-width:2px;
    classDef mapper fill:#dfd,stroke:#333,stroke-width:2px;
    classDef config fill:#cfc,stroke:#333,stroke-width:2px;
    classDef external fill:#eef,stroke:#333,stroke-width:2px;
```
