Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
3c3f6c4
setup(routes): Modify to ES6 import syntax. Setup file structure for …
tomwinskell May 30, 2025
a01c0a1
refactor(typescript): Refactored project for TypeScript.
tomwinskell May 30, 2025
a2610bd
feat(tsoa-swagger):
tomwinskell Jun 2, 2025
e4c7ff6
feat(tsoa-swagger): Add additional get route to find a product using Id.
tomwinskell Jun 2, 2025
373fd4d
feat(tsoa-swagger): Add generate service and controller to add reviews.
tomwinskell Jun 2, 2025
597cbd2
feat(tsoa-swagger): Add productId/reviews route to get all reviews fo…
tomwinskell Jun 2, 2025
6184f7c
feat(sort-price): Add ability to sort products by price.
tomwinskell Jun 2, 2025
10a6363
refactor(review-product-routes): Refactor some of the routes to /revi…
tomwinskell Jun 3, 2025
7dd271e
feat(error-handling): Add more comprehensive error handling across se…
tomwinskell Jun 3, 2025
a5dd0dd
feat(build-product): Add faker image url generator.
tomwinskell Jun 3, 2025
524d528
refactor(monorepo): Switch to using yarn workspaces and monorepo for …
tomwinskell Jun 3, 2025
2424bf2
refactor(web-app): Update to TailwindCSS, add necessary config files.
tomwinskell Jun 3, 2025
632d165
feat(fetch-products): Add .ts files to build query URL and fetch prod…
tomwinskell Jun 3, 2025
a70da4f
refactor(remove-redux-examples): Remove counter and quotes examples f…
tomwinskell Jun 3, 2025
70c16bb
feat(frontend-ui): Confirm products fetching, add Flowbite React and …
tomwinskell Jun 3, 2025
94404e2
feat(pagination): Add pagination.
tomwinskell Jun 3, 2025
ab1c9f4
feat(price-sort): Add ability to sort by lowest or highest price. Add…
tomwinskell Jun 3, 2025
6cf8591
feat(search-bar): Add search bar and dark / light mode.
tomwinskell Jun 4, 2025
7b54e63
feat(category-dropdown): Add category dropdown for products.
tomwinskell Jun 4, 2025
000b66a
feat(search): Add ability to search products using debounce function.
tomwinskell Jun 4, 2025
3f58277
refactor(ui): Some refactoring of classNames to ensure UI renders cor…
tomwinskell Jun 4, 2025
0153c28
refactor(absolute-imports): Refactor relative to absolute imports.
tomwinskell Jun 4, 2025
923e7a6
refactor: Remove old test files from example app.
tomwinskell Jun 4, 2025
81c29b6
feat(readme-files): Add readme files for each app and overall readme …
tomwinskell Jun 4, 2025
1076c11
feat(category-dropdown): Add additional categories.
tomwinskell Jun 4, 2025
a1ba1f3
feat(docker): Add docker container for web app. Refactor api to inclu…
tomwinskell Jun 5, 2025
895d397
feat(docker): Add docker compose with mongodb.
tomwinskell Jun 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Node
node_modules
npm-debug.log
yarn-debug.log
yarn-error.log
.pnpm-store
dist
build
.cache

# Env
.env
.env.*

# OS
.DS_Store
Thumbs.db

# Git
.git
.gitignore

# Editor/IDE
.vscode
.idea

# Docker
Dockerfile*
.dockerignore

# Test & coverage
coverage
*.test.*
*.spec.*
jest.config.*
cypress/
playwright/

# Monorepo tooling
turbo
*.tsbuildinfo
30 changes: 30 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules/
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

.yalc/
yalc.lock

# Environment variables
.env
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
66 changes: 63 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,66 @@
## Product List
# Product List Monorepo

A full-stack product management application with a React frontend and Express.js API backend.

This project has been created by a student at Parsity, an online software engineering course. The work in this repository is wholly of the student based on a sample starter project that can be accessed by looking at the repository that this project forks.
## Structure

If you have any questions about this project or the program in general, visit [parsity.io](https://parsity.io/) or email hello@parsity.io.
```
apps/
├── web/ # React + Redux Toolkit frontend
├── api/ # Express.js + MongoDB backend
```

## Quick Start

### Prerequisites

- [Docker Desktop](https://docs.docker.com/get-started/get-docker/)

### Docker Setup

```bash
# Build and start all services
yarn docker:build

# Generate seed data (run after build)
curl http://localhost:3000/generate
```

**Access points:**
- Web app: http://localhost:8080
- API docs: http://localhost:3000/docs

### Development

```bash
# Individual services
yarn docker:web:build && yarn docker:web # Web only
yarn docker:api:build && yarn docker:api # API only

# Local development (requires MongoDB)
yarn dev
```

## Tech Stack

**Frontend (web):**

- React 19 + Redux Toolkit
- Vite + TypeScript
- Tailwind CSS + Flowbite React

**Backend (api):**

- Express.js + TypeScript
- MongoDB + Mongoose
- TSOA (auto-generated routes/docs)

## Features

- Product browsing with search, filtering, and pagination
- Product reviews and ratings
- Dark/light mode toggle
- Responsive design
- Auto-generated API documentation

For detailed setup and development information, see the README files in each app directory.
2 changes: 2 additions & 0 deletions apps/api/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Uncomment if running API in docker but mongodb locally on macOS/Windows
# MONGODB=mongodb://host.docker.internal:27017/products
28 changes: 28 additions & 0 deletions apps/api/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Build stage
FROM node:18-alpine AS build

WORKDIR /app

# Copy workspace root files (relative to build context)
# Copy API workspace package.json
COPY package.json yarn.lock ./
COPY apps/api/package.json ./apps/api/

# Install only the API workspace (and its deps)
RUN yarn install

# Copy all files
COPY apps/api ./apps/api

# Build the specific workspace
RUN yarn workspace api build

# Production stage
FROM node:18-alpine
WORKDIR /app
# Copy built application
COPY --from=build /app/apps/api/build ./build
# Copy node_modules
COPY --from=build /app/node_modules ./node_modules
EXPOSE 3000
CMD ["node", "build/src/server.js"]
128 changes: 128 additions & 0 deletions apps/api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# Product List API

A RESTful API for managing products and reviews, built with Express.js, TypeScript, and MongoDB. This API provides endpoints for product management, review system, and data generation using TSOA for automatic route generation and OpenAPI documentation.

## Features

- **Product Management**: CRUD operations for products
- **Review System**: Create and manage product reviews
- **Data Generation**: Generate sample products and reviews using Faker.js
- **Auto-generated Documentation**: Swagger/OpenAPI documentation
- **Type Safety**: Full TypeScript implementation with Zod validation
- **CORS Support**: Cross-origin resource sharing enabled

## Tech Stack

- **Node.js** - Runtime environment
- **Express.js** - Web framework
- **TypeScript** - Type safety
- **MongoDB** - Database with Mongoose ODM
- **TSOA** - Auto-generated routes and OpenAPI specs
- **Faker.js** - Sample data generation
- **Swagger UI** - API documentation interface

## Getting Started

### Prerequisites

- Node.js (v18 or higher)
- MongoDB (running locally or connection string)
- npm or yarn

### Installation

```bash
# Install dependencies
npm install

# Start development server with auto-reload
npm run dev

# Build for production
npm run build

# Start production server
npm start
```

### Database Setup

Ensure MongoDB is running locally on the default port (27017).

## API Documentation

Interactive API documentation is available at:
```
http://localhost:3000/docs
```

## API Endpoints

### Products

| Method | Endpoint | Description | Query Parameters |
|--------|----------|-------------|------------------|
| GET | `/products` | Get all products | `page`, `limit`, `category`, `price`, `query` |
| GET | `/products/{id}` | Get product by ID | - |
| POST | `/products` | Create new product | - |
| DELETE | `/products/{id}` | Delete product | - |

**Product Query Parameters:**
- `page` - Page number for pagination
- `limit` - Number of items per page
- `category` - Filter by product category
- `price` - Sort by price (`highest` or `lowest`)
- `query` - Search products by name

**Product Schema:**
```json
{
"name": "string",
"category": "string",
"price": "number",
"image": "string (URL)"
}
```

### Reviews

| Method | Endpoint | Description | Query Parameters |
|--------|----------|-------------|------------------|
| GET | `/reviews/{productId}` | Get reviews for product | `page`, `limit` |
| POST | `/reviews` | Create new review | - |
| DELETE | `/reviews/{id}` | Delete review | - |

**Review Schema:**
```json
{
"text": "string",
"rating": "number (1-5)",
"productId": "string"
}
```

### Data Generation

| Method | Endpoint | Description |
|--------|----------|-------------|
| GET | `/generate` | Generate sample products and reviews |

### Project Structure

```
src/
├── errors/ # Error handling and types
├── generate/ # Data generation endpoints
├── products/ # Product-related endpoints
│ ├── productModel.ts
│ ├── productsController.ts
│ ├── productsService.ts
│ └── productTypes.ts
├── reviews/ # Review-related endpoints
│ ├── reviewModel.ts
│ ├── reviewsController.ts
│ ├── reviewsService.ts
│ └── reviewTypes.ts
├── app.ts # Express app configuration
└── server.ts # Server entry point
```
Loading