Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

51 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Velumi

A Full Stack product and user management platform.

Velumi is a Full Stack web application designed to manage a product catalog through a modern user interface and a REST API. It includes JWT-based authentication, role-based access control, and an administration dashboard for managing users, products, and platform statistics.

The project is built using React and TypeScript on the frontend, Spring Boot on the backend, and MySQL as its database management system.


Table of Contents


Features

Product Catalog

  • Browse the product catalog.
  • Search products by name.
  • Filter products by category.
  • View product information and prices.
  • Manage product images.

Authentication and User Management

  • User registration.
  • User login.
  • JWT-based authentication.
  • Password hashing using BCrypt.
  • Token-based session management.
  • Role-based access control.

Administration Dashboard

The administration dashboard provides the following functionality:

  • View registered users.
  • Display user roles.
  • Filter users by name.
  • Browse the complete product catalog.
  • View general platform statistics.
  • Display the total number of users, products, and categories.

Administrative features are restricted to users with the ROLE_ADMIN role.


Technologies

Frontend

Technology Purpose
React 19 User interface development
TypeScript Static typing
Vite 8 Development server and build tool
Tailwind CSS 4 Styling and responsive design
Motion Animations
Lucide React Icons
JWT Decode JWT token decoding

Backend

Technology Purpose
Java 21 Programming language
Spring Boot 4.1 Backend framework
Spring Web REST API development
Spring Security Authentication and authorization
Spring Data JPA Data persistence
Hibernate Object-relational mapping
MySQL Relational database
JWT Token-based authentication
BCrypt Password hashing
Maven Dependency and build management
Lombok Boilerplate code reduction

Project Architecture

The project is divided into two independent modules: frontend and backend.

fullstack-lab/
│
├── backend/
│   ├── src/
│   │   ├── main/
│   │   │   ├── java/org/dam/velumi/
│   │   │   │   ├── config/
│   │   │   │   ├── controller/
│   │   │   │   ├── manager/
│   │   │   │   ├── model/
│   │   │   │   ├── repository/
│   │   │   │   ├── service/
│   │   │   │   └── VelumiApplication.java
│   │   │   │
│   │   │   └── resources/
│   │   │       └── application.properties
│   │   │
│   │   └── test/
│   │
│   ├── uploads/
│   │   └── productos/
│   │
│   ├── pom.xml
│   ├── mvnw
│   └── mvnw.cmd
│
├── frontend/
│   ├── public/
│   ├── src/
│   │   ├── assets/
│   │   ├── components/
│   │   │   ├── admin/
│   │   │   └── ui/
│   │   ├── services/
│   │   ├── types/
│   │   ├── App.tsx
│   │   └── main.tsx
│   │
│   ├── package.json
│   ├── vite.config.ts
│   └── tsconfig.json
│
└── README.md

Backend Structure

  • config: Security, JWT, and CORS configuration.
  • controller: REST API endpoint definitions.
  • manager: Authentication-related components.
  • model: Database entities.
  • repository: Data access and database operations.
  • service: Business logic.
  • uploads: Product image storage.

Frontend Structure

  • components: Reusable UI components.
  • components/admin: Administration dashboard components.
  • components/ui: Shared visual components.
  • services: API communication and authentication management.
  • types: TypeScript interfaces and type definitions.
  • assets: Static assets and graphical resources.

Prerequisites

Make sure the following tools are installed before running the project:

  • Java JDK 21 or later.
  • Node.js compatible with Vite 8.
  • npm.
  • MySQL.
  • Git.

Recommended development environments:

  • IntelliJ IDEA for the backend.
  • Visual Studio Code for the frontend.

Installation and Setup

1. Clone the Repository

git clone https://github.com/Mahu2121/fullstack-lab.git

cd fullstack-lab

2. Configure the Database

Create a MySQL database:

CREATE DATABASE velumi;

The application uses Spring Data JPA and Hibernate to manage entities and update the database schema.

