Skip to content

rodrigsmor/tastyhub-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

569 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Tastyhub logo icon

Tastyhub β€” Recipe Sharing Platform

TastyHub is a back-end application developed with a strong focus on Software Architecture best practices, System Design, and Web Security. The project simulates a social platform for recipe sharing and was conceived as a hands-on study project, prioritizing architectural clarity, conscious technical decisions, and sustainable code.

The main goal is not just to deliver features, but to explore real-world trade-offs, document decisions, and build a solid foundation for future evolution.


πŸ“š Table of Contents


🎯 Project Goals

  • Apply SOLID, DRY, KISS, and Clean Architecture principles
  • Implement Design Patterns for robust and standardized solutions
  • Develop a robust REST API using JAVA and Spring Boot
  • Properly model authentication and onboarding flows
  • Explore System Design concepts within a modular monolith

πŸ“ Architecture

  • Architectural Style: Modular Monolith
  • Approach: Clean Architecture (inspired by Hexagonal / Ports & Adapters)
  • Layers:
    • Application: Orchestrates use cases and coordinates domain logic. Handles DTOs and application workflows.
    • Domain: Contains core business rules, entities, value objects, and repository contracts. Framework-independent.
    • Infrastructure: Provides technical implementations such as database persistence, security, messaging, and caching.
    • Interfaces (Delivery Layer): Entry points of the system, such as REST controllers, WebSocket endpoints, and event listeners.

βš™οΈ Technologies

  • Language: Java 17
  • Framework: Spring Boot
  • Persistence: PostgreSQL + JPA (Hibernate)
  • Migrations: Flyway
  • Authentication: JWT (stateless)
  • Cache: Redis (πŸ”œ)
  • Messaging: Kafka (πŸ”œ)
  • Real-time Communication: WebSocket (πŸ”œ)
  • Documentation: Swagger / OpenAPI
  • Testing: JUnit 5, Mockito
  • Infrastructure: Docker

πŸ—„οΈ Database Structure

Database Structure

πŸ—οΈ System Design

[img]

πŸ“¦ Package Structure

com.tastyhub
β”œβ”€β”€ modules                    # Business modules organized by bounded context (modular monolith approach)
β”‚   β”œβ”€β”€ auth
β”‚   β”‚   β”œβ”€β”€ application        # Application layer: orchestrates use cases and coordinates domain logic
β”‚   β”‚   β”‚   β”œβ”€β”€ usecase        # Application use cases (command/query handlers implementing business flows)
β”‚   β”‚   β”‚   β”œβ”€β”€ dto            # Data Transfer Objects used for input/output boundaries
β”‚   β”‚   β”‚   └── mapper         # Mapping logic between Domain models and DTOs
β”‚   β”‚   β”‚   
β”‚   β”‚   β”œβ”€β”€ domain             # Core business logic and domain rules (framework-independent)
β”‚   β”‚   β”‚   β”œβ”€β”€ annotations    # Custom domain-level annotations (e.g., business constraints)
β”‚   β”‚   β”‚   β”œβ”€β”€ event          # Domain events representing significant business occurrences
β”‚   β”‚   β”‚   β”œβ”€β”€ model          # Aggregates, Entities, Value Objects, and Enums
β”‚   β”‚   β”‚   β”œβ”€β”€ repository     # Repository contracts (interfaces) defining persistence operations
β”‚   β”‚   β”‚   β”œβ”€β”€ service        # Domain services containing complex business logic
β”‚   β”‚   β”‚   └── policy         # Business policies and rule objects encapsulating decision logic
β”‚   β”‚   β”‚   
β”‚   β”‚   β”œβ”€β”€ infrastructure     # Technical implementations of external concerns
β”‚   β”‚   β”‚   β”œβ”€β”€ aspect         # Cross-cutting concerns (AOP: logging, auditing, transactions)
β”‚   β”‚   β”‚   β”œβ”€β”€ persistence    # Repository implementations, JPA mappings, database adapters
β”‚   β”‚   β”‚   β”œβ”€β”€ security       # Security configurations and authentication providers
β”‚   β”‚   β”‚   β”œβ”€β”€ messaging      # Kafka/RabbitMQ producers, consumers, and integration adapters
β”‚   β”‚   β”‚   └── cache          # Redis integrations and caching strategies
β”‚   β”‚   β”‚   
β”‚   β”‚   └── interfaces         # Entry points into the application (delivery layer)
β”‚   β”‚       β”œβ”€β”€ controller     # REST controllers exposing HTTP endpoints
β”‚   β”‚       β”œβ”€β”€ websocket      # WebSocket endpoints for real-time communication
β”‚   β”‚       └── listener       # Event listeners (application or messaging-driven)
β”‚   β”‚ 
β”‚   β”œβ”€β”€ user                   
β”‚   β”œβ”€β”€ recipes                              
β”‚   β”œβ”€β”€ articles                              
β”‚   β”‚   ...other modules
β”‚   └── comments
β”‚
└── shared
    β”œβ”€β”€ exception              # Global exception handling and base domain exception classes
    β”œβ”€β”€ dto                    # Shared DTOs used across modules (avoid overusing)
    β”œβ”€β”€ kernel                 # Core abstractions and base classes shared across the system
    └── config                 # Global technical configurations (Spring, security, serialization, etc.)

