# starimper/student_marketplace architecture

> Architecture diagram of the GitHub repository starimper/student_marketplace, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/starimper/student_marketplace
- Repository: https://github.com/starimper/student_marketplace

## Overview

Student Marketplace is a campus buy-and-sell application with a React frontend and Spring Boot backend. Students browse listings, inspect seller information, and purchase items; sellers manage listings and profiles, while users can leave reviews and use an optional authenticated AI assistant. The README documents backend and browser-local demo modes, time-based discounts, photo uploads, and PostgreSQL-backed reviews. Several backend and frontend relationships are documented, but many implementation files were not sampled, so unverified links are omitted or marked dashed.

Main entry points: [`student-marketplace-main/src/App.tsx`](https://github.com/starimper/student_marketplace/blob/main/student-marketplace-main/src/App.tsx) (React application), [`student-marketplace-main/src/api/index.ts`](https://github.com/starimper/student_marketplace/blob/main/student-marketplace-main/src/api/index.ts) (API adapters), [`student-marketplace/src/main/java/com/studentmarketplace/listing/ListingService.java`](https://github.com/starimper/student_marketplace/blob/main/student-marketplace/src/main/java/com/studentmarketplace/listing/ListingService.java) (Listing and pricing), [`student-marketplace/src/main/java/com/studentmarketplace/client/ClientReviewService.java`](https://github.com/starimper/student_marketplace/blob/main/student-marketplace/src/main/java/com/studentmarketplace/client/ClientReviewService.java) (Review statistics)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Student web app"]
  node_web["React application<br/>[App.tsx]"]
  node_login["Sign-in screens<br/>[Login.tsx]"]
  node_catalog["Catalog and listing views<br/>[Catalog.tsx]"]
  node_listingform["Listing editor<br/>[ListingForm.tsx]"]
  node_reviewsui["Reviews and seller ratings<br/>[Reviews.tsx]"]
  node_assistantui["AI assistant<br/>[AiAssistant.tsx]"]
  node_apiadapter["API adapters<br/>[index.ts]"]
  node_mockdata[("Browser demo data<br/>[mockAdapter.ts]")]
end

subgraph group_backend["Marketplace backend"]
  node_listingapi["Listing APIs"]
  node_listingservice["Listing and pricing"]
  node_listingstore[("Listings and discount rules")]
  node_purchase["Purchase transactions"]
  node_photo["Photo handling<br/>[PhotoService.java]"]
  node_reviewsapi["Review and seller APIs"]
  node_reviewsservice["Review statistics"]
  node_users["User profiles<br/>[UserService.java]"]
  node_aiapi["AI chat endpoint"]
  node_aiservice["AI chat service<br/>[AiChatService.java]"]
end

subgraph group_identity["Identity and access"]
  node_authui["Session and route guards<br/>[AuthContext.tsx]"]
  node_authapi["Authentication API"]
  node_authservice["JWT authentication<br/>[AuthService.java]"]
  node_security["Request security"]
end

subgraph group_operations["Platform services"]
  node_database[("PostgreSQL database")]
end

node_students(("Students"))
node_openrouter{{"OpenRouter"}}

node_students -->|"use"| node_web
node_web -->|"routes to"| node_login
node_web -->|"routes to"| node_catalog
node_web -->|"routes to"| node_listingform
node_web -->|"routes to"| node_reviewsui
node_web -->|"routes to"| node_assistantui
node_login -.->|"uses session"| node_authui
node_authui -.->|"requests auth"| node_apiadapter
node_apiadapter -->|"selects demo mode"| node_mockdata
node_apiadapter -.->|"calls API"| node_authapi
node_apiadapter -.->|"calls API"| node_listingapi
node_apiadapter -->|"calls API"| node_reviewsapi
node_apiadapter -->|"calls API"| node_aiapi
node_authapi -.->|"delegates to"| node_authservice
node_authservice -->|"issues JWT"| node_security
node_listingapi -.->|"delegates to"| node_listingservice
node_listingservice -.->|"reads and writes"| node_listingstore
node_purchase -->|"locks listing"| node_listingstore
node_reviewsapi -->|"delegates to"| node_reviewsservice
node_reviewsservice -->|"counts listings"| node_listingstore
node_reviewsservice -->|"stores reviews"| node_database
node_aiservice -->|"sends chat request"| node_openrouter
node_aiapi -.->|"delegates to"| node_aiservice
node_listingservice -.->|"persists listings"| node_database
node_photo -.->|"stores photo metadata"| node_database
node_students -.->|"buy item"| node_purchase
node_listingform -.->|"uploads photos"| node_photo
node_reviewsui -->|"loads feedback"| node_reviewsapi
node_assistantui -->|"sends chat"| node_aiapi

click node_web "https://github.com/starimper/student_marketplace/blob/main/student-marketplace-main/src/App.tsx"
click node_login "https://github.com/starimper/student_marketplace/blob/main/student-marketplace-main/src/pages/Login.tsx"
click node_catalog "https://github.com/starimper/student_marketplace/blob/main/student-marketplace-main/src/pages/Catalog.tsx"
click node_listingform "https://github.com/starimper/student_marketplace/blob/main/student-marketplace-main/src/pages/ListingForm.tsx"
click node_reviewsui "https://github.com/starimper/student_marketplace/blob/main/student-marketplace-main/src/pages/Reviews.tsx"
click node_assistantui "https://github.com/starimper/student_marketplace/blob/main/student-marketplace-main/src/pages/AiAssistant.tsx"
click node_apiadapter "https://github.com/starimper/student_marketplace/blob/main/student-marketplace-main/src/api/index.ts"
click node_mockdata "https://github.com/starimper/student_marketplace/blob/main/student-marketplace-main/src/api/mockAdapter.ts"
click node_authui "https://github.com/starimper/student_marketplace/blob/main/student-marketplace-main/src/auth/AuthContext.tsx"
click node_authapi "https://github.com/starimper/student_marketplace/blob/main/student-marketplace/src/main/java/com/studentmarketplace/auth/AuthController.java"
click node_authservice "https://github.com/starimper/student_marketplace/blob/main/student-marketplace/src/main/java/com/studentmarketplace/auth/AuthService.java"
click node_security "https://github.com/starimper/student_marketplace/blob/main/student-marketplace/src/main/java/com/studentmarketplace/security/SecurityConfig.java"
click node_listingapi "https://github.com/starimper/student_marketplace/blob/main/student-marketplace/src/main/java/com/studentmarketplace/listing/ListingController.java"
click node_listingservice "https://github.com/starimper/student_marketplace/blob/main/student-marketplace/src/main/java/com/studentmarketplace/listing/ListingService.java"
click node_listingstore "https://github.com/starimper/student_marketplace/blob/main/student-marketplace/src/main/java/com/studentmarketplace/listing/ListingRepository.java"
click node_purchase "https://github.com/starimper/student_marketplace/blob/main/student-marketplace/src/main/java/com/studentmarketplace/purchase/PurchaseService.java"
click node_photo "https://github.com/starimper/student_marketplace/blob/main/student-marketplace/src/main/java/com/studentmarketplace/photo/PhotoService.java"
click node_reviewsapi "https://github.com/starimper/student_marketplace/blob/main/student-marketplace/src/main/java/com/studentmarketplace/client/ClientReviewController.java"
click node_reviewsservice "https://github.com/starimper/student_marketplace/blob/main/student-marketplace/src/main/java/com/studentmarketplace/client/ClientReviewService.java"
click node_users "https://github.com/starimper/student_marketplace/blob/main/student-marketplace/src/main/java/com/studentmarketplace/user/UserService.java"
click node_aiapi "https://github.com/starimper/student_marketplace/blob/main/student-marketplace/src/main/java/com/studentmarketplace/ai/AiChatController.java"
click node_aiservice "https://github.com/starimper/student_marketplace/blob/main/student-marketplace/src/main/java/com/studentmarketplace/ai/AiChatService.java"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_web,node_login,node_catalog,node_listingform,node_reviewsui,node_assistantui,node_apiadapter,node_mockdata toneBlue
class node_listingapi,node_listingservice,node_listingstore,node_purchase,node_photo,node_reviewsapi,node_reviewsservice,node_users,node_aiapi,node_aiservice toneAmber
class node_authui,node_authapi,node_authservice,node_security,node_openrouter toneMint
class node_database toneRose
class node_students toneIndigo
```

## Components

### Student web app

- [React application](https://github.com/starimper/student_marketplace/blob/main/student-marketplace-main/src/App.tsx): `student-marketplace-main/src/App.tsx`
- [Sign-in screens](https://github.com/starimper/student_marketplace/blob/main/student-marketplace-main/src/pages/Login.tsx): `student-marketplace-main/src/pages/Login.tsx`
- [Catalog and listing views](https://github.com/starimper/student_marketplace/blob/main/student-marketplace-main/src/pages/Catalog.tsx): `student-marketplace-main/src/pages/Catalog.tsx`
- [Listing editor](https://github.com/starimper/student_marketplace/blob/main/student-marketplace-main/src/pages/ListingForm.tsx): `student-marketplace-main/src/pages/ListingForm.tsx`
- [Reviews and seller ratings](https://github.com/starimper/student_marketplace/blob/main/student-marketplace-main/src/pages/Reviews.tsx): `student-marketplace-main/src/pages/Reviews.tsx`
- [AI assistant](https://github.com/starimper/student_marketplace/blob/main/student-marketplace-main/src/pages/AiAssistant.tsx): `student-marketplace-main/src/pages/AiAssistant.tsx`
- [API adapters](https://github.com/starimper/student_marketplace/blob/main/student-marketplace-main/src/api/index.ts): `student-marketplace-main/src/api/index.ts`
- [Browser demo data](https://github.com/starimper/student_marketplace/blob/main/student-marketplace-main/src/api/mockAdapter.ts): `student-marketplace-main/src/api/mockAdapter.ts`

### Marketplace backend

- [Listing APIs](https://github.com/starimper/student_marketplace/blob/main/student-marketplace/src/main/java/com/studentmarketplace/listing/ListingController.java): `student-marketplace/src/main/java/com/studentmarketplace/listing/ListingController.java`
- [Listing and pricing](https://github.com/starimper/student_marketplace/blob/main/student-marketplace/src/main/java/com/studentmarketplace/listing/ListingService.java): `student-marketplace/src/main/java/com/studentmarketplace/listing/ListingService.java`
- [Listings and discount rules](https://github.com/starimper/student_marketplace/blob/main/student-marketplace/src/main/java/com/studentmarketplace/listing/ListingRepository.java): `student-marketplace/src/main/java/com/studentmarketplace/listing/ListingRepository.java`
- [Purchase transactions](https://github.com/starimper/student_marketplace/blob/main/student-marketplace/src/main/java/com/studentmarketplace/purchase/PurchaseService.java): `student-marketplace/src/main/java/com/studentmarketplace/purchase/PurchaseService.java`
- [Photo handling](https://github.com/starimper/student_marketplace/blob/main/student-marketplace/src/main/java/com/studentmarketplace/photo/PhotoService.java): `student-marketplace/src/main/java/com/studentmarketplace/photo/PhotoService.java`
- [Review and seller APIs](https://github.com/starimper/student_marketplace/blob/main/student-marketplace/src/main/java/com/studentmarketplace/client/ClientReviewController.java): `student-marketplace/src/main/java/com/studentmarketplace/client/ClientReviewController.java`
- [Review statistics](https://github.com/starimper/student_marketplace/blob/main/student-marketplace/src/main/java/com/studentmarketplace/client/ClientReviewService.java): `student-marketplace/src/main/java/com/studentmarketplace/client/ClientReviewService.java`
- [User profiles](https://github.com/starimper/student_marketplace/blob/main/student-marketplace/src/main/java/com/studentmarketplace/user/UserService.java): `student-marketplace/src/main/java/com/studentmarketplace/user/UserService.java`
- [AI chat endpoint](https://github.com/starimper/student_marketplace/blob/main/student-marketplace/src/main/java/com/studentmarketplace/ai/AiChatController.java): `student-marketplace/src/main/java/com/studentmarketplace/ai/AiChatController.java`
- [AI chat service](https://github.com/starimper/student_marketplace/blob/main/student-marketplace/src/main/java/com/studentmarketplace/ai/AiChatService.java): `student-marketplace/src/main/java/com/studentmarketplace/ai/AiChatService.java`

### Identity and access

- [Session and route guards](https://github.com/starimper/student_marketplace/blob/main/student-marketplace-main/src/auth/AuthContext.tsx): `student-marketplace-main/src/auth/AuthContext.tsx`
- [Authentication API](https://github.com/starimper/student_marketplace/blob/main/student-marketplace/src/main/java/com/studentmarketplace/auth/AuthController.java): `student-marketplace/src/main/java/com/studentmarketplace/auth/AuthController.java`
- [JWT authentication](https://github.com/starimper/student_marketplace/blob/main/student-marketplace/src/main/java/com/studentmarketplace/auth/AuthService.java): `student-marketplace/src/main/java/com/studentmarketplace/auth/AuthService.java`
- [Request security](https://github.com/starimper/student_marketplace/blob/main/student-marketplace/src/main/java/com/studentmarketplace/security/SecurityConfig.java): `student-marketplace/src/main/java/com/studentmarketplace/security/SecurityConfig.java`

### Platform services

- **PostgreSQL database**

### Other components

- **Students**
- **OpenRouter**

## Connections

- Students → React application: use (evidence: `student-marketplace-main/src/App.tsx`)
- React application → Sign-in screens: routes to (evidence: `student-marketplace-main/src/App.tsx`)
- React application → Catalog and listing views: routes to (evidence: `student-marketplace-main/src/App.tsx`)
- React application → Listing editor: routes to (evidence: `student-marketplace-main/src/App.tsx`)
- React application → Reviews and seller ratings: routes to (evidence: `student-marketplace-main/src/App.tsx`)
- React application → AI assistant: routes to (evidence: `student-marketplace-main/src/App.tsx`)
- Sign-in screens → Session and route guards: uses session
- Session and route guards → API adapters: requests auth (evidence: `student-marketplace-main/src/auth/AuthContext.tsx`)
- API adapters → Browser demo data: selects demo mode (evidence: `README.md`)
- API adapters → Authentication API: calls API
- API adapters → Listing APIs: calls API
- API adapters → Review and seller APIs: calls API (evidence: `README.md`)
- API adapters → AI chat endpoint: calls API (evidence: `README.md`)
- Authentication API → JWT authentication: delegates to
- JWT authentication → Request security: issues JWT (evidence: `student-marketplace/src/main/java/com/studentmarketplace/auth/AuthService.java`)
- Listing APIs → Listing and pricing: delegates to
- Listing and pricing → Listings and discount rules: reads and writes (evidence: `student-marketplace/src/main/java/com/studentmarketplace/listing/ListingService.java`)
- Purchase transactions → Listings and discount rules: locks listing (evidence: `student-marketplace/src/main/java/com/studentmarketplace/listing/ListingRepository.java`)
- Review and seller APIs → Review statistics: delegates to (evidence: `student-marketplace/src/main/java/com/studentmarketplace/client/ClientReviewController.java`)
- Review statistics → Listings and discount rules: counts listings (evidence: `student-marketplace/src/main/java/com/studentmarketplace/client/ClientReviewService.java`)
- Review statistics → PostgreSQL database: stores reviews (evidence: `README.md`)
- AI chat service → OpenRouter: sends chat request (evidence: `README.md`)
- AI chat endpoint → AI chat service: delegates to
- Listing and pricing → PostgreSQL database: persists listings
- Photo handling → PostgreSQL database: stores photo metadata
- Students → Purchase transactions: buy item
- Listing editor → Photo handling: uploads photos
- Reviews and seller ratings → Review and seller APIs: loads feedback (evidence: `README.md`)
- AI assistant → AI chat endpoint: sends chat (evidence: `README.md`)