3. Configure the Backend

Navigate to the backend directory:

cd backend

Create a .env file in the backend directory:

DATASOURCE_URL=jdbc:mysql://localhost:3306/velumi
DATASOURCE_USERNAME=root
DATASOURCE_PASSWORD=your_password
JWT_SECRET=your_secret_key_at_least_32_characters_long

Replace the values with your local database credentials and a secure JWT secret.

4. Configure the Frontend

From the project root, navigate to the frontend directory:

cd frontend

Install the dependencies:

npm install

Environment Variables

The backend requires the following configuration values:

Variable Description
DATASOURCE_URL MySQL database connection URL
DATASOURCE_USERNAME Database username
DATASOURCE_PASSWORD Database password
JWT_SECRET Secret key used to sign JWT tokens

Make sure to configure these values before starting the backend.


Running the Project

The frontend and backend must be started separately using two terminal windows.

Backend

Navigate to the backend directory.

On Linux or macOS:

./mvnw spring-boot:run

On Windows:

mvnw.cmd spring-boot:run

The backend will be available at:

http://localhost:8080

Frontend

Navigate to the frontend directory:

npm run dev

The frontend will be available at:

http://localhost:5173

REST API

The application exposes the following REST endpoints.

Authentication

Base URL: /api/auth

Method Endpoint Description
POST /register Register a new user
POST /login Authenticate a user

Example login request:

{
  "username": "username",
  "password": "password"
}

The response contains a JWT token:

{
  "token": "jwt_token"
}

Products

Base URL: /api/productos

Method Endpoint Description Access
GET / Retrieve all products Public
POST / Create a product Authenticated
GET /{id}/imagen Retrieve a product image Public

Administration

Base URL: /api/admin/usuarios

Method Endpoint Description Access
GET / Retrieve registered users Administrator

Administrative endpoints require a valid JWT token with the ROLE_ADMIN role.


Authentication and Security

Velumi implements an authentication system using Spring Security and JSON Web Tokens.

The authentication workflow is as follows:

  1. The user submits their login credentials.
  2. The backend validates the credentials.
  3. If authentication succeeds, the backend generates a JWT signed using HS256.
  4. The frontend stores the token in localStorage.
  5. Protected requests include the token in the Authorization header.
  6. Spring Security validates the token and checks the user's permissions.

Example authorization header:

Authorization: Bearer <token>

User Roles

The application defines two user roles:

Role Description
ROLE_USER Standard user
ROLE_ADMIN Administrator

Newly registered users are automatically assigned the ROLE_USER role.

Administrator privileges must be assigned through user data management.


Data Model

User

The Usuario entity represents registered users.

Field Type Description
id Long Unique identifier
username String Username
password String Hashed password
rol String User role

Product

The Product entity represents the products available in the catalog.

Field Type Description
id Long Unique identifier
nombre String Product name
precio double Product price
descripcion String Product description
stock int Available stock
imagenUrl String Image URL
categoria String Product category
fechaCreacion Date Creation date
activo Boolean Product status
imagenNombre String Image filename

Available Scripts

Frontend

Run these commands from the frontend directory:

Command Description
npm run dev Start the development server
npm run build Build the application for production
npm run lint Run ESLint
npm run preview Preview the production build

Backend

Run these commands from the backend directory.

Execute tests:

./mvnw test

Build the application:

./mvnw clean package

Additional Configuration

  • The frontend uses http://localhost:8080 as its API base URL.
  • The backend allows CORS requests from http://localhost:5173.
  • JWT tokens have a one-hour expiration time.
  • Hibernate uses the update strategy to synchronize the database schema.
  • Product images are stored in backend/uploads/productos/.

For production deployment, database credentials, API URLs, CORS settings, and security secrets should be adapted to the target environment.


Author

Mahu2121


Built with React, TypeScript, Spring Boot, and MySQL.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages