DevWorkspace is a Spring Boot application for managing workspaces and their members.
It allows workspace owners to add/remove members, assign roles, and view workspace member lists.
- Create and manage workspaces
- Add members to a workspace (owner-only permission)
- Remove members from a workspace (owner-only permission)
- List all members in a workspace
- Clean JSON responses using DTOs
- Role-based checks to ensure only owners can modify members
- Backend: Java 17, Spring Boot 3
- Database: H2 (in-memory for testing) / PostgreSQL or MySQL (optional for production)
- ORM: Spring Data JPA (Hibernate)
- Build Tool: Maven
- API: RESTful endpoints
Tables:
users: stores user accountsworkspaces: stores workspace info, links to ownerworkspace_members: maps users to workspaces with roles (ownerormember)
Relationships:
Workspace→User(owner) → One-to-OneWorkspaceMember→User&Workspace→ Many-to-One- Unique constraint on
(user_id, workspace_id)inworkspace_members
- Clone the repository
git clone https://github.com/<your-username>/devworkspace.git
cd devworkspace- Build and run the project
mvn spring-boot:run- Access the API
Base URL: http://localhost:8080API Endpoints
| Resource | Method | Endpoint | Request Params / Body | Permissions / Notes |
|---|---|---|---|---|
| Users | POST | /api/users/register |
Body: { "name", "email", "password" } |
Anyone |
| POST | /api/users/login |
Body: { "email", "password" } |
Anyone | |
| GET | /api/users |
- | Admin / All users (optional) | |
| Workspaces | POST | /workspaces |
Body: { "name" } |
Only logged-in user; becomes owner |
| GET | /workspaces |
- | All logged-in users | |
| GET | /workspaces/{id}/members |
- | Only workspace members | |
| POST | /workspaces/{id}/members?requesterId={userId} |
Body: { "userId", "role" } |
Only owner | |
| DELETE | /workspaces/{id}/members/{memberId}?requesterId={userId} |
- | Only owner | |
| Channels | POST | /channels/workspace/{workspaceId}?requesterId={userId}&name={name} |
- | Only workspace owner |
| GET | /channels/workspace/{workspaceId} |
- | Workspace members | |
| DELETE | /channels/{channelId}?requesterId={userId} |
- | Only workspace owner | |
| Messages | POST | /messages/channel/{channelId}?senderId={userId}&content={text} |
- | Workspace members |
| GET | /messages/channel/{channelId} |
- | Workspace members | |
| DELETE | /messages/{messageId}?requesterId={userId} |
- | Only sender can delete |
POST /api/users/register POST /api/users/login GET /api/users
POST /workspaces # create workspace GET /workspaces # list workspaces GET /workspaces/{id}/members # list workspace members POST /workspaces/{id}/members # add member DELETE /workspaces/{id}/members/{memberId} # remove member
POST /channels/workspace/{workspaceId}?requesterId=1&name=general GET /channels/workspace/{workspaceId} DELETE /channels/{channelId}?requesterId=1
POST /messages/channel/{channelId}?senderId=2&content=Hello GET /messages/channel/{channelId} DELETE /messages/{messageId}?requesterId=2 # delete own message
- Clone the repository
- Configure
application.propertiesfor your database - Run the Spring Boot application
- Use Postman or frontend to interact with APIs
- Only workspace owners can create channels or manage members
- Members can send messages and delete their own messages
- Deleting a workspace or channel cascades to delete associated members, channels, and messages
This project is licensed under the MIT License.