Skip to content

Uttam-Mahata/texflow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

30 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

TexFlow - Online LaTeX Code Editor and Renderer

A production-ready, real-time collaborative LaTeX editor built with modern cloud-native technologies.

πŸš€ Features

  • Real-time Collaboration: Multiple users can edit documents simultaneously using CRDTs (Yjs)
  • LaTeX Compilation: Support for pdflatex, xelatex, and lualatex
  • Cloud Storage: Secure file storage with MinIO (S3-compatible)
  • User Authentication: JWT-based authentication with refresh tokens
  • Project Management: Create, share, and manage LaTeX projects
  • Monitoring: Built-in Prometheus metrics and Grafana dashboards
  • API Gateway: Kong gateway with rate limiting and authentication
  • Microservices: Scalable microservices architecture in Go

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Frontend  β”‚ (React + Monaco Editor)
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
       β”‚
β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Kong Gateway   β”‚ (Rate Limiting, Auth, Routing)
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                                           β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚   Auth   β”‚  β”‚ Project  β”‚  β”‚ WebSocketβ”‚ β”‚
β”‚  β”‚ Service  β”‚  β”‚ Service  β”‚  β”‚ Service  β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚                                           β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”              β”‚
β”‚  β”‚Collabora-β”‚  β”‚Compila-  β”‚              β”‚
β”‚  β”‚tion Svc  β”‚  β”‚tion Svc  β”‚              β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜              β”‚
β”‚                                           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”          β”‚
β”‚  β”‚MongoDB β”‚  β”‚ Redisβ”‚  β”‚ MinIOβ”‚          β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”˜          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“‹ Prerequisites

  • Docker and Docker Compose (20.10+)
  • Go 1.21+ (for local development)
  • Node.js 18+ and npm (for frontend development)
  • Make (optional, for convenience commands)

πŸš€ Quick Start

1. Clone the repository

git clone https://github.com/yourusername/texflow.git
cd texflow

2. Generate JWT keys

make generate-keys

Or manually:

mkdir -p keys
openssl genrsa -out keys/jwt-private.pem 4096
openssl rsa -in keys/jwt-private.pem -pubout -out keys/jwt-public.pem

3. Configure environment variables

cp .env.example .env
# Edit .env with your configuration

4. Start all services with Docker Compose

make docker-up
# OR
docker-compose -f deployments/docker/docker-compose.yml up -d

5. Verify services are running

docker-compose -f deployments/docker/docker-compose.yml ps

All services should show as "healthy" after a few moments.

6. Access the services

πŸ› οΈ Development

Build all services

make build

Run individual services locally

make run-auth
make run-project
make run-websocket
make run-collaboration
make run-compilation

Run tests

make test

View logs

make docker-logs

πŸ“š API Documentation

Authentication Endpoints

Register a new user

POST /api/v1/auth/register
Content-Type: application/json

{
  "email": "user@example.com",
  "username": "johndoe",
  "password": "securepassword123",
  "full_name": "John Doe"
}

Login

POST /api/v1/auth/login
Content-Type: application/json

{
  "email": "user@example.com",
  "password": "securepassword123"
}

Response:

{
  "user": {
    "id": "...",
    "email": "user@example.com",
    "username": "johndoe",
    "full_name": "John Doe"
  },
  "access_token": "eyJ...",
  "refresh_token": "eyJ...",
  "expires_in": 900
}

Get current user

GET /api/v1/auth/me
Authorization: Bearer <access_token>

Project Endpoints

Create a project

POST /api/v1/projects
Authorization: Bearer <access_token>
Content-Type: application/json

{
  "name": "My Research Paper",
  "description": "PhD thesis on Machine Learning",
  "compiler": "pdflatex",
  "is_public": false,
  "tags": ["research", "ml"]
}

List user projects

GET /api/v1/projects?page=1&limit=10
Authorization: Bearer <access_token>

Get a project

GET /api/v1/projects/:id
Authorization: Bearer <access_token>

πŸ—οΈ Project Structure

texflow/
β”œβ”€β”€ services/
β”‚   β”œβ”€β”€ auth/                 # Authentication service
β”‚   β”œβ”€β”€ project/              # Project management service
β”‚   β”œβ”€β”€ websocket/            # WebSocket service for real-time features
β”‚   β”œβ”€β”€ collaboration/        # Collaboration service (Yjs)
β”‚   └── compilation/          # LaTeX compilation service
β”œβ”€β”€ frontend/                 # React frontend
β”œβ”€β”€ infrastructure/
β”‚   β”œβ”€β”€ kong/                 # Kong API Gateway configuration
β”‚   β”œβ”€β”€ prometheus/           # Prometheus configuration
β”‚   └── grafana/              # Grafana dashboards
β”œβ”€β”€ deployments/
β”‚   β”œβ”€β”€ docker/               # Docker Compose files
β”‚   └── kubernetes/           # Kubernetes manifests
β”œβ”€β”€ docs/                     # Documentation
β”œβ”€β”€ Makefile                  # Build and deployment commands
└── README.md

πŸ”§ Configuration

Environment Variables

All services can be configured via environment variables. See .env.example for a complete list.

Key variables:

  • MONGO_URI: MongoDB connection string
  • REDIS_ADDR: Redis address
  • MINIO_ENDPOINT: MinIO endpoint
  • JWT_SECRET: Secret for JWT signing (use RSA keys in production)
  • COMPILATION_TIMEOUT: Maximum compilation time (default: 30s)

πŸ“Š Monitoring

Prometheus Metrics

Each service exposes metrics at /metrics. Key metrics include:

  • HTTP request rates and latencies
  • Database operation metrics
  • Active WebSocket connections
  • Compilation queue depth and duration
  • Cache hit rates

Grafana Dashboards

Access Grafana at http://localhost:3000 (default credentials: admin/admin)

Pre-configured dashboards:

  1. Service Health Dashboard: Overview of all services
  2. Compilation Metrics: Compilation performance and queue status
  3. Database Performance: MongoDB and Redis metrics
  4. Infrastructure Overview: CPU, memory, and network usage

πŸ”’ Security

  • JWT authentication with RS256 signing
  • Password hashing with bcrypt (cost factor: 12)
  • Docker container isolation for compilation
  • No network access for compilation containers
  • Rate limiting via Kong API Gateway
  • CORS configuration
  • Input validation and sanitization

🚒 Deployment

Docker Compose (Development/Testing)

docker-compose -f deployments/docker/docker-compose.yml up -d

Kubernetes (Production)

kubectl apply -f deployments/kubernetes/

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

πŸ“§ Contact

For questions or support, please open an issue on GitHub.


Built with ❀️ using Go, React, MongoDB, and Docker

About

LaTeX rendering system

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •