# edward2362/android-asm3-2022 architecture

> Architecture diagram of the GitHub repository edward2362/android-asm3-2022, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/edward2362/android-asm3-2022
- Repository: https://github.com/edward2362/android-asm3-2022

## Overview

##### Project Type and Purpose
- This is a full-stack “Go-Goat” book marketplace composed of:
- A native Android front-end (Java + XML)
- A Node.js/Express RESTful API back-end
- A MongoDB database (Atlas)
- Purpose: allow users to browse, search, post, update, delete, and purchase new/used books, including account management and seller reviews.

##### File Structure Analysis
- Backend/
- index.js (server entry)
- config/db.js (MongoDB connection)
- controllers/ (business logic per resource: auth, book, order, etc.)
- models/ (Mongoose schemas)
- routes/ (Express routes mapping to controllers)
- middleware/auth.js (JWT or session checks)
- Frontend/
- app/src/main/java/com/example/asm3/… – Activities, Fragments, Controllers, Adapters, Models
- base/networking/api (ApiService interface) & services (HTTP tasks)
- base/localStorage (file-based persistence)
- config/Constant.java (endpoints, keys)
- resources: layouts, drawables, menus, values
- build.gradle, wrapper files

##### Key Components to Illustrate
- Android Client
- UI Layer: Activities & Fragments
- Controller/VM Layer: Controllers and ViewModels
- Networking Layer: Retrofit/AsyncTask modules via ApiService
- Local Storage (caching or offline)
- REST API Server
- Express Server (index.js)
- Middleware (authentication)
- Router Layer (routes/*.js)
- Controller Layer (controllers/*.js)
- Data Layer (models/*.js using Mongoose)
- Database
- MongoDB cluster (Atlas)
- External Services
- Heroku (hosting API)
- Potential push notification service

##### Relationships and Data Flows
- Android → HTTP(S) requests → API endpoints (e.g., GET /api/book/getProducts)
- API → CRUD operations → MongoDB
- API → JSON responses → Android client
- Auth flows: login/register endpoints returning JWT or session token → stored locally → attached to subsequent requests
- NotificationReceiver on Android might handle push notifications from server/external service

##### Architectural Patterns & Principles
- Backend: MVC (models, routes/controllers, express server)
- Frontend: MVVM-like (Activities/Fragments + Controllers/ViewModels + Adapters)
- Clear separation of concerns: UI vs networking vs data layers
- RESTful design, stateless API, token‐based authentication

##### Essential Elements
- Component labels: Activity names, Controller modules, API endpoints, Model schemas
- Container boundaries for Frontend vs Backend vs Cloud

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Android Client"
        direction TB
        Activities["Activities"]:::mobile
        Fragments["Fragments"]:::mobile
        ViewModels["Controllers / ViewModels"]:::mobile
        ApiService["ApiService"]:::mobile
        NetworkingServices["Networking Services"]:::mobile
        LocalFileController["LocalFileController"]:::mobile
        NotificationReceiver["NotificationReceiver"]:::mobile
    end

    subgraph "API Server"
        direction TB
        ExpressServer["index.js"]:::backend
        DBConfig["db.js"]:::backend
        Constants["Constants.js"]:::backend
        AuthMiddleware["auth.js"]:::backend

        subgraph "Routes"
            direction TB
            AuthRoute["auth.js"]:::backend
            BookRoute["book.js"]:::backend
            CategoryRoute["category.js"]:::backend
            NotificationRoute["notification.js"]:::backend
            OrderRoute["order.js"]:::backend
            ReviewRoute["review.js"]:::backend
            SubCategoryRoute["subCategory.js"]:::backend
        end

        subgraph "Controllers"
            direction TB
            AuthController["authController.js"]:::backend
            BookController["bookController.js"]:::backend
            CategoryController["categoryController.js"]:::backend
            NotificationController["notificationController.js"]:::backend
            OrderController["orderController.js"]:::backend
            ReviewController["reviewController.js"]:::backend
            SubCategoryController["subCategoryController.js"]:::backend
        end

        subgraph "Models"
            direction TB
            BookModel["Book.js"]:::backend
            CategoryModel["Category.js"]:::backend
            CustomerModel["Customer.js"]:::backend
            NotificationModel["Notification.js"]:::backend
            OrderModel["Order.js"]:::backend
            ReviewModel["Review.js"]:::backend
            SubCategoryModel["SubCategory.js"]:::backend
        end
    end

    subgraph "Cloud / External Services"
        direction TB
        MongoDBAtlas["MongoDB Atlas"]:::database
        Heroku["Heroku Hosting"]:::external
        NotificationService["Push Notification Service"]:::external
    end

    %% Data Flows
    Activities -->|"uses"| ViewModels
    Fragments -->|"binds to"| ViewModels
    ViewModels -->|"calls"| ApiService
    ApiService -->|"invokes"| NetworkingServices
    NetworkingServices -->|"HTTP requests"| ExpressServer
    ExpressServer -->|"loads"| DBConfig
    ExpressServer -->|"uses constants"| Constants
    ExpressServer -->|"applies"| AuthMiddleware
    AuthMiddleware --> AuthRoute
    ExpressServer --> AuthRoute
    ExpressServer --> BookRoute
    ExpressServer --> CategoryRoute
    ExpressServer --> NotificationRoute
    ExpressServer --> OrderRoute
    ExpressServer --> ReviewRoute
    ExpressServer --> SubCategoryRoute

    AuthRoute --> AuthController
    BookRoute --> BookController
    CategoryRoute --> CategoryController
    NotificationRoute --> NotificationController
    OrderRoute --> OrderController
    ReviewRoute --> ReviewController
    SubCategoryRoute --> SubCategoryController

    AuthController --> CustomerModel
    BookController --> BookModel
    CategoryController --> CategoryModel
    NotificationController --> NotificationModel
    OrderController --> OrderModel
    ReviewController --> ReviewModel
    SubCategoryController --> SubCategoryModel

    BookModel --> MongoDBAtlas
    CategoryModel --> MongoDBAtlas
    CustomerModel --> MongoDBAtlas
    NotificationModel --> MongoDBAtlas
    OrderModel --> MongoDBAtlas
    ReviewModel --> MongoDBAtlas
    SubCategoryModel --> MongoDBAtlas

    NetworkingServices --> Heroku
    Heroku --> ExpressServer

    NotificationService --> NotificationReceiver

    %% Click Events - Android Client
    click Activities "https://github.com/edward2362/android-asm3-2022/tree/main/Frontend/app/src/main/java/com/example/asm3/"
    click Fragments "https://github.com/edward2362/android-asm3-2022/tree/main/Frontend/app/src/main/java/com/example/asm3/fragments/"
    click ViewModels "https://github.com/edward2362/android-asm3-2022/tree/main/Frontend/app/src/main/java/com/example/asm3/controllers/"
    click ApiService "https://github.com/edward2362/android-asm3-2022/blob/main/Frontend/app/src/main/java/com/example/asm3/base/networking/api/ApiService.java"
    click NetworkingServices "https://github.com/edward2362/android-asm3-2022/tree/main/Frontend/app/src/main/java/com/example/asm3/base/networking/services/"
    click LocalFileController "https://github.com/edward2362/android-asm3-2022/blob/main/Frontend/app/src/main/java/com/example/asm3/base/localStorage/LocalFileController.java"
    click NotificationReceiver "https://github.com/edward2362/android-asm3-2022/blob/main/Frontend/app/src/main/java/com/example/asm3/base/broadcastReceiver/NotificationReceiver.java"

    %% Click Events - API Server
    click ExpressServer "https://github.com/edward2362/android-asm3-2022/blob/main/Backend/index.js"
    click DBConfig "https://github.com/edward2362/android-asm3-2022/blob/main/Backend/config/db.js"
    click Constants "https://github.com/edward2362/android-asm3-2022/blob/main/Backend/constants/Constants.js"
    click AuthMiddleware "https://github.com/edward2362/android-asm3-2022/blob/main/Backend/middleware/auth.js"
    click AuthRoute "https://github.com/edward2362/android-asm3-2022/blob/main/Backend/routes/auth.js"
    click BookRoute "https://github.com/edward2362/android-asm3-2022/blob/main/Backend/routes/book.js"
    click CategoryRoute "https://github.com/edward2362/android-asm3-2022/blob/main/Backend/routes/category.js"
    click NotificationRoute "https://github.com/edward2362/android-asm3-2022/blob/main/Backend/routes/notification.js"
    click OrderRoute "https://github.com/edward2362/android-asm3-2022/blob/main/Backend/routes/order.js"
    click ReviewRoute "https://github.com/edward2362/android-asm3-2022/blob/main/Backend/routes/review.js"
    click SubCategoryRoute "https://github.com/edward2362/android-asm3-2022/blob/main/Backend/routes/subCategory.js"
    click AuthController "https://github.com/edward2362/android-asm3-2022/blob/main/Backend/controllers/authController.js"
    click BookController "https://github.com/edward2362/android-asm3-2022/blob/main/Backend/controllers/bookController.js"
    click CategoryController "https://github.com/edward2362/android-asm3-2022/blob/main/Backend/controllers/categoryController.js"
    click NotificationController "https://github.com/edward2362/android-asm3-2022/blob/main/Backend/controllers/notificationController.js"
    click OrderController "https://github.com/edward2362/android-asm3-2022/blob/main/Backend/controllers/orderController.js"
    click ReviewController "https://github.com/edward2362/android-asm3-2022/blob/main/Backend/controllers/reviewController.js"
    click SubCategoryController "https://github.com/edward2362/android-asm3-2022/blob/main/Backend/controllers/subCategoryController.js"
    click BookModel "https://github.com/edward2362/android-asm3-2022/blob/main/Backend/models/Book.js"
    click CategoryModel "https://github.com/edward2362/android-asm3-2022/blob/main/Backend/models/Category.js"
    click CustomerModel "https://github.com/edward2362/android-asm3-2022/blob/main/Backend/models/Customer.js"
    click NotificationModel "https://github.com/edward2362/android-asm3-2022/blob/main/Backend/models/Notification.js"
    click OrderModel "https://github.com/edward2362/android-asm3-2022/blob/main/Backend/models/Order.js"
    click ReviewModel "https://github.com/edward2362/android-asm3-2022/blob/main/Backend/models/Review.js"
    click SubCategoryModel "https://github.com/edward2362/android-asm3-2022/blob/main/Backend/models/SubCategory.js"

    %% Styles
    classDef mobile fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef backend fill:#90EE90,stroke:#000,stroke-width:1px
    classDef database fill:#FFA500,stroke:#000,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#000,stroke-width:1px
```
