GCode-codepad is a collaborative online code editor integrated with real-time video calling functionality. The backend is designed as a distributed system using a microservices architecture, ensuring scalability, maintainability, and high performance. This README provides an overview of the backend structure, the services involved, and instructions to set up and test the system using Docker Compose.
The backend of GCode-codepad is structured as a set of interconnected microservices, each responsible for specific functionalities. These services communicate over a dedicated Docker network, ensuring secure and efficient inter-service interactions. The system leverages:
- MySQL: For persistent data storage.
- Redis: For caching and fast data access.
- Microservices: To handle user management, video calls, code synchronization, and API gateway functionalities.
- Image:
mysql:latest
- Container Name:
mysql-db
- Description: Serves as the primary data store for persistent information such as user data, room metadata, and other relational data.
- Environment Variables:
MYSQL_ROOT_PASSWORD
: Root user password.MYSQL_DATABASE
: Name of the default database.MYSQL_USER
: Database user.MYSQL_PASSWORD
: Password for the database user.
- Ports:
3306:3306
- Volumes: Persists data in the
mysql-data
volume.
- Image:
redis:latest
- Container Name:
redis
- Description: Provides in-memory data storage for caching, session management, and fast access to frequently used data.
- Ports:
6379:6379
- Image: Built from
./user-service/Dockerfile
- Container Name:
user-service
- Description: Handles user registration, authentication, and profile management.
- Environment Variables:
DB_HOST
: Hostname for MySQL (mysql-db
).DB_PORT
: Port for MySQL (3306
).DB_USER
: MySQL user (youruser
).DB_PASSWORD
: MySQL password (yourpassword
).DB_NAME
: MySQL database name (yourdatabase
).
- Ports:
8081:8081
- Dependencies: Depends on
mysql-db
. - Networks:
backend
- Image: Built from
./gateway/Dockerfile
- Container Name:
gateway
- Description: Acts as the API Gateway, routing requests to appropriate backend services and handling cross-cutting concerns like authentication, logging, and rate limiting.
- Environment Variables:
SPRING_APPLICATION_NAME
: Name of the application (gateway
).SERVER_PORT
: Port for the gateway (8080
).USER_SERVICE_URI
: URI for the User Service (http://user-service:8081
).CODE_SERVICE_URI
: URI for the Code Service (http://code-service:8083
).
- Ports:
8080:8080
- Dependencies: Depends on
user-service
,video-service
, andcode-service
. - Networks:
backend
- Image: Built from
./video-service/Dockerfile
- Container Name:
video-service
- Description: Manages video call functionalities, handling signaling and peer connections using WebRTC.
- Ports:
8002:8002
- Networks:
backend
- Image: Built from
./code-service/Dockerfile
- Container Name:
code-service
- Description: Manages real-time code synchronization, leveraging Firebase Realtime Database for collaborative editing.
- Ports:
8083:8083
- Networks:
backend
Before setting up the backend services, ensure you have the following installed on your local machine or server:
- Docker: Install Docker
- Docker Compose: Install Docker Compose
- Git: Install Git
git clone https://github.com/yourusername/GCode-codepad-backend.git
cd GCode-codepad-backend
docker-compose up -d --build
docker-compose ps
docker-compose logs <service-name>
This project is licensed under the MIT License. You are free to use, modify, and distribute the code.