# masterflux/bookstore-devops-project architecture

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

- Interactive diagram: https://gitdiagram.com/masterflux/bookstore-devops-project
- Repository: https://github.com/masterflux/bookstore-devops-project

## Overview

##### Frontend service
- Located in the "frontend/bookstorefe" directory.
- Built using Next.js.
- Exposes API endpoints (for login, catalog, cart) that proxy or interface directly with the backend services.
- Configured via environment variables (URL, CATALOG_URL, CART_URL) to point to the backend endpoints.
- Dockerized using its own Dockerfile and Kubernetes manifests.

##### Backend services
a. Catalog Service:
- Found in "backend/catalogservice".
- Built with Express.js under Node.js.
- Serves the catalog-related functionality (likely listing books or handling catalog API calls).
- Has its own Dockerfile and configurations (port 3001 by default).

b. Cart and User Service:
- Located in "backend/cartservice".
- Developed using NestJS, indicating the adoption of an MVC-like pattern and potential for modular component organization (e.g., separating cart and user functionality).
- Manages cart operations and user authentication, as indicated by distinct directories ("cart" and "user").
- Dockerized and exposed on port 3002 by default.

Additionally, there are deployment artifacts such as Docker-Compose scripts, GitHub Actions workflows (.github/workflows), and multiple Kubernetes manifest files in the "k8s-manifests" directory. These indicate that the system leverages container orchestration and CI/CD pipelines to manage builds and deployments.

- Frontend (Next.js based bookstore UI)
- Catalog Service (Express.js based backend)
- Cart & User Service (NestJS based backend)

##### Out the interactions
- Optionally, include any internal communications within the Cart & User Service (e.g., between controllers, services, and database access, if applicable) to show the internal flow.

##### Deployment and containerization aspects
- A representation of the Kubernetes cluster where the different services are deployed as pods/services (frontend, catalog-service, cart-service).
- Optionally, show the CI/CD pipeline (GitHub Actions) that pushes updated Docker images to the deployment environment.
- You may also mention the discovery of these components through environment configurations specified in the Frontend’s .env file and in the Kubernetes manifests.

##### Details related to architectural design
- Microservices pattern and separation of concerns (the frontend is decoupled from backend logic, and backend services are further segregated based on functionality).
- Use of industry standards like Docker and Kubernetes for deployment, as well as code quality setups (linting and formatting configuration files are present in the cart service).

## Diagram (Mermaid)

```mermaid
flowchart TD
    GA("GitHub Actions Pipeline\n(CI/CD)"):::pipeline

    subgraph "Kubernetes Cluster"
        FE("Frontend - Bookstore UI\n(Next.js, Port 3000, Dockerized)"):::frontend
        CAT("Catalog Service\n(Express.js, Port 3001, Dockerized)"):::backend
        CART("Cart & User Service\n(NestJS, Port 3002, Dockerized)"):::backend
    end

    GA --> FE
    GA --> CAT
    GA --> CART

    FE -->|"catalog_API"| CAT
    FE -->|"cart_user_API"| CART

    click FE "https://github.com/masterflux/bookstore-devops-project/tree/main/frontend/bookstorefe"
    click CAT "https://github.com/masterflux/bookstore-devops-project/tree/main/backend/catalogservice"
    click CART "https://github.com/masterflux/bookstore-devops-project/tree/main/backend/cartservice"

    classDef frontend fill:#f9c74f,stroke:#333,stroke-width:2px;
    classDef backend fill:#90be6d,stroke:#333,stroke-width:2px;
    classDef pipeline fill:#f94144,stroke:#333,stroke-width:2px;
```
