# kumagaihirokiss/protospace-b architecture

> Architecture diagram of the GitHub repository kumagaihirokiss/protospace-b, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kumagaihirokiss/protospace-b
- Repository: https://github.com/kumagaihirokiss/protospace-b

## Overview

This repository is a single Spring Boot monolith that serves a server-rendered web app for managing users, prototypes, and comments. It is packaged as a runnable JAR on Java 21 and is designed to run against PostgreSQL, with schema evolution handled by Flyway.

The main architectural style is MVC:
- Browser requests hit Spring MVC controllers.
- Controllers bind request data into form objects and invoke persistence/auth helpers.
- Domain data is loaded from the database through repository abstractions.
- Responses are rendered with Thymeleaf templates rather than a separate frontend app.

The presentation layer is in `src/main/resources/templates`. It is split by feature:
- `prototypes/` for listing, detail, create, and edit screens
- `users/` for login, signup, and user detail screens
- `fragments/` for reusable header and footer markup  
Static CSS and image assets live under `src/main/resources/static`, so UI styling is fully server-side rendered and asset-based.

The web/controller layer is feature-oriented:
- `PrototypeController` handles prototype browsing and CRUD-style interactions.
- `CommentController` manages comment submission.
- `UserController` handles account-related flows such as sign-up, login, and user profile views.  
This layer is the main boundary between HTTP requests and application logic.

Request validation is separated into dedicated form objects and validation groups:
- `UserForm`
- `CommentForm`
- `ValidationOrder`, `ValidationPriority1`, `ValidationPriority2`  
This suggests multi-step or prioritized validation rules, likely for signup and posting flows, keeping input validation out of the controllers and entities.

The domain/persistence model is centered on three entities:
- `UserEntity`
- `PrototypeEntity`
- `CommentEntity`  
These represent the app’s core business data and likely form the main relational model: users author prototypes, and prototypes receive comments.

Data access is organized through repository interfaces:
- `UserRepository`
- `PrototypeRepository`
- `CommentRepository`  
These repositories are the abstraction point between controllers/services and the database. The project dependency list mentions MyBatis, while the file tree shows repository-style persistence and SQL migrations, so the repository boundary is the key persistence seam in the architecture.

Schema management is externalized in Flyway migrations under `src/main/resources/db/migration`:
- users table
- prototype table
- comment table
- foreign key addition linking prototypes to users  
This makes the database structure explicit and versioned, which is important for diagramming the persistence layer as a first-class subsystem rather than an implicit runtime concern.

Authentication and authorization are handled by a separate security slice:
- `SecurityConfig` defines the security rules and login flow.
- `CustomUserDetail` adapts application users to Spring Security’s user model.
- `UserAuthenticationService` supports authentication-related lookup/logic.  
This indicates the app has authenticated and anonymous user boundaries, with login/signup integrated into the same monolith.

`application.properties` and `application-prod.properties` suggest environment-specific configuration, likely covering database connection, security/session settings, and runtime profiles. The presence of a `Dockerfile` indicates the app is intended to be containerized for deployment.

From a data-flow perspective, the most important paths are:
- Prototype browsing: HTTP request → controller → repository → PostgreSQL → Thymeleaf view
- Signup/login: HTTP request → controller → form validation → auth/service layer → user repository → security context/session
- Comment posting: HTTP request → controller → comment form validation → repository → database → updated prototype detail view

The only test artifact shown is a Spring Boot application test, so the repo currently appears centered on application-level integration/runtime structure rather than a large unit-test suite.