πŸš€ Running the Project

First, make sure that the Git CLI is properly installed on your machine. If not, follow the official Git documentation (Git - Install) for installation and configuration, or download the project directly as a .zip file from GitHub.


With the Git CLI installed and configured, run the following command in your terminal to clone the repository:

git clone git@github.com:rodrigsmor/tastyhub-api.git

Then, navigate to the newly created directory:

cd tastyhub-api

⚠️ Important note: Configure the environment variables for a proper setup. At the root of the project, create a .env file and add the following variables (example):

SPRING_PROFILES_ACTIVE=     # Active profile (prod or dev)

# Image Viewing
API_UPLOAD_BASE_URL=        # Base Url of Images

# Database Configuration

DB_URL=                     # Database connection URL (e.g., jdbc:postgresql://localhost:5432/tastyhub)
DB_USERNAME=                # Database user credentials
DB_PASSWORD=                # Database password

# Spring Security

SPRING_SECURITY_USERNAME=   # (Optional) Basic Auth username
SPRING_SECURITY_PASSWORD=   # (Optional) Basic Auth password

# Postgres (Docker/Local Setup)

POSTGRES_DB=                # Name of the PostgreSQL database
POSTGRES_USER=              # PostgreSQL administrative user
POSTGRES_PASSWORD=          # PostgreSQL administrative password

# JWT Configuration

JWT_SECRET=                 # Secret key for signing tokens
JWT_EXPIRATION=             # Token expiration time (e.g., in milliseconds)
JWT_SECRET_KEY=             # Additional secret key or encoded string if required
JWT_ISSUER=                 # Registered claim identifying the token provider (e.g., tastyhub-api)

πŸ‘‰ Don’t forget to replace the values according to your context (username, password, database name, etc.).


From this point on, there are three main ways to run the project:

  1. 🐳 Using Docker Compose (highly recommended) to run all containers.
  2. πŸ‹ Using Standalone Docker only for the Spring project.
  3. πŸ”© Hands-on running only the Spring Boot project (via IntelliJ or terminal).

🐳 Using Docker Compose

Docker Compose is the most recommended approach, as it allows you to start all required services (Spring Boot, database, cache, etc.) with a single command.

  1. Make sure Docker and Docker Compose are installed.

  2. From the project root directory, run:

docker-compose up -d
  1. This will start all containers defined in the docker-compose.yml file.

    • The Spring Boot service will be available at http://localhost:8080.
    • The database (e.g., PostgreSQL) will be available on the configured port (e.g., 5432).
  2. To stop the containers:

docker-compose down

πŸ‹ Using Standalone Docker

If you want to run only the Spring Boot container, without auxiliary services, you can use Docker directly.

  1. Make sure Docker is installed.

  2. Build the project JAR:

./gradlew build
  1. Build the Docker image:
# Build the production image
docker build -t tastyhub-api .

# Build the development image
docker build -t tastyhub-api-dev -f Dockerfile.dev .
  1. Run the container:
docker run -p 8080:8080 tastyhub-api
  1. The application will be available at http://localhost:8080.

Documentation UI will be available at http://localhost:8080/swagger-ui/index.html.


πŸ”© Hands On

If you prefer to run only the Spring Boot project, without Docker, you can execute it directly in IntelliJ IDEA or via the terminal.

  1. Using IntelliJ IDEA

    • Open the project in IntelliJ.
    • Locate the main class annotated with @SpringBootApplication.
    • Click Run.
  2. Using the terminal

    • Run:
./gradlew bootRun
  • Or, if you prefer to build the JAR:
./gradlew build
java -jar build/libs/your-project-0.0.1-SNAPSHOT.jar
  1. The application will be available at http://localhost:8080.

πŸ‘¨πŸ½β€πŸ’» Author

Rodrigo Moreira profile picture

Rodrigo Moreira 🌠

πŸŒπŸ‘¨πŸ½β€πŸ’Ό Developed with β™₯️ by Rodrigo Moreira da Silva

Badge Twitter Badge Linkedin


Copyright Β© 2023 – 2026. Rodrigo Moreira da Silva

About

Tastyhub is a recipe sharing web application. It is a REST API developed using Java and Spring Framework, where a login system with authentication and authorization using JWT tokens is implemented.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors