# hitohata/wherewerewe architecture

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

- Interactive diagram: https://gitdiagram.com/hitohata/wherewerewe
- Repository: https://github.com/hitohata/wherewerewe

## Overview

##### Main Components
- Frontend: Located in the “frontend” folder. This part is built with modern web technologies (React/TypeScript, given the .tsx files) and includes routing (tab views, layouts), assets (images, fonts), and UI components.
- Backend: Found under “backend/core-where-were-we”. It is a Rust-based backend that is modularly structured into several bounded contexts:
- Services (in app/services) – likely shared utility functions or common services.
- Travel Module (in app/travel) – includes dtos, errors, interfaces, models (entities, repositories, ids), use cases, and service logic for managing travel-related features.
- Users Module (in app/users) – encapsulates all things user-related: dtos, errors, interfaces, models, repository pattern, and use case implementations.
- GraphQL API: A separate “graphql/schema.graphql” file indicates that the application either provides or consumes a GraphQL layer.
- Infrastructure / Deployment:
- “cdk” folder contains AWS CDK configuration (including TypeScript files, stack definitions, deployment scripts), meaning that cloud infrastructure deployment is automated.
- Docker Compose file in the backend further shows container orchestration.

##### Establish Relationships and Interactions
- The Frontend interacts with the Backend, likely through RESTful endpoints or via the GraphQL API.
- The GraphQL layer, based on the schema file, may serve as an interface for the frontend to query and mutate data managed by the backend services.
- Within the Backend, the Travel and Users modules are built around well-defined layers:
- Data Transfer Objects (DTOs) → Error Handling → Interfaces → Models (with repositories and entity definitions) → Service Layer → Use Cases.
- Shared utilities and common services (located under the “utils” folder) are used across backend modules.
- The CDK component defines the cloud infrastructure (networks, compute, storage) which physically hosts the backend (and possibly serves the frontend) and integrates through deployment scripts (Docker Compose for local development and/or production orchestration).

##### Architectural Patterns and Key Design Principles
- Modular design: The backend is segregated into distinct modules (services, travel, users) that each encapsulate their own domain logic.
- Layered architecture: Each module has clear layers (DTOs, errors, interfaces, models/repositories, use cases) indicative of separation of concerns.
- Microservice- or bounded-context-like segmentation: While it’s a single repository, the separation into distinct packages (Cargo workspaces) within the backend suggests that similar principles to microservices (clear boundaries) are applied.
- Infrastructure as code: Usage of AWS CDK shows automation and code-driven cloud deployment.
- Frontend and API separation: The clear separation between frontend (UI) and backend (logic and data handling, exposed via GraphQL or other endpoints) reinforces a full-stack approach.

##### Final Detailed Steps
- Clearly denote interfaces between the frontend and backend (or GraphQL) to represent how data is exchanged.
- Representation of testing and automation (GitHub workflows, test utilities) as support elements around the core deployment flow.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend"
        FrontendUI["Frontend UI"]:::frontend
    end

    subgraph "API Layer"
        GraphQLAPI["GraphQL API"]:::api
    end

    subgraph "Backend Core Application"
        direction TB
        BackendCore["Backend Core Application"]:::backend
        SharedServices["Shared Services"]:::backend
        TravelModule["Travel Module"]:::backend
        UsersModule["Users Module"]:::backend
        BackendCore --> SharedServices
        BackendCore --> TravelModule
        BackendCore --> UsersModule
        TravelModule -->|"uses"| SharedServices
        UsersModule -->|"uses"| SharedServices
    end

    subgraph "Infrastructure & Deployment"
        CDKInfra["CDK Infrastructure"]:::infra
        DockerCompose["Docker Compose Orchestration"]:::infra
    end

    subgraph "Documentation"
        Documentation["Documentation"]:::doc
    end

    FrontendUI -->|"calls"| GraphQLAPI
    GraphQLAPI -->|"queries/mutates"| BackendCore
    FrontendUI -->|"deployed_by"| CDKInfra
    BackendCore -->|"deployed_by"| CDKInfra
    DockerCompose -->|"orchestrates"| BackendCore
    Documentation -->|"references"| FrontendUI

    %% Click Events
    click FrontendUI "https://github.com/hitohata/wherewerewe/tree/develop/frontend/"
    click GraphQLAPI "https://github.com/hitohata/wherewerewe/blob/develop/graphql/schema.graphql"
    click BackendCore "https://github.com/hitohata/wherewerewe/tree/develop/backend/core-where-were-we/"
    click SharedServices "https://github.com/hitohata/wherewerewe/tree/develop/backend/core-where-were-we/app/services/"
    click TravelModule "https://github.com/hitohata/wherewerewe/tree/develop/backend/core-where-were-we/app/travel/"
    click UsersModule "https://github.com/hitohata/wherewerewe/tree/develop/backend/core-where-were-we/app/users/"
    click CDKInfra "https://github.com/hitohata/wherewerewe/tree/develop/cdk/"
    click DockerCompose "https://github.com/hitohata/wherewerewe/blob/develop/backend/core-where-were-we/docker-compose.yml"
    click Documentation "https://github.com/hitohata/wherewerewe/tree/develop/docs/top-page/"

    %% Styles
    classDef frontend fill:#add8e6,stroke:#000,stroke-width:2px;
    classDef backend fill:#90ee90,stroke:#000,stroke-width:2px;
    classDef api fill:#ffebcd,stroke:#000,stroke-width:2px;
    classDef infra fill:#ffcccb,stroke:#000,stroke-width:2px;
    classDef doc fill:#d3d3d3,stroke:#000,stroke-width:2px;
```
