| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
In traditional collaborative environments, when multiple users attempt to edit the same data simultaneously, race conditions inevitably lead to database corruption. In the context of a live subtitle editing engine, this results in overwritten translations and broken timestamp synchronizations. Furthermore, repeatedly querying a relational database for massive datasets creates severe latency bottlenecks, while static HTTP architectures force users to manually refresh their clients just to see updates.
LingoStream is a highly concurrent, distributed backend designed to solve the bottlenecks of real-time collaborative editing. Built to handle heavy read/write traffic, it actively prevents concurrent data collisions, serves read requests in under 5 milliseconds, and pushes live translation updates to all connected clients instantly without requiring manual intervention.
LingoStream/
├── docker-compose.yml # Infrastructure blueprint (PostgreSQL, Redis, App)
├── Dockerfile # Multi-stage build instructions for the Spring Boot app
├── pom.xml # Maven dependencies (Testcontainers, Redisson, WebSockets)
├── README.md # Documentation
└── src/
├── main/
│ ├── java/
│ │ └── com/
│ │ └── lingostream/
│ │ └── core/
│ │ ├── CoreApplication.java # Spring Boot entry point
│ │ ├── config/
│ │ │ ├── RedissonConfig.java # Dynamic Redis & Spring Cache config
│ │ │ └── WebSocketConfig.java # STOMP message broker config
│ │ ├── controller/
│ │ │ ├── AuthController.java # JWT Keymaster / Login endpoint
│ │ │ └── SubtitleController.java # Cache-intercepted REST endpoints
│ │ ├── entity/
│ │ │ └── SubtitleEntity.java # Database schema mapping
│ │ ├── repository/
│ │ │ └── SubtitleRepository.java # PostgreSQL data access layer
│ │ ├── security/ # JWT Cryptography & Filter Chain
│ │ │ ├── JwtAuthenticationFilter.java
│ │ │ ├── JwtUtil.java
│ │ │ └── SecurityConfig.java
│ │ └── service/
│ │ ├── DataIngestionRunner.java # Startup script to parse SRT files
│ │ ├── RedisMessageSubscriber.java # Redis Pub/Sub cluster listener
│ │ └── SubtitleService.java # Business logic, locks, & sockets
│ └── resources/
│ ├── application.yml # Spring Boot properties
│ ├── dataset/
│ │ ├── iron-man-1-en.srt # Sample English subtitle data
│ │ └── iron-man-1-jp.srt # Sample Japanese subtitle data
│ └── static/
│ └── websocket-test.html # Live STOMP client for socket verification
└── test/
└── java/
└── com/lingostream/core/
└── SubtitleIntegrationTest.java # Testcontainers verification
Note: The live demonstration above was recorded during Phase 4 development, prior to the implementation of the stateless JWT authentication vault.
Because the entire distributed infrastructure (Application, PostgreSQL database, and Redis cache) is containerized via a multi-stage Docker build, you do not need to install Java, Postgres, or Redis on your local machine to run this project.
Clone the repository and spin up the environment using Docker Compose:
git clone https://github.com/yourusername/lingostream.git
cd lingostream
docker-compose up --build
Note: On the first run, the DataIngestionRunner will automatically parse the provided multi-language SRT files in the /dataset folder and seed the PostgreSQL database.
Once the Spring Boot banner appears in the terminal, you can fetch the English subtitle track for Iron Man. The first request will hit PostgreSQL; subsequent refreshes will be served entirely from the Redis cache.
curl -X GET "http://localhost:8080/api/subtitles/iron-man-1?language=en"
To see the full-duplex WebSocket broadcasting in action, you must first authenticate.
curl -X POST http://localhost:8080/api/auth/login \
-H "Content-Type: application/json" \
-d '{"username":"admin", "password":"password"}'
curl -X PUT http://localhost:8080/api/subtitles/YOUR-UUID-HERE \
-H "Authorization: Bearer YOUR_JWT_TOKEN_HERE" \
-H "Content-Type: text/plain" \
-d "Redis Pub/Sub is working!"
The browser UI will instantly render the updated database row in real-time, routed completely through the Redis message broker.
| Method | Endpoint | Parameters | Description |
|---|---|---|---|
| POST | /api/auth/login | username, password | Authenticates the user and returns a cryptographically signed JWT. |
| GET | /api/subtitles/{videoId} | language (default: 'en') | Public route. Retrieves subtitle payload via Redis Cache-Aside pattern for <5ms response times. |
| PUT | /api/subtitles/{id} | String (Body), Bearer Token | Secured route. Updates a line, triggers distributed lock, evicts cache, and fires a Redis Pub/Sub broadcast. |
| Protocol | Destination | Description |
|---|---|---|
| Connect | /ws | The initial handshake endpoint for the SockJS client. |
| Subscribe | /topic/subtitles/{videoId} | The dedicated channel clients subscribe to for receiving real-time, broadcasted updates. |
| Back | FazBrowse Home | New Git URL |