# josebright/refactor-monolith-application-to-microservices architecture

> Architecture diagram of the GitHub repository josebright/refactor-monolith-application-to-microservices, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/josebright/refactor-monolith-application-to-microservices
- Repository: https://github.com/josebright/refactor-monolith-application-to-microservices

## Overview

##### Main Components Identification

a. Frontend Layer:
- Ionic/Angular web application (udagram-frontend)
- As a single container with internal components for:
- Auth Module
- Feed Module
- Home Module
- API Service Layer

b. Backend Microservices:
- Feed Service (udagram-api-feed)
- User Service (udagram-api-user)
- Reverse Proxy (udagram-reverseproxy)

c. External Services:
- AWS S3 for image storage
- PostgreSQL database
- AWS RDS (if used instead of local PostgreSQL)

**[Client Layer]**

**[Reverse Proxy Layer]**

**[Microservices Layer]**

**[External Services Layer]**

##### Component Relationships

- Frontend → Reverse Proxy (HTTP/REST)
- Reverse Proxy → Feed Service & User Service (Internal routing)
- Feed Service → S3 (Image storage)
- Feed Service → PostgreSQL (Feed data)
- User Service → PostgreSQL (User data)

##### Important Details

a. Infrastructure Elements:
- Docker containers (shown by container boundaries)
- Kubernetes deployments (indicated in deployment files)
- CircleCI pipeline (shown as a CI/CD component)

b. Communication Protocols:
- REST APIs between components
- Database connections
- S3 interactions

##### Additional Elements

Include:
- Environment variables configuration
- Security boundaries
- Load balancing through reverse proxy
- API versioning (v0 as seen in the code)

##### Specific Implementation Details

- The separation of user and feed services
- The role of the reverse proxy in routing
- The shared database access pattern
- The authentication flow between services

##### Technical Specifications

Technical details:
- TypeScript/Node.js backend
- Ionic/Angular frontend
- PostgreSQL database
- AWS S3 storage
- Docker containerization
- Kubernetes orchestration
- CircleCI integration

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Frontend["Frontend Application"]:::frontend
        AuthMod["Auth Module"]:::frontend
        FeedMod["Feed Module"]:::frontend
        HomeMod["Home Module"]:::frontend
        APIService["API Service Layer"]:::frontend
        
        Frontend --> AuthMod
        Frontend --> FeedMod
        Frontend --> HomeMod
        Frontend --> APIService
    end

    subgraph "Reverse Proxy"
        RProxy["Reverse Proxy"]:::proxy
    end

    subgraph "Microservices"
        FeedService["Feed Service"]:::backend
        UserService["User Service"]:::backend
        
        subgraph "Feed Service Components"
            FeedRoutes["Feed Routes"]:::routes
            FeedModel["Feed Model"]:::model
            FeedService --> FeedRoutes
            FeedService --> FeedModel
        end
        
        subgraph "User Service Components"
            UserRoutes["User Routes"]:::routes
            AuthRoutes["Auth Routes"]:::routes
            UserModel["User Model"]:::model
            UserService --> UserRoutes
            UserService --> AuthRoutes
            UserService --> UserModel
        end
    end

    subgraph "External Services"
        S3["AWS S3"]:::external
        DB[(PostgreSQL/RDS)]:::database
    end

    subgraph "Infrastructure"
        K8s["Kubernetes Deployments"]:::infra
        Docker["Docker Containers"]:::infra
        CircleCI["CircleCI Pipeline"]:::infra
    end

    APIService --> RProxy
    RProxy --> FeedService
    RProxy --> UserService
    FeedService --> S3
    FeedService --> DB
    UserService --> DB
    
    %% Component Mappings
    click Frontend "https://github.com/josebright/refactor-monolith-application-to-microservices/tree/master/udagram-frontend"
    click AuthMod "https://github.com/josebright/refactor-monolith-application-to-microservices/tree/master/udagram-frontend/src/app/auth"
    click FeedMod "https://github.com/josebright/refactor-monolith-application-to-microservices/tree/master/udagram-frontend/src/app/feed"
    click HomeMod "https://github.com/josebright/refactor-monolith-application-to-microservices/tree/master/udagram-frontend/src/app/home"
    click APIService "https://github.com/josebright/refactor-monolith-application-to-microservices/tree/master/udagram-frontend/src/app/api"
    click FeedService "https://github.com/josebright/refactor-monolith-application-to-microservices/tree/master/udagram-api-feed"
    click UserService "https://github.com/josebright/refactor-monolith-application-to-microservices/tree/master/udagram-api-user"
    click RProxy "https://github.com/josebright/refactor-monolith-application-to-microservices/tree/master/udagram-reverseproxy"
    click FeedRoutes "https://github.com/josebright/refactor-monolith-application-to-microservices/blob/master/udagram-api-feed/src/controllers/v0/feed/routes/feed.router.ts"
    click UserRoutes "https://github.com/josebright/refactor-monolith-application-to-microservices/blob/master/udagram-api-user/src/controllers/v0/users/routes/user.router.ts"
    click AuthRoutes "https://github.com/josebright/refactor-monolith-application-to-microservices/blob/master/udagram-api-user/src/controllers/v0/users/routes/auth.router.ts"
    click FeedModel "https://github.com/josebright/refactor-monolith-application-to-microservices/blob/master/udagram-api-feed/src/controllers/v0/feed/models/FeedItem.ts"
    click UserModel "https://github.com/josebright/refactor-monolith-application-to-microservices/blob/master/udagram-api-user/src/controllers/v0/users/models/User.ts"
    click K8s "https://github.com/josebright/refactor-monolith-application-to-microservices/tree/master/deployment"
    click Docker "https://github.com/josebright/refactor-monolith-application-to-microservices/blob/master/docker-compose.yaml"
    click CircleCI "https://github.com/josebright/refactor-monolith-application-to-microservices/blob/master/.circleci/config.yml"

    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef proxy fill:#e74c3c,stroke:#c0392b,color:white
    classDef external fill:#f1c40f,stroke:#f39c12,color:black
    classDef database fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef infra fill:#34495e,stroke:#2c3e50,color:white
    classDef routes fill:#9b59b6,stroke:#8e44ad,color:white
    classDef model fill:#1abc9c,stroke:#16a085,color:white
```
