# mohamed-afzal-nandolia/apna-mart architecture

> Architecture diagram of the GitHub repository mohamed-afzal-nandolia/apna-mart, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mohamed-afzal-nandolia/apna-mart
- Repository: https://github.com/mohamed-afzal-nandolia/apna-mart

## Overview

##### Main Components
- Frontend: Built with React and TailwindCSS. It contains pages, components, hooks, and services (e.g., components like DashboardMain, LoginForm, SignupForm, and pages such as HomePage, Checkout, ItemPage). The frontend interacts with the backend through dedicated APIs.
- Backend: Implemented in Spring Boot using Maven. It consists of multiple packages that are clearly structured – controllers (e.g., AdminController, UserController, OrderController), service layers with standard service interfaces and their implementations, repositories for database access, and security components (JWT-based authentication, security configuration). Also note configuration classes like CloudinaryConfig for integrating external image handling.
- Database: MySQL serves as the persistent data store. The project includes a SQL script (database/db.sql) and uses JPA repositories in the backend to interact with the database.
- Infrastructure/Deployment: There’s a Dockerfile in the backend, Maven wrapper files, and configuration files (e.g., application.yml and application.properties) that hint at containerization and configurable environments.

##### Component Relationships
- The Backend layer includes several sub-components:
- Controllers route incoming HTTP requests.
- Service layers encapsulate business logic.
- Repositories handle persistence with MySQL.
- Security components and configurations (JWT, Authentication filters) protect endpoints.
- External Services: There is integration with Cloudinary as seen with the CloudinaryConfig class that handles media uploads.

##### Architectural Patterns and Design Principles
- Clear MVC (Model-View-Controller) patterns in the backend: Controllers, Services, Repositories.
- Layered architecture for separation of concerns (e.g., API layer, business logic layer, persistence layer).
- Use of dependency injection and configuration management via Spring Boot.
- Frontend component-based architecture typical of React.
- Use of Docker for ensuring consistent deployment environments (as indicated by the Dockerfile).

##### Relevant Technologies and Frameworks
- Frontend: React, TailwindCSS, Vite (for build and development).
- Backend: Spring Boot, Maven, JWT for security, and integration with Cloudinary.
- Database: MySQL.
- Additionally, you may note build scripts (Maven, npm) and environment configuration files.

##### Elements
- Use clear, self-explanatory labels for each component (for example, "Frontend (React/Tailwind)", "Backend (Spring Boot)", "MySQL Database", "Cloudinary Service").
- From Frontend to Backend indicating HTTP requests (API calls).
- From Backend to the Database indicating CRUD operations.
- From Backend to External Services (like Cloudinary) for media handling.
- Connection details like security layers (JWT token validation processes) within the backend.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        FE1("Frontend (React/TailwindCSS UI)"):::frontend
        FE2("Pages (HomePage,Checkout,ItemPage)"):::frontend
        FE3("Components (DashboardMain,LoginForm,SignupForm)"):::frontend
        FE4("Hooks"):::frontend
        FE5("Services (API Calls)"):::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer (Spring Boot)"
        BE1("Application Entry Point"):::backend
        BE2("Controllers (API Endpoints)"):::backend
        BE3("Services (Business Logic)"):::backend
        BE4("Repositories (Data Persistence)"):::backend
        BE5("Security (JWT & Config)"):::backend
        BE6("Cloudinary Integration"):::backend
    end

    %% Database Layer
    subgraph "Database Layer"
        DB("MySQL Database"):::database
    end

    %% Deployment Layer
    subgraph "Deployment"
        DEP("Infrastructure (Docker, Maven, Config)"):::deployment
    end

    %% Frontend Internal Flows
    FE1 --> FE2
    FE1 --> FE3
    FE1 --> FE4
    FE1 --> FE5

    %% Frontend to Backend Flows
    FE2 -->|"HTTP_request"| BE2
    FE3 -->|"HTTP_request"| BE2
    FE5 -->|"API_call"| BE2

    %% Backend Internal Flows
    BE1 --> BE2
    BE2 --> BE3
    BE3 --> BE4
    BE2 --> BE5
    BE3 --> BE6
    BE5 -->|"secures"| BE2

    %% Backend to Database
    BE4 -->|"CRUD_operations"| DB

    %% Backend to Deployment
    BE1 --- DEP
    BE2 --- DEP
    BE3 --- DEP
    BE4 --- DEP
    BE5 --- DEP
    BE6 --- DEP

    %% Frontend to Backend Entry Point (Initialization)
    FE1 -->|"initiate"| BE1

    %% Click Events for Component Mapping
    click FE2 "https://github.com/mohamed-afzal-nandolia/apna-mart/tree/main/frontend/src/pages"
    click FE3 "https://github.com/mohamed-afzal-nandolia/apna-mart/tree/main/frontend/src/components"
    click FE4 "https://github.com/mohamed-afzal-nandolia/apna-mart/tree/main/frontend/src/hooks"
    click FE5 "https://github.com/mohamed-afzal-nandolia/apna-mart/tree/main/frontend/src/services"
    click BE1 "https://github.com/mohamed-afzal-nandolia/apna-mart/blob/main/backend/src/main/java/net/apnamart/backend/ApnaMartApplication.java"
    click BE2 "https://github.com/mohamed-afzal-nandolia/apna-mart/tree/main/backend/src/main/java/net/apnamart/backend/controller"
    click BE3 "https://github.com/mohamed-afzal-nandolia/apna-mart/tree/main/backend/src/main/java/net/apnamart/backend/service"
    click BE4 "https://github.com/mohamed-afzal-nandolia/apna-mart/tree/main/backend/src/main/java/net/apnamart/backend/repository"
    click BE5 "https://github.com/mohamed-afzal-nandolia/apna-mart/tree/main/backend/src/main/java/net/apnamart/backend/Security"
    click BE6 "https://github.com/mohamed-afzal-nandolia/apna-mart/blob/main/backend/src/main/java/net/apnamart/backend/Config/CloudinaryConfig.java"
    click DB "https://github.com/mohamed-afzal-nandolia/apna-mart/blob/main/database/db.sql"
    click DEP "https://github.com/mohamed-afzal-nandolia/apna-mart/tree/main/backend/Dockerfile"

    %% Styles
    classDef frontend fill:#bbdefb,stroke:#0d47a1,stroke-width:2px;
    classDef backend fill:#c8e6c9,stroke:#1b5e20,stroke-width:2px;
    classDef database fill:#ffe0b2,stroke:#e65100,stroke-width:2px;
    classDef deployment fill:#d7ccc8,stroke:#4e342e,stroke-width:2px;
```
