# zebangeth/campuscycle architecture

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

- Interactive diagram: https://gitdiagram.com/zebangeth/campuscycle
- Repository: https://github.com/zebangeth/campuscycle

## Overview

##### Main Components

A. Frontend Layer (Vue.js Application):
- Home/Search Interface
- Product Management (Add/Edit Listings)
- User Profile Management
- Authentication Views
- TypeScript integration and Vite build system

B. Backend Layer (Node.js/Express):
- Main API groups based on the routes:
- User Management (/userRoutes)
- Listing Management (/listingRoutes)
- Category Management (/categoryRoutes)
- Admin Operations (/adminRoutes)
- Search Functionality (/searchRoutes)
- Wishlist Management (/wishlistRoutes)
- Middleware layer showing:
- Authentication Middleware
- Admin Authentication
- Request Processing

C. Database Layer:
- MongoDB instance with main collections based on models:
- Users
- Listings
- Categories
- Admins
- Wishlists

D. External Services:
- GitLab OIDC Authentication Service
- Image Storage Service (implied by the structure)

##### Architecture Pattern Representation

A clear three-tier architecture:
**[Client Tier (Vue.js)] ←→ [Application Tier (Express)] ←→ [Data Tier (MongoDB)]**

##### Infrastructure Components

Containers and orchestration:
- Docker containers (show frontend and backend containers)
- Kubernetes cluster components:
- Frontend deployment/service
- Backend deployment/service
- MongoDB deployment/service

##### Specific Design Elements

- Rectangles: Main components (Frontend, Backend, Database)
- Hexagons: External services
- Rounded rectangles: API endpoints groupings

- Blue: Frontend components
- Green: Backend services
- Yellow: Database components
- Gray: External services
- Red: Security/Authentication components

##### Key Flows to Highlight

A. Authentication Flow:
**User → Frontend → GitLab OIDC → Backend → Database**

B. Listing Management Flow:
**User → Frontend → Backend (Auth Middleware) → Database**

C. Search Flow:
**User → Frontend → Backend (Search Routes) → Database → Results**

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef database fill:#f1c40f,stroke:#f39c12,color:black
    classDef external fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef security fill:#e74c3c,stroke:#c0392b,color:white

    %% Infrastructure Layer
    subgraph Kubernetes
        FD[Frontend Deployment]
        BD[Backend Deployment]
        MD[MongoDB Deployment]
        FS[Frontend Service]
        BS[Backend Service]
        MS[MongoDB Service]
    end

    %% Frontend Layer
    subgraph Frontend
        Home["Home/Search Interface"]
        ProdMgmt["Product Management"]
        UserProfile["User Profile"]
        Auth["Authentication Views"]
        ProdDetails["Product Details"]
    end

    %% Backend Layer
    subgraph Backend
        AuthMW["Authentication Middleware"]
        AdminMW["Admin Authentication"]

        subgraph Routes
            UserRoutes["User Routes"]
            ListingRoutes["Listing Routes"]
            CategoryRoutes["Category Routes"]
            AdminRoutes["Admin Routes"]
            SearchRoutes["Search Routes"]
            WishlistRoutes["Wishlist Routes"]
        end
    end

    %% Database Layer
    subgraph Database
        Users[(Users)]
        Listings[(Listings)]
        Categories[(Categories)]
        Admins[(Admins)]
        Wishlists[(Wishlists)]
    end

    %% External Services
    GitLab{"GitLab OIDC"}
    ImageStorage{"Image Storage"}

    %% Relationships
    Frontend --> AuthMW
    AuthMW --> Routes
    Routes --> Database
    Frontend --> GitLab
    GitLab --> Backend
    Frontend --> ImageStorage

    %% Component Styling
    class Home,ProdMgmt,UserProfile,Auth,ProdDetails frontend
    class AuthMW,AdminMW,UserRoutes,ListingRoutes,CategoryRoutes,AdminRoutes,SearchRoutes,WishlistRoutes backend
    class Users,Listings,Categories,Admins,Wishlists database
    class GitLab,ImageStorage external

    %% Click Events
    click Home "https://github.com/zebangeth/CampusCycle/blob/main/frontend/src/views/Home.vue"
    click ProdMgmt "https://github.com/zebangeth/CampusCycle/blob/main/frontend/src/views/AddListing.vue"
    click UserProfile "https://github.com/zebangeth/CampusCycle/blob/main/frontend/src/views/Profile.vue"
    click ProdDetails "https://github.com/zebangeth/CampusCycle/blob/main/frontend/src/views/ProductDetail.vue"
    click UserRoutes "https://github.com/zebangeth/CampusCycle/blob/main/backend/src/routes/userRoutes.ts"
    click ListingRoutes "https://github.com/zebangeth/CampusCycle/blob/main/backend/src/routes/listingRoutes.ts"
    click CategoryRoutes "https://github.com/zebangeth/CampusCycle/blob/main/backend/src/routes/categoryRoutes.ts"
    click AdminRoutes "https://github.com/zebangeth/CampusCycle/blob/main/backend/src/routes/adminRoutes.ts"
    click SearchRoutes "https://github.com/zebangeth/CampusCycle/blob/main/backend/src/routes/searchRoutes.ts"
    click WishlistRoutes "https://github.com/zebangeth/CampusCycle/blob/main/backend/src/routes/wishlistRoutes.ts"
    click Users "https://github.com/zebangeth/CampusCycle/blob/main/backend/src/models/User.ts"
    click Listings "https://github.com/zebangeth/CampusCycle/blob/main/backend/src/models/Listing.ts"
    click Categories "https://github.com/zebangeth/CampusCycle/blob/main/backend/src/models/Category.ts"
    click Admins "https://github.com/zebangeth/CampusCycle/blob/main/backend/src/models/Admin.ts"
    click Wishlists "https://github.com/zebangeth/CampusCycle/blob/main/backend/src/models/Wishlist.ts"
    click AuthMW "https://github.com/zebangeth/CampusCycle/blob/main/backend/src/middleware/authMiddleware.ts"
    click AdminMW "https://github.com/zebangeth/CampusCycle/blob/main/backend/src/middleware/adminAuthMiddleware.ts"
    click FD "https://github.com/zebangeth/CampusCycle/blob/main/k8s/frontend-deployment.yaml"
    click BD "https://github.com/zebangeth/CampusCycle/blob/main/k8s/backend-deployment.yaml"
    click MD "https://github.com/zebangeth/CampusCycle/blob/main/k8s/mongo-deployment.yaml"
    click FS "https://github.com/zebangeth/CampusCycle/blob/main/k8s/frontend-service.yaml"
    click BS "https://github.com/zebangeth/CampusCycle/blob/main/k8s/backend-service.yaml"
    click MS "https://github.com/zebangeth/CampusCycle/blob/main/k8s/mongo-service.yaml"
```
