# rak-code/athena architecture

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

- Interactive diagram: https://gitdiagram.com/rak-code/athena
- Repository: https://github.com/rak-code/athena

## Overview

##### Project type and purpose
- This is a full-stack e-commerce application (“Athena”) with two main parts:
- A React-based frontend (user shopping site + admin panel).
- A Spring Boot backend exposing REST endpoints and handling business logic, persistence, authentication, and integrations.
- Primary use cases:
- Public users browse products, manage cart/wishlist, place orders, write reviews.
- Admin users log in to view metrics, manage products/orders/categories/users/payments.
- AI chat support via Hugging Face API.

##### File structure
- Top level:
- frontend/ – React app code, components, pages, contexts, services, styles, build configs.
- backend/ – Spring Boot code, controllers, services, repositories, models, config, Docker & Maven setup, Flyway migrations.
- athena.sql + migration scripts under backend/src/main/resources/db/migration – MySQL schema & migrations.
- Architectural patterns & layers in backend:
- Controllers → Services → Repositories (DAO) → Database (MySQL).
- Configuration classes for CORS, Web, OpenAPI, Security (JWT).
- Deployment artifacts:
- backend/Dockerfile + docker-compose.yml (backend + DB).
- frontend/.env → points to backend API.

##### Key insights from README
- Technologies: React.js, React Router, Axios, Bootstrap on frontend; Spring Boot, Spring Security (JWT), Flyway, JPA/Hibernate, MySQL on backend.
- Features: role-based auth, product/order/user management, shopping cart, wishlist, reviews, email notifications, AI chat integration.
- API contract: many `/api/...` endpoints grouped by resource (products, orders, users, etc.).

- Controllers (list major controllers)
- Services (list PaymentService, OrderService, EmailService, HuggingFaceChatService)
- Repositories
- Config & Security (CorsConfig, WebConfig, SecurityConfig, JwtAuthenticationFilter)
- Client → Controllers (HTTP/REST + JWT)
- Controllers → Services → Repositories → MySQL
- Services → External services
- Database → Controllers (read queries)

## Diagram (Mermaid)

