System Architecture Overview
Relevant source files
The following files were used as context for generating this wiki page:
- README.md
- src/main/resources/data.sql
- src/main/java/org/example/coding_convention/project/model/Project.java
- src/main/java/org/example/coding_convention/user/model/User.java
- src/main/java/org/example/coding_convention/websocket/WebSocketController.java
- src/main/java/org/example/coding_convention/project/service/ProjectService.java
- src/main/java/org/example/coding_convention/file/model/Files.java
The PhanesEditor backend is a real-time collaborative web-based code editor designed to facilitate project-based teamwork. The system architecture is built around a hybrid communication model that separates administrative CRUD operations from high-concurrency real-time interactions. It utilizes a Spring Boot framework with MariaDB for persistence and WebSocket for low-latency synchronization of code changes and chat messages.
Sources: README.md:1-15, README.md:65-75
Core Architectural Components
The system is structured into several functional domains, with the Project entity acting as the central unit for access control and resource grouping.
High-Level Architecture
The following diagram illustrates the separation between RESTful API services and WebSocket real-time services.
The architecture separates HTTP-based management of projects and members from WebSocket-based real-time communication for editing and chatting.
Sources: README.md:85-92, src/main/java/org/example/coding_convention/websocket/WebSocketController.java:15-30
Data Model and Schema
The system uses a relational schema where users belong to projects through a many-to-many relationship managed by the project_member mapping table.
Entity Relationship Diagram
The database schema defines strict ownership and association rules, ensuring that files and chats are strictly bound to specific projects.
Key Data Structures
| Component | Responsibility | Relevant Files |
|---|---|---|
| User | Manages authentication, profile, and platform integration (LOCAL, KAKAO, GOOGLE). | User.java |
| Project | Groups files and members; defines the primary language (JAVA, PYTHON, etc.). | Project.java |
| Files | Tracks code assets, paths, and S3 URLs within a specific project. | Files.java |
| ProjectMember | Manages authorization levels (ADMIN, USER) for project-specific actions. | ProjectMember.java |
Real-Time Communication Flow
The system implements real-time features using Spring WebSocket with the STOMP protocol. Communication is routed through room IDs (typically project IDs) to ensure message isolation.
WebSocket Message Routing
The WebSocketController handles two primary message types:
- Chat Messages: Distributed to
/topic/chat/{roomId}. - Editor Events: Distributed to
/topic/editor/{roomId}to sync code changes and cursor positions.
Access Control Logic
A critical design point of the PhanesEditor architecture is Project-Based Access Control. Before allowing a user to participate in real-time communication or modify files, the system validates their membership status.
- REST Validation: Controllers often check
UserDto.AuthUseragainst project indices. - WebSocket Validation: Connection is restricted based on project membership to block unauthorized access.
- Membership Roles: The
ProjectMember.Status(ADMIN or USER) determines specific permissions within a project.
Sources: README.md:57-63, src/main/java/org/example/coding_convention/project/service/ProjectService.java:58-75, src/main/java/org/example/coding_convention/project_member/model/ProjectMember.java:24-26
Conclusion
The PhanesEditor-BE architecture provides a robust foundation for collaborative coding by effectively combining traditional relational data management with real-time event broadcasting. By centering all interactions around the "Project" entity and enforcing strict membership-based access control, the system ensures data integrity and secure collaboration for its users.