How slyrackgo/uni_library works
Project type and purpose
• This is a full-stack university online library system.
• Backend: Spring Boot (Java) REST API with JWT security, file upload/download, caching, and MySQL persistence.
• Frontend: React.js single-page application.
• Static file server: Node.js/Express serves the React build.
• Database scripts under src/main/Database/product.sql for schema initialization.
File structure
• Top level
• Dockerfile, pom.xml, mvnw scripts → Maven-based Spring Boot service, containerizable.
• src/main/Database → SQL script for MySQL.
• src/main/frontend → React app (package.json, public/, src/).
• src/main/server → Node.js/Express static file server (server.js, package.json).
• src/main/java/com/example/uni_library → Spring Boot code organized by layers: Controllers, Services, Repositories, Exceptions, Security, Product subpackage, Mappings, CacheConfiguration.
• Test code under src/test/java confirms REST endpoints and application bootstrapping.
Key insights from README
• Two user roles: Admin and User, both interacting via REST API.
• Endpoints:
• /product/{id}/upload (POST multipart)
• /product/{id}/download (GET)
• JWT token-based authentication.
• Technologies: Spring Boot, Java, React.js, MySQL.
Main components & interactions
a. React Frontend
• Hosted on Node.js/Express static server.
• Requests data and files via HTTP(S) to the API.
b. Node.js Static Server
• Serves optimized React build (index.html, JS bundles, static assets).
• Optionally proxies API calls to Spring Boot service for CORS.
c. Spring Boot Backend
• Presentation layer: Controllers (ProductController, AttachmentController, Security controllers).
• Business layer: Services and ServiceImpl classes implementing commands/queries (CreateProductService, GetProductService, etc.).
• Data layer: Repositories (Spring Data JPA) interacting with MySQL.
• Security layer: JWT filters, CustomUserDetailsService, SecurityConfiguration.
• CacheConfiguration for in-memory caching of frequent queries.
• Exception handling via GlobalExceptionHandler.
d. MySQL Database
• Tables for products, attachments, users, students, customers.
• Initialized by product.sql.
e. File Storage
• Local filesystem or configured storage location holds uploaded book files.
f. External/Infra services (optional)
• Docker container runtime, Maven build environment.
Architectural patterns & design principles
• Layered architecture (Controller → Service → Repository).
• Command and Query separation: Commands (upload, delete), Queries (get, search).
• DTO mapping via ModelMapperConfig.
• Centralized exception handling.
• Token-based stateless authentication with JWT filter chain.
• Static resource hosting decoupled from API.