This project is a simplified clone of the popular Discord platform, featuring real-time messaging and user interaction. The backend is powered by Spring Boot, and the frontend is built with Angular.
- User authentication (login, registration)
- Real-time messaging with WebSockets
- Private and group channels
- User profile management
- Role-based permissions
- Tech Stack
- Architecture
- Setup
- Running the Application
- API Endpoints
- Frontend Overview
- Contributing
- License
- Java 17 or later
- Spring Boot (REST, WebSocket, Security, JPA)
- MySQL/PostgreSQL (or any other relational database)
- WebSocket for real-time communication
- Angular 14+ (with TypeScript)
- Bootstrap or Angular Material for UI design
- Socket.io for WebSocket-based messaging
- Maven/Gradle for build management
- Docker for containerization (optional)
- JWT for authentication and session management
- Redis for caching (optional)
- Backend: The backend is designed using a microservices architecture with RESTful services for user authentication, messaging, and channel management. Real-time messaging is implemented using WebSockets.
- Frontend: The Angular frontend interacts with the backend using REST APIs and WebSockets for real-time communication.
- Java 17 or later
- Node.js (with npm)
- Angular CLI
- MySQL/PostgreSQL (or any database)
- Maven (or Gradle)
-
Clone the repository.
git clone https://github.com/yourusername/discord-clone.git cd discord-clone/backend
-
Set up the database:
- Create a database in MySQL/PostgreSQL named
discord_clone
. - Configure the
application.properties
(orapplication.yml
) file with your database details.
spring.datasource.url=jdbc:mysql://localhost:3306/discord_clone spring.datasource.username=yourusername spring.datasource.password=yourpassword spring.jpa.hibernate.ddl-auto=update
- Create a database in MySQL/PostgreSQL named
-
Build and run the backend.
./mvnw clean install ./mvnw spring-boot:run
- Navigate to the
frontend
directory.cd ../frontend
- Install the dependencies.
npm install
- Serve the Angular application.
ng serve
- Once the backend is running, the REST APIs will be available at
http://localhost:8080/api
. - WebSocket endpoints will be available at
ws://localhost:8080/ws
.
- The Angular frontend can be accessed at
http://localhost:4200
.
POST /api/auth/register
- Register a new userPOST /api/auth/login
- Login an existing user
GET /api/channels/{channelId}/messages
- Retrieve messages from a channelPOST /api/channels/{channelId}/messages
- Send a message in a channel
GET /api/channels
- List all available channelsPOST /api/channels
- Create a new channel
GET /api/users/{userId}
- Retrieve user profilePUT /api/users/{userId}
- Update user profile
- Endpoint:
ws://localhost:8080/ws
- Events:
message
- Send/receive messageschannel_join
- Notify users when someone joins a channel
The frontend allows users to:
- Sign Up and Log In using JWT authentication.
- Join/Create Channels: Users can join existing channels or create their own.
- Real-time Messaging: Users can send and receive messages in real time.
- Manage User Profiles: Users can update their profiles and view other users.
We welcome contributions! If you'd like to contribute, please fork the repository and submit a pull request.
Steps:
- Fork the repo
- Create your feature branch (
git checkout -b feature/YourFeature
) - Commit your changes (
git commit -am 'Add YourFeature'
) - Push to the branch (
git push origin feature/YourFeature
) - Create a new Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
If you have any questions, feel free to reach out to the project maintainer at [[email protected]].
Let me know if you'd like any changes or additional details!