# craniacshencil/campusswap architecture

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

- Interactive diagram: https://gitdiagram.com/craniacshencil/campusswap
- Repository: https://github.com/craniacshencil/campusswap

## Overview

##### Main Components

Frontend Layer:
- Vue.js Single Page Application (SPA)
- Vuex Store (state management)
- Custom Components
- Pages/Views
- Asset Management

Backend Layer:
- Django REST Framework
- Authentication System
- Multiple Django Apps:
- admin_actions
- apis
- products
- payments
- PostgreSQL Database
- Third-party Services:
- ImgBB API (image hosting)
- Razorpay API (payments)

**Client Layer**

**Frontend Layer**

**API Gateway**

**Backend Services**

**Database Layer**

**External Services**

##### Component Relationships

- Client browsers connect to Vue.js frontend
- Frontend communicates with Django backend through REST APIs
- Backend services interact with PostgreSQL database
- Payment service connects to Razorpay
- Image handling connects to ImgBB
- Admin actions flow through dedicated admin routes

##### Specific Component Details

Frontend (Vue.js):
- Main pages (Home, Buy, Sell, Resources, Admin Dashboard)
- Vuex store for state management
- Custom components structure

Backend (Django):
- Four main Django apps and their responsibilities:
- admin_actions: Administrative operations
- apis: Student/User management
- products: Listing management
- payments: Payment processing

Database:
- Main tables: Users, Products, Resources, Payments
- Relationships between tables

##### Additional Elements

Security Layer:
- Authentication flow
- Admin approval process
- User registration validation

Data Flow:
- Product listing flow
- Payment processing flow
- Resource management flow

##### Important Notes

- Environment configuration (.env)
- Development vs production setup
- Separation between frontend dev server (Vite) and Django server
- Points of integration with third-party services

##### Recommendations

- Maintain consistent styling
- Version information
- Notes for scaling considerations
- Document authentication flow separately

Remember to include both development and production configurations, as they differ in terms of server setup and build processes.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Browser["Web Browser"]
    end

    subgraph "Frontend Application"
        VueApp["Vue.js SPA"]:::frontend
        click VueApp "https://github.com/craniacshencil/campusSWAP/blob/master/frontend/src/App.vue"
        
        subgraph "State Management"
            Store["Vuex Store"]:::frontend
            UserModule["User Module"]:::frontend
            click Store "https://github.com/craniacshencil/campusSWAP/blob/master/frontend/src/store/index.js"
            click UserModule "https://github.com/craniacshencil/campusSWAP/blob/master/frontend/src/store/modules/userModule.js"
        end

        subgraph "Components"
            CustomComps["Custom Components"]:::frontend
            click CustomComps "https://github.com/craniacshencil/campusSWAP/tree/master/frontend/src/custom_comps/"
        end

        subgraph "Views"
            Pages["Pages"]:::frontend
            Auth["Authentication Views"]:::frontend
            ProductViews["Product Views"]:::frontend
            AdminView["Admin Dashboard"]:::frontend
            ResourceViews["Resource Views"]:::frontend
            click Pages "https://github.com/craniacshencil/campusSWAP/tree/master/frontend/src/pages/"
            click Auth "https://github.com/craniacshencil/campusSWAP/blob/master/frontend/src/pages/Login.vue"
            click ProductViews "https://github.com/craniacshencil/campusSWAP/blob/master/frontend/src/pages/Buy.vue"
            click AdminView "https://github.com/craniacshencil/campusSWAP/blob/master/frontend/src/pages/AdminDash.vue"
            click ResourceViews "https://github.com/craniacshencil/campusSWAP/blob/master/frontend/src/pages/Resources.vue"
        end

        DevConfig["Development Config"]:::config
        click DevConfig "https://github.com/craniacshencil/campusSWAP/blob/master/frontend/vite.config.js"
    end

    subgraph "Backend Services"
        DjangoConfig["Django Configuration"]:::backend
        URLRouter["URL Router"]:::backend
        click DjangoConfig "https://github.com/craniacshencil/campusSWAP/blob/master/campusSwap/settings.py"
        click URLRouter "https://github.com/craniacshencil/campusSWAP/blob/master/campusSwap/urls.py"

        subgraph "Core Services"
            AdminActions["Admin Actions"]:::backend
            UserAPI["User/Student API"]:::backend
            ProductsService["Products Management"]:::backend
            PaymentService["Payment Processing"]:::backend
            click AdminActions "https://github.com/craniacshencil/campusSWAP/tree/master/admin_actions/"
            click UserAPI "https://github.com/craniacshencil/campusSWAP/tree/master/apis/"
            click ProductsService "https://github.com/craniacshencil/campusSWAP/tree/master/products/"
            click PaymentService "https://github.com/craniacshencil/campusSWAP/tree/master/payments/"
        end
    end

    subgraph "Data Layer"
        PostgreSQL[("PostgreSQL DB")]:::database
    end

    subgraph "External Services"
        ImgBB["ImgBB API"]:::external
        Razorpay["Razorpay API"]:::external
    end

    %% Connections
    Browser --> VueApp
    VueApp --> Store
    Store --> UserModule
    VueApp --> CustomComps
    VueApp --> Pages
    Pages --> Auth
    Pages --> ProductViews
    Pages --> AdminView
    Pages --> ResourceViews
    VueApp --> DjangoConfig
    DjangoConfig --> URLRouter
    URLRouter --> AdminActions
    URLRouter --> UserAPI
    URLRouter --> ProductsService
    URLRouter --> PaymentService
    AdminActions --> PostgreSQL
    UserAPI --> PostgreSQL
    ProductsService --> PostgreSQL
    PaymentService --> PostgreSQL
    ProductsService --> ImgBB
    PaymentService --> Razorpay

    %% Styles
    classDef frontend fill:#3498db,color:#fff
    classDef backend fill:#2ecc71,color:#fff
    classDef database fill:#f1c40f,color:#000
    classDef external fill:#9b59b6,color:#fff
    classDef config fill:#e74c3c,color:#fff

    %% Legend
    subgraph Legend
        Frontend["Frontend Component"]:::frontend
        Backend["Backend Service"]:::backend
        DB["Database"]:::database
        External["External Service"]:::external
        Config["Configuration"]:::config
    end
```