Main entry points: [`protospace/src/main/java/in/tech_camp/protospace/ProtospaceApplication.java`](https://github.com/kumagaihirokiss/protospace-b/blob/main/protospace/src/main/java/in/tech_camp/protospace/ProtospaceApplication.java) (Protospace), [`protospace/src/main/java/in/tech_camp/protospace/controller/PrototypeController.java`](https://github.com/kumagaihirokiss/protospace-b/blob/main/protospace/src/main/java/in/tech_camp/protospace/controller/PrototypeController.java) (Prototype Ctrl), [`protospace/src/main/java/in/tech_camp/protospace/controller/CommentController.java`](https://github.com/kumagaihirokiss/protospace-b/blob/main/protospace/src/main/java/in/tech_camp/protospace/controller/CommentController.java) (Comment Ctrl), [`protospace/src/main/java/in/tech_camp/protospace/controller/UserController.java`](https://github.com/kumagaihirokiss/protospace-b/blob/main/protospace/src/main/java/in/tech_camp/protospace/controller/UserController.java) (User Ctrl)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_app["App Core"]
  node_node_app["Protospace<br/>Spring Boot app"]
end

subgraph group_group_web["Web Layer"]
  node_node_proto_controller["Prototype Ctrl<br/>MVC controller"]
  node_node_comment_controller["Comment Ctrl<br/>MVC controller"]
  node_node_user_controller["User Ctrl<br/>MVC controller"]
  node_node_proto_views["Prototype Views<br/>Thymeleaf views"]
  node_node_user_views["User Views<br/>Thymeleaf views"]
end

subgraph group_group_domain["Domain Model"]
  node_node_user_form["User Form<br/>form object<br/>[UserForm.java]"]
  node_node_comment_form["Comment Form<br/>form object<br/>[CommentForm.java]"]
  node_node_validation["Validation Rules<br/>validation groups"]
  node_node_user_entity[("User Entity<br/>JPA entity<br/>[UserEntity.java]")]
  node_node_proto_entity[("Prototype Entity<br/>JPA entity")]
  node_node_comment_entity[("Comment Entity<br/>JPA entity<br/>[CommentEntity.java]")]
end

subgraph group_group_persistence["Persistence"]
  node_node_user_repo["User Repo"]
  node_node_proto_repo["Prototype Repo"]
  node_node_comment_repo["Comment Repo"]
  node_node_migrations["Flyway Migrations<br/>schema migrations"]
end

subgraph group_group_security["Security"]
  node_node_security_config["Security Config"]
  node_node_user_detail["User Detail<br/>Security adapter"]
  node_node_auth_service["Auth Service"]
end

subgraph group_group_assets["UI Assets"]
  node_node_fragments["Fragments"]
  node_node_static["Static Assets<br/>css/images"]
end

node_node_app -->|"wires"| node_node_security_config
node_node_app -->|"hosts"| node_node_proto_controller
node_node_app -->|"hosts"| node_node_comment_controller
node_node_app -->|"hosts"| node_node_user_controller
node_node_security_config -->|"uses"| node_node_user_detail
node_node_security_config -->|"delegates"| node_node_auth_service
node_node_user_controller -->|"binds"| node_node_user_form
node_node_user_controller -->|"applies"| node_node_validation
node_node_proto_controller -->|"reads/writes"| node_node_proto_repo
node_node_proto_controller -->|"reads"| node_node_user_repo
node_node_comment_controller -->|"binds"| node_node_comment_form
node_node_comment_controller -->|"writes"| node_node_comment_repo
node_node_comment_controller -->|"applies"| node_node_validation
node_node_proto_repo -->|"maps"| node_node_proto_entity
node_node_proto_repo -->|"joins"| node_node_user_entity
node_node_comment_repo -->|"maps"| node_node_comment_entity
node_node_user_repo -->|"maps"| node_node_user_entity
node_node_auth_service -->|"queries"| node_node_user_repo
node_node_user_detail -->|"adapts"| node_node_user_entity
node_node_proto_entity -->|"related"| node_node_comment_entity
node_node_proto_controller -->|"renders"| node_node_proto_views
node_node_user_controller -->|"renders"| node_node_user_views
node_node_proto_views -->|"includes"| node_node_fragments
node_node_user_views -->|"includes"| node_node_fragments
node_node_proto_views -->|"uses"| node_node_static
node_node_user_views -->|"uses"| node_node_static
node_node_migrations -->|"creates"| node_node_user_entity
node_node_migrations -->|"creates"| node_node_proto_entity
node_node_migrations -->|"creates"| node_node_comment_entity

click node_node_app "https://github.com/kumagaihirokiss/protospace-b/blob/main/protospace/src/main/java/in/tech_camp/protospace/ProtospaceApplication.java"
click node_node_security_config "https://github.com/kumagaihirokiss/protospace-b/blob/main/protospace/src/main/java/in/tech_camp/protospace/SecurityConfig.java"
click node_node_user_detail "https://github.com/kumagaihirokiss/protospace-b/blob/main/protospace/src/main/java/in/tech_camp/protospace/custom_user/CustomUserDetail.java"
click node_node_auth_service "https://github.com/kumagaihirokiss/protospace-b/blob/main/protospace/src/main/java/in/tech_camp/protospace/service/UserAuthenticationService.java"
click node_node_proto_controller "https://github.com/kumagaihirokiss/protospace-b/blob/main/protospace/src/main/java/in/tech_camp/protospace/controller/PrototypeController.java"
click node_node_comment_controller "https://github.com/kumagaihirokiss/protospace-b/blob/main/protospace/src/main/java/in/tech_camp/protospace/controller/CommentController.java"
click node_node_user_controller "https://github.com/kumagaihirokiss/protospace-b/blob/main/protospace/src/main/java/in/tech_camp/protospace/controller/UserController.java"
click node_node_proto_views "https://github.com/kumagaihirokiss/protospace-b/tree/main/protospace/src/main/resources/templates/prototypes"
click node_node_user_views "https://github.com/kumagaihirokiss/protospace-b/tree/main/protospace/src/main/resources/templates/users"
click node_node_fragments "https://github.com/kumagaihirokiss/protospace-b/tree/main/protospace/src/main/resources/templates/fragments"
click node_node_static "https://github.com/kumagaihirokiss/protospace-b/tree/main/protospace/src/main/resources/static"
click node_node_user_form "https://github.com/kumagaihirokiss/protospace-b/blob/main/protospace/src/main/java/in/tech_camp/protospace/form/UserForm.java"
click node_node_comment_form "https://github.com/kumagaihirokiss/protospace-b/blob/main/protospace/src/main/java/in/tech_camp/protospace/form/CommentForm.java"
click node_node_validation "https://github.com/kumagaihirokiss/protospace-b/blob/main/protospace/src/main/java/in/tech_camp/protospace/validation/ValidationOrder.java"
click node_node_user_entity "https://github.com/kumagaihirokiss/protospace-b/blob/main/protospace/src/main/java/in/tech_camp/protospace/entity/UserEntity.java"
click node_node_proto_entity "https://github.com/kumagaihirokiss/protospace-b/blob/main/protospace/src/main/java/in/tech_camp/protospace/entity/PrototypeEntity.java"
click node_node_comment_entity "https://github.com/kumagaihirokiss/protospace-b/blob/main/protospace/src/main/java/in/tech_camp/protospace/entity/CommentEntity.java"
click node_node_user_repo "https://github.com/kumagaihirokiss/protospace-b/blob/main/protospace/src/main/java/in/tech_camp/protospace/repository/UserRepository.java"
click node_node_proto_repo "https://github.com/kumagaihirokiss/protospace-b/blob/main/protospace/src/main/java/in/tech_camp/protospace/repository/PrototypeRepository.java"
click node_node_comment_repo "https://github.com/kumagaihirokiss/protospace-b/blob/main/protospace/src/main/java/in/tech_camp/protospace/repository/CommentRepository.java"
click node_node_migrations "https://github.com/kumagaihirokiss/protospace-b/tree/main/protospace/src/main/resources/db/migration"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_node_app toneBlue
class node_node_proto_controller,node_node_comment_controller,node_node_user_controller,node_node_proto_views,node_node_user_views toneAmber
class node_node_user_form,node_node_comment_form,node_node_validation,node_node_user_entity,node_node_proto_entity,node_node_comment_entity toneMint
class node_node_user_repo,node_node_proto_repo,node_node_comment_repo,node_node_migrations toneRose
class node_node_security_config,node_node_user_detail,node_node_auth_service toneIndigo
class node_node_fragments,node_node_static toneTeal
```

## Components

### App Core

Spring Boot entrypoint and runtime wiring.

- [Protospace](https://github.com/kumagaihirokiss/protospace-b/blob/main/protospace/src/main/java/in/tech_camp/protospace/ProtospaceApplication.java): Spring Boot app · Application bootstrap and runtime entrypoint. · `protospace/src/main/java/in/tech_camp/protospace/ProtospaceApplication.java`

### Web Layer

MVC controllers and server-rendered views.

- [Prototype Ctrl](https://github.com/kumagaihirokiss/protospace-b/blob/main/protospace/src/main/java/in/tech_camp/protospace/controller/PrototypeController.java): MVC controller · Handles prototype browsing and CRUD-style interactions. · `protospace/src/main/java/in/tech_camp/protospace/controller/PrototypeController.java`
- [Comment Ctrl](https://github.com/kumagaihirokiss/protospace-b/blob/main/protospace/src/main/java/in/tech_camp/protospace/controller/CommentController.java): MVC controller · Handles comment submission flows. · `protospace/src/main/java/in/tech_camp/protospace/controller/CommentController.java`
- [User Ctrl](https://github.com/kumagaihirokiss/protospace-b/blob/main/protospace/src/main/java/in/tech_camp/protospace/controller/UserController.java): MVC controller · Handles signup, login, and user profile views. · `protospace/src/main/java/in/tech_camp/protospace/controller/UserController.java`
- [Prototype Views](https://github.com/kumagaihirokiss/protospace-b/tree/main/protospace/src/main/resources/templates/prototypes): Thymeleaf views · Templates for listing, detail, create, and edit screens. · `protospace/src/main/resources/templates/prototypes`
- [User Views](https://github.com/kumagaihirokiss/protospace-b/tree/main/protospace/src/main/resources/templates/users): Thymeleaf views · Templates for login, signup, and user detail screens. · `protospace/src/main/resources/templates/users`

### Domain Model

Forms, entities, and validation boundaries.

- [User Form](https://github.com/kumagaihirokiss/protospace-b/blob/main/protospace/src/main/java/in/tech_camp/protospace/form/UserForm.java): form object · Request binding and validation input for user flows. · `protospace/src/main/java/in/tech_camp/protospace/form/UserForm.java`
- [Comment Form](https://github.com/kumagaihirokiss/protospace-b/blob/main/protospace/src/main/java/in/tech_camp/protospace/form/CommentForm.java): form object · Request binding and validation input for comments. · `protospace/src/main/java/in/tech_camp/protospace/form/CommentForm.java`
- [Validation Rules](https://github.com/kumagaihirokiss/protospace-b/blob/main/protospace/src/main/java/in/tech_camp/protospace/validation/ValidationOrder.java): validation groups · Prioritized validation ordering for multi-step input checks. · `protospace/src/main/java/in/tech_camp/protospace/validation/ValidationOrder.java`
- [User Entity](https://github.com/kumagaihirokiss/protospace-b/blob/main/protospace/src/main/java/in/tech_camp/protospace/entity/UserEntity.java): JPA entity · Core user record stored in the database. · `protospace/src/main/java/in/tech_camp/protospace/entity/UserEntity.java`
- [Prototype Entity](https://github.com/kumagaihirokiss/protospace-b/blob/main/protospace/src/main/java/in/tech_camp/protospace/entity/PrototypeEntity.java): JPA entity · Core prototype record stored in the database. · `protospace/src/main/java/in/tech_camp/protospace/entity/PrototypeEntity.java`
- [Comment Entity](https://github.com/kumagaihirokiss/protospace-b/blob/main/protospace/src/main/java/in/tech_camp/protospace/entity/CommentEntity.java): JPA entity · Core comment record stored in the database. · `protospace/src/main/java/in/tech_camp/protospace/entity/CommentEntity.java`

### Persistence

Repositories and database migrations.

- [User Repo](https://github.com/kumagaihirokiss/protospace-b/blob/main/protospace/src/main/java/in/tech_camp/protospace/repository/UserRepository.java): repository · Persistence boundary for user data access. · `protospace/src/main/java/in/tech_camp/protospace/repository/UserRepository.java`
- [Prototype Repo](https://github.com/kumagaihirokiss/protospace-b/blob/main/protospace/src/main/java/in/tech_camp/protospace/repository/PrototypeRepository.java): repository · Persistence boundary for prototype data access. · `protospace/src/main/java/in/tech_camp/protospace/repository/PrototypeRepository.java`
- [Comment Repo](https://github.com/kumagaihirokiss/protospace-b/blob/main/protospace/src/main/java/in/tech_camp/protospace/repository/CommentRepository.java): repository · Persistence boundary for comment data access. · `protospace/src/main/java/in/tech_camp/protospace/repository/CommentRepository.java`
- [Flyway Migrations](https://github.com/kumagaihirokiss/protospace-b/tree/main/protospace/src/main/resources/db/migration): schema migrations · Versioned database schema evolution scripts. · `protospace/src/main/resources/db/migration`

### Security

Authentication and user identity integration.

- [Security Config](https://github.com/kumagaihirokiss/protospace-b/blob/main/protospace/src/main/java/in/tech_camp/protospace/SecurityConfig.java): Spring Security config · Defines authentication, authorization, and login flow. · `protospace/src/main/java/in/tech_camp/protospace/SecurityConfig.java`
- [User Detail](https://github.com/kumagaihirokiss/protospace-b/blob/main/protospace/src/main/java/in/tech_camp/protospace/custom_user/CustomUserDetail.java): Security adapter · Adapts application users to Spring Security's user model. · `protospace/src/main/java/in/tech_camp/protospace/custom_user/CustomUserDetail.java`
- [Auth Service](https://github.com/kumagaihirokiss/protospace-b/blob/main/protospace/src/main/java/in/tech_camp/protospace/service/UserAuthenticationService.java): auth service · Supports authentication-related user lookup and logic. · `protospace/src/main/java/in/tech_camp/protospace/service/UserAuthenticationService.java`

### UI Assets

Static styling and reusable template fragments.

- [Fragments](https://github.com/kumagaihirokiss/protospace-b/tree/main/protospace/src/main/resources/templates/fragments): template fragments · Reusable header and footer markup. · `protospace/src/main/resources/templates/fragments`
- [Static Assets](https://github.com/kumagaihirokiss/protospace-b/tree/main/protospace/src/main/resources/static): css/images · Server-side UI styling and image assets. · `protospace/src/main/resources/static`

## Connections

- Protospace → Security Config: wires · Bootstraps application security configuration.
- Protospace → Prototype Ctrl: hosts · Runs MVC request handling.
- Protospace → Comment Ctrl: hosts · Runs MVC request handling.
- Protospace → User Ctrl: hosts · Runs MVC request handling.
- Security Config → User Detail: uses · Loads authenticated user identity.
- Security Config → Auth Service: delegates · Relies on auth lookup and logic.
- User Ctrl → User Form: binds · Collects request data into forms.
- User Ctrl → Validation Rules: applies · Uses prioritized validation rules.
- Prototype Ctrl → Prototype Repo: reads/writes · Loads and persists prototypes.
- Prototype Ctrl → User Repo: reads · Resolves users for prototype-related flows.
- Comment Ctrl → Comment Form: binds · Collects comment submission data.
- Comment Ctrl → Comment Repo: writes · Persists new comments.
- Comment Ctrl → Validation Rules: applies · Uses validation for comment input.
- Prototype Repo → Prototype Entity: maps · Persists prototype records.
- Prototype Repo → User Entity: joins · Associates prototypes with authors.
- Comment Repo → Comment Entity: maps · Persists comment records.
- User Repo → User Entity: maps · Persists user records.
- Auth Service → User Repo: queries · Looks up users during authentication.
- User Detail → User Entity: adapts · Wraps application user data.
- Prototype Entity → Comment Entity: related · Prototypes receive comments.
- Prototype Ctrl → Prototype Views: renders · Serves prototype screens.
- User Ctrl → User Views: renders · Serves account screens.
- Prototype Views → Fragments: includes · Reuses shared header/footer markup.
- User Views → Fragments: includes · Reuses shared header/footer markup.
- Prototype Views → Static Assets: uses · Consumes CSS and image assets.
- User Views → Static Assets: uses · Consumes CSS and image assets.
- Flyway Migrations → User Entity: creates · Defines the users table.
- Flyway Migrations → Prototype Entity: creates · Defines the prototype table.
- Flyway Migrations → Comment Entity: creates · Defines the comment table.