```mermaid
graph TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        SPA["React SPA"]:::frontend
        Main["main.jsx"]:::frontend
        App["App.jsx"]:::frontend
        UIComp["UI Components"]:::frontend
        CartCtx["CartContext"]:::frontend
        WishCtx["WishlistContext"]:::frontend
        Protected["ProtectedRoute"]:::frontend
        PagesPub["Public Pages"]:::frontend
        PagesUser["User Pages"]:::frontend
        PagesAdmin["Admin Pages"]:::frontend
        ApiSvc["API Services (Axios)"]:::frontend
        Env[".env & .env.example"]:::frontend

        SPA --> Main
        Main --> App
        App --> UIComp
        UIComp --> CartCtx
        UIComp --> WishCtx
        App --> Protected
        Protected --> PagesPub
        Protected --> PagesUser
        Protected --> PagesAdmin
        UIComp --> PagesPub
        UIComp --> PagesUser
        UIComp --> PagesAdmin
        App --> ApiSvc
    end

    %% Backend Layer
    subgraph "Backend Layer"
        AppClass["BackendApplication.java"]:::backend
        Config["Config & Security"]:::backend
        Controllers["Controllers"]:::backend
        Services["Business Services"]:::backend
        Repos["Repositories"]:::backend
        Models["Models"]:::backend
        DTOs["DTOs"]:::backend
        Flyway["Flyway Migrations"]:::datastore
        Props["application.properties"]:::backend
        Docker["Dockerfile & docker-compose.yml"]:::backend
        Maven["pom.xml & mvnw"]:::backend
        Tests["Backend Tests"]:::backend

        AppClass --> Config
        AppClass --> Controllers
        AppClass --> Services
        AppClass --> Repos
        AppClass --> Flyway
        AppClass --> Props

        Controllers --> Services
        Services --> Repos
        Controllers --> Models
        Controllers --> DTOs
        Repos --> Models
    end

    %% Database and External
    AthenaDB["Athena DB<br/>(MySQL)"]:::datastore
    athenaSQL["athena.sql"]:::datastore
    HuggingFace["Hugging Face Chat API"]:::external
    SMTP["SMTP Email Service"]:::external

    %% Flows
    ApiSvc -->|"HTTP/REST + JWT"| Controllers
    Controllers -->|"Calls"| Services
    Services -->|"Persists/Queries"| AthenaDB
    Services -->|"Sends email"| SMTP
    Services -->|"Chatbot calls"| HuggingFace
    Flyway --> AthenaDB
    athenaSQL -.-> AthenaDB
    AthenaDB --> Repos

    %% Click Events
    click SPA "https://github.com/rak-code/athena/tree/main/frontend/src/"
    click Main "https://github.com/rak-code/athena/blob/main/frontend/src/main.jsx"
    click App "https://github.com/rak-code/athena/blob/main/frontend/src/App.jsx"
    click UIComp "https://github.com/rak-code/athena/tree/main/frontend/src/components/"
    click CartCtx "https://github.com/rak-code/athena/blob/main/frontend/src/context/CartContext.jsx"
    click WishCtx "https://github.com/rak-code/athena/blob/main/frontend/src/context/WishlistContext.jsx"
    click Protected "https://github.com/rak-code/athena/blob/main/frontend/src/components/ProtectedRoute.jsx"
    click PagesPub "https://github.com/rak-code/athena/tree/main/frontend/src/pages/"
    click PagesAdmin "https://github.com/rak-code/athena/tree/main/frontend/src/pages/admin/"
    click PagesUser "https://github.com/rak-code/athena/tree/main/frontend/src/pages/user/"
    click ApiSvc "https://github.com/rak-code/athena/tree/main/frontend/src/services/"
    click Env "https://github.com/rak-code/athena/blob/main/frontend/.env"
    click Env "https://github.com/rak-code/athena/blob/main/frontend/.env.example"
    click AppClass "https://github.com/rak-code/athena/blob/main/backend/src/main/java/com/example/backend/BackendApplication.java"
    click Controllers "https://github.com/rak-code/athena/tree/main/backend/src/main/java/com/example/backend/controller/"
    click Services "https://github.com/rak-code/athena/tree/main/backend/src/main/java/com/example/backend/services/"
    click Repos "https://github.com/rak-code/athena/tree/main/backend/src/main/java/com/example/backend/repository/"
    click Models "https://github.com/rak-code/athena/tree/main/backend/src/main/java/com/example/backend/model/"
    click DTOs "https://github.com/rak-code/athena/tree/main/backend/src/main/java/com/example/backend/dto/"
    click Config "https://github.com/rak-code/athena/tree/main/backend/src/main/java/com/example/backend/config/"
    click Flyway "https://github.com/rak-code/athena/tree/main/backend/src/main/resources/db/migration/"
    click Props "https://github.com/rak-code/athena/blob/main/backend/src/main/resources/application.properties"
    click athenaSQL "https://github.com/rak-code/athena/blob/main/athena.sql"
    click Docker "https://github.com/rak-code/athena/tree/main/backend/Dockerfile"
    click Docker "https://github.com/rak-code/athena/blob/main/backend/docker-compose.yml"
    click Maven "https://github.com/rak-code/athena/blob/main/backend/pom.xml"
    click Maven "https://github.com/rak-code/athena/tree/main/backend/mvnw"
    click Maven "https://github.com/rak-code/athena/tree/main/backend/.mvn/"
    click Tests "https://github.com/rak-code/athena/blob/main/backend/src/test/java/com/example/backend/BackendApplicationTests.java"

    %% Styles
    classDef frontend fill:#D6EAF8,stroke:#3498DB,color:#1B4F72
    classDef backend fill:#D5F5E3,stroke:#27AE60,color:#145A32
    classDef datastore fill:#FDEDEC,stroke:#E74C3C,color:#641E16,stroke-dasharray: 5 5
    classDef external fill:#F4F6F7,stroke:#7F8C8D,color:#2C3E50,stroke-dasharray: 2 2
```
