# kelvinn44/electrigo architecture

> Architecture diagram of the GitHub repository kelvinn44/electrigo, 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/kelvinn44/electrigo
- Repository: https://github.com/kelvinn44/electrigo

## Overview

##### Project Type & Purpose
- This is a full-stack microservices application built around domain-driven design. Its purpose is to manage car rentals, with distinct services for user/account management (accountService), car bookings and vehicle management (carRentalService), and payment processing (paymentService). A separate frontend (in the public directory) provides the user interface.

##### Main Components
- Account Service:
- Contains business logic related to user accounts, authentication, and account management.
- Files in accountService/account and the main file “main.go”.
- Car Rental Service:
- Responsible for handling vehicle details and booking/reservation logic.
- Separated into subdirectories (booking and car).
- Payment Service:
- Manages payment processing.
- Contains its own main and sub-directory for payment functionality.
- Frontend:
- Static HTML pages, JavaScript, and CSS files under the “public” directory.
- Database:
- The application uses MySQL (as indicated by seed.sql and instructions in the README) to manage persistent data across microservices.
- External Dependencies:
- RESTful API interactions between these services following an API-first approach.
- Environment variables (configured via .env files in accountService and paymentService).

##### Relationships & Interactions
- Each microservice is independently deployable and interacts with others via RESTful APIs.
- The microservices themselves are loosely coupled: for example, the car rental service uses a separate API call to contact the payment service when processing bookings.

##### Architectural Patterns & Design Principles
- Domain-Driven Design: Each service encapsulates its respective domain logic (accounts, vehicles/bookings, payments).
- Loosely Coupled Microservices: Clearly show that each service is autonomous with its own processes and deployment lifecycle.
- API-First Communication: Represent communication between services over RESTful APIs and include versioning details (e.g., /v1) if necessary.
- Independent Deployability: Indicate that services can be updated or rolled back without affecting others.
- Security Best Practices: Optionally, note elements like environment variables for credentials and secure password handling (bcrypt).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interface Layer
    subgraph "User Interface Layer"
        FE["Frontend (HTML/CSS/JS)"]:::frontend
    end

    %% Microservices Layer
    subgraph "Microservices Layer"
        AS["Account Service\n(Account Management)"]:::service
        CRS["Car Rental Service\n(Bookings/Vehicle Management)"]:::service
        PS["Payment Service\n(Billing)"]:::service
    end

    %% Database Layer
    subgraph "Database Layer"
        DB["MySQL\n(Persistent Storage)"]:::database
    end

    %% Connections from Frontend to Microservices
    FE -->|"API-Call"| AS
    FE -->|"API-Call"| CRS
    FE -->|"API-Call"| PS

    %% Inter-Service Communication
    CRS -->|"CallsPaymentAPI"| PS

    %% Microservices Interaction with Database
    AS -->|"DataOps"| DB
    CRS -->|"DataOps"| DB
    PS -->|"DataOps"| DB

    %% Click Events for Account Service
    click AS "https://github.com/kelvinn44/electrigo/tree/main/accountService/account"
    click AS "https://github.com/kelvinn44/electrigo/blob/main/accountService/main.go"

    %% Click Events for Car Rental Service
    click CRS "https://github.com/kelvinn44/electrigo/tree/main/carRentalService/booking"
    click CRS "https://github.com/kelvinn44/electrigo/tree/main/carRentalService/car"
    click CRS "https://github.com/kelvinn44/electrigo/blob/main/carRentalService/main.go"

    %% Click Events for Payment Service
    click PS "https://github.com/kelvinn44/electrigo/tree/main/paymentService/payment"
    click PS "https://github.com/kelvinn44/electrigo/blob/main/paymentService/main.go"

    %% Click Event for Frontend
    click FE "https://github.com/kelvinn44/electrigo/tree/main/public"

    %% Click Event for Database
    click DB "https://github.com/kelvinn44/electrigo/blob/main/seed.sql"

    %% Styles
    classDef frontend fill:#fbe0c4,stroke:#d35400,stroke-width:2px;
    classDef service fill:#d6eaf8,stroke:#2e86c1,stroke-width:2px;
    classDef database fill:#d5f5e3,stroke:#27ae60,stroke-width:2px;
```
