Skip to content

aacolyte/mita-rest-service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

71 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mita

📚 Mita

Full-stack Library Management System with role-based access control and JWT authentication. Built with Spring Boot and React.

📖 Table of Contents

Please note: This repository contains only the back-end part of the application.

🚀 About The Project

Mita is a full-stack web application for managing a digital library. The system supports authentication, authorization, and various operations for users, categories, and items.

It follows a stateless architecture using JWT with automatic token refresh on the frontend.

✨ Features

👤 User

  • Registration & Login

  • Full CRUD for categories

  • Full CRUD for items

  • Quick item search and filtering

  • Various item sorting options

  • Edit profile

👑 Admin

  • Access to admin dashboard

  • Manage all users

  • Role-based access control (ADMIN / USER)

🛠 Tech Stack

Backend

  • Java 21

  • Spring Boot

  • Spring Data

  • Spring Security

  • JWT

  • REST API

  • PostgreSQL

Frontend

  • React

  • Fetch API

  • Automatic token refresh

  • Protected routes

  • SPA architecture

🔐 Security

  • Stateless authentication using JWT

  • Access token + Refresh token mechanism

  • Automatic access token refresh on expiration

  • Role-based authorization

  • Custom JwtAuthenticationFilter

  • Protected REST endpoints

  • Admin-only API routes (/api/admin/**)

🏗 Architecture

The application follows a classic client-server architecture:

flowchart TD
    A[React SPA] --> B[Spring Boot REST API]
    B --> C[PostgreSQL Database]
Loading

🗄 Database Architecture

There is three main tables in database

erDiagram

    USER ||--o{ CATEGORY : owns
    USER ||--o{ ITEM : creates
    CATEGORY ||--o{ ITEM : contains

    USER {
        Long id 
        String username
        String email
        String password 
        String avatar 
        String about 
        Role role 
    }

    CATEGORY {
        Long id 
        String name 
        Long userId
    }

    ITEM {
        Long id 
        String title 
        Double rating
        String additionalInfo 
        String poster
        Long userId 
        Long categoryId 
    }
Loading

📡 REST API Structure

🔑 Auth Endpoints

Method Endpoint Description
POST /api/auth/register Register user
POST /api/auth/authenticate Login
POST /api/auth/refresh Refresh access token
POST /api/auth/logout Logout

👤 User Endpoints

Method Endpoint Access Description
GET /api/users/profile Authenticated Get user info
PUT /api/users/avatar Authenticated Update avatar
PUT /api/users/about Authenticated Update about block
PUT /api/users/name Authenticated Update name
GET /api/users/stats Authenticated Get user stats

📂 Category Endpoints

Method Endpoint Access Description
GET /api/categories Authenticated Get categories
GET /api/categories/{id} Authenticated Get category by id
POST /api/categories Authenticated Add category
PUT /api/categories/{id} Authenticated Update category
DELETE /api/categories/{id} Authenticated Delete category

📦 Item Endpoints

Method Endpoint Access Description
GET /api/items Authenticated Get items with filtration and sorting
GET /api/items/{id} Authenticated Get item by id
POST /api/items Authenticated Add item
PUT /api/items/{id} Authenticated Update item
DELETE /api/items/{id} Authenticated Delete item

👑 Admin Endpoints

Method Endpoint Access Description
GET /api/admin/user-by-email ADMIN Get user by email
DELETE /api/admin/user-by-email ADMIN Delete user by email

🔍 How it looks

Main page have several blocks:

  • Categories list
  • Items list
  • Filter bar
  • Hidden navigation bar

Main page

Profile page:

  • Avatar and name
  • About block
  • Best items for each category
  • Logout button

Main page

Add item page:

  • Input fields
  • Preview card
  • Submit button
  • Cancel button

Main page

Registration page:

Main page

Login page:

Main page

🚀 How to Run

Backend

mvn spring-boot:run

Runs on:

http://localhost:8080

About

This is a REST service for the Mita app. This app is a library for your favorite movies, series, games, and more.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages