Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Stage 1: Build the application
FROM maven:3.9.6-eclipse-temurin-17 AS build
WORKDIR /app
# Copy only the pom.xml first to leverage Docker cache for dependencies
COPY pom.xml .
RUN mvn dependency:go-offline -B
# Copy source code and build
COPY src ./src
RUN mvn clean package -DskipTests

# Stage 2: Run the application
FROM eclipse-temurin:17-jre-jammy
WORKDIR /app
COPY --from=build /app/target/*.jar app.jar
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "app.jar"]
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,40 @@
# Ramsai Kitchen

Digital restaurant management system built with Spring Boot and PostgreSQL.

## Quick Start Tutorial

### Prerequisites
- Docker and Docker Compose installed on your machine.

### First-Time Running the Project
1. **Clone the repository**:
```bash
git clone <repository-url>
cd RamsAI-Kitchen
```

2. **Start the application**:
Use Docker Compose to build and start both the database and the application:
```bash
docker compose up --build
```
The application will be available at [http://localhost:8080](http://localhost:8080).

### Development with Docker Compose Watch
For a faster development loop, this project supports `docker compose watch`. This allows you to see your changes in real-time without manually rebuilding the containers.

1. **Run in watch mode**:
```bash
docker compose watch
```

2. **What happens during watch?**:
- **Static Files**: Any changes in `src/main/resources/static` will be automatically synced to the running container.
- **Java Code & Dependencies**: Any changes in `src/` or `pom.xml` will trigger an automatic rebuild and restart of the application container, ensuring your backend changes are reflected immediately.

---

## User Stories & Acceptance Criteria

### 1. Menu Access
Expand Down
33 changes: 32 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,35 @@ services:
ports:
- "5432:5432"
volumes:
- ./src/main/resources/sql/schema.sql:/docker-entrypoint-initdb.d/schema.sql
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ramsai -d ramsai_kitchen"]
interval: 5s
timeout: 5s
retries: 5

app:
build: .
container_name: ramsai-kitchen-app
ports:
- "8080:8080"
environment:
- SPRING_DATASOURCE_URL=jdbc:postgresql://db:5432/ramsai_kitchen
- SPRING_DATASOURCE_USERNAME=ramsai
- SPRING_DATASOURCE_PASSWORD=kitchen_password
- SPRING_JPA_HIBERNATE_DDL_AUTO=validate
depends_on:
db:
condition: service_healthy
develop:
watch:
- path: ./src/main/resources/static
action: sync
target: /app/resources/static
- path: ./pom.xml
action: rebuild
- path: ./src
action: rebuild

volumes:
postgres_data:
13 changes: 12 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<java.version>17</java.version>
<org.mapstruct.version>1.5.5.Final</org.mapstruct.version>
<lombok-mapstruct-binding.version>0.2.0</lombok-mapstruct-binding.version>
<lombok.version>1.18.32</lombok.version>
</properties>
<dependencies>
<dependency>
Expand Down Expand Up @@ -52,6 +53,7 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<optional>true</optional>
</dependency>
<dependency>
Expand All @@ -60,6 +62,12 @@
<version>${org.mapstruct.version}</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand All @@ -77,10 +85,13 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<version>3.13.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<compilerArgs>
<arg>-parameters</arg>
</compilerArgs>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
Expand Down
30 changes: 30 additions & 0 deletions src/main/java/com/ramsai/kitchen/config/SecurityConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.ramsai.kitchen.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
import org.springframework.security.web.SecurityFilterChain;

@Configuration
@EnableWebSecurity
public class SecurityConfig {

@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http
.csrf(AbstractHttpConfigurer::disable)
.authorizeHttpRequests(auth -> auth
.requestMatchers("/", "/index.html", "/error", "/static/**", "/css/**", "/js/**", "/images/**").permitAll()
.anyRequest().permitAll()
)
.formLogin(login -> login
.defaultSuccessUrl("/", true)
.permitAll()
)
.logout(logout -> logout.permitAll());

return http.build();
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/ramsai/kitchen/enums/ItemStatus.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.ramsai.kitchen.enums;

public enum ItemStatus {
PENDING, PREPARING, READY, SERVED
PENDING, COOKING, READY, SERVED, CANCELLED
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.ramsai.kitchen.exceptions;

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;

@ResponseStatus(HttpStatus.BAD_REQUEST)
public class InsufficientStockException extends RuntimeException {
public InsufficientStockException(String message) {
super(message);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.ramsai.kitchen.models.dtos;

import com.ramsai.kitchen.enums.ItemStatus;
import java.math.BigDecimal;

public record OrderItemResponse(
Long id,
Long orderId,
Long productId,
String productName,
Integer quantity,
BigDecimal unitPrice,
String specialNotes,
ItemStatus itemStatus
) {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.ramsai.kitchen.models.dtos;

public record ProductPopularityResponse(
Long id,
String name,
Long totalQuantitySold,
String categoryName
) {}
13 changes: 13 additions & 0 deletions src/main/java/com/ramsai/kitchen/models/dtos/TableResponse.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.ramsai.kitchen.models.dtos;

import com.ramsai.kitchen.enums.TableStatus;
import java.time.LocalDateTime;

public record TableResponse(
Long id,
Integer tableNumber,
TableStatus status,
Integer xPos,
Integer yPos,
LocalDateTime lastOrderTime
) {}
40 changes: 40 additions & 0 deletions src/main/resources/static/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Ramsai Kitchen</title>
<style>
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background-color: #f4f7f6;
color: #333;
}
.container {
text-align: center;
padding: 2rem;
background: white;
border-radius: 8px;
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
h1 {
color: #2c3e50;
}
p {
color: #7f8c8d;
}
</style>
</head>
<body>
<div class="container">
<h1>Welcome to Ramsai Kitchen</h1>
<p>Hello World! Your Spring Boot application is running in Docker.
MODIFICARE MODIFICARE</p>
</div>
</body>
</html>
Loading