This guide provides instructions for setting up your development environment and working with the TG_ERP microservices architecture.
- Development Environment Setup
- Project Structure
- Microservices Architecture
- Telegram Integration
- Database Configuration
- Message Broker Setup
- Testing Guidelines
- CI/CD Pipeline
- Git
- Docker and Docker Compose
- Node.js (v18 or later)
- npm or yarn
- Telegram Bot API credentials
-
Clone the repository
git clone https://github.com/your-organization/tg-erp.git cd tg-erp -
Install dependencies
# Install root-level dependencies npm install # Install service-specific dependencies cd services/auth-service npm install # Repeat for other services
-
Environment Configuration
Copy the example environment files:
cp .env.example .env
Update the
.envfile with your specific configurations, including:- Database connection strings
- Telegram Bot API credentials
- Service ports
- Message broker connection details
-
Start the development environment
# From the root directory cd docker docker-compose up
This will start all required services:
- API Gateway
- Microservices (Auth, Org Structure, etc.)
- Databases (PostgreSQL, MongoDB, Neo4j, InfluxDB)
- Message Broker (Kafka/RabbitMQ)
-
Run the services in development mode for hot-reloading:
# Start a specific service in development mode cd services/auth-service npm run dev
-
Access the API Gateway at
http://localhost:3000 -
Use the Telegram Bot by messaging the bot you've configured
tg-erp/
├── services/ # Microservices
│ ├── api-gateway/ # API Gateway service
│ ├── auth-service/ # Authentication service
│ ├── org-service/ # Organization structure service
│ ├── communication-service/ # Communication service
│ ├── project-service/ # Project and meeting service
│ └── workplace-service/ # Document and file management service
├── docs/ # Documentation
├── docker/ # Docker configurations
│ ├── docker-compose.yml # Main composition file
│ └── */ # Service-specific Docker configurations
├── scripts/ # Utility scripts
└── ...
Each service follows a standard structure:
service-name/
├── src/ # Source code
│ ├── controllers/ # Request handlers
│ ├── services/ # Business logic
│ ├── models/ # Data models
│ ├── middleware/ # Middleware functions
│ ├── routes/ # API routes
│ ├── utils/ # Utility functions
│ ├── events/ # Event handlers for message broker
│ └── index.ts # Entry point
├── tests/ # Test files
├── Dockerfile # Docker configuration
├── package.json # Dependencies and scripts
└── tsconfig.json # TypeScript configuration
TG_ERP follows a microservices architecture with these key components:
- Routes requests to appropriate services
- Handles authentication and authorization
- Manages rate limiting and logging
- Aggregates responses when needed
- Handles user registration via Telegram ID
- Manages authentication and JWT generation
- Implements two-factor authentication via Telegram
- Controls access through role-based permissions
- Maintains organizational hierarchy and relationships
- Supports multiple organizational models (hierarchy, holons, matrix, tribes)
- Provides personalized views based on user context
- Manages notification delivery
- Creates temporary meeting channels
- Handles chat-based communications
- Schedules and manages meetings
- Provides calendar functionality
- Tracks agendas and action items
- Enables collaborative document editing
- Manages file storage and version control
- Implements check-in functionality
- Create a Telegram Bot through BotFather
- Configure your bot token in the
.envfile - Implement webhook handling for bot commands
- Configure your bot to use Web Apps
- Implement Web App interfaces using HTML/CSS/JS
- Connect Web Apps to the backend services
TG_ERP uses multiple database technologies:
Used for structured, transactional data:
- User accounts and authentication
- Meeting and project data
- Core business entities
Used for document storage:
- Collaborative documents
- File metadata
- Unstructured content
Used for graph relationships:
- Organizational structure
- User relationships and permissions
- Complex hierarchical data
Used for time-series data:
- System metrics
- User activity logs
- Performance monitoring
TG_ERP uses a message broker for asynchronous communication between services:
- Configure connection settings in
.env - Define topics/queues for different event types
- Implement producers and consumers in each service
user.registered: New user registrationmeeting.created: New meeting creationdocument.updated: Document updatesnotification.created: New notification
- Write unit tests for all business logic
- Use Jest as the testing framework
- Aim for high test coverage
- Test service interactions
- Use a test message broker
- Configure test databases
- Test complete user workflows
- Simulate Telegram Bot interactions
- Use Cypress for UI testing
The CI/CD pipeline is configured using GitHub Actions:
- Runs on each push and pull request
- Executes linting and unit tests
- Builds Docker images
- Development environment: Local WSL for development and testing
- Staging environment: Hetzner Cloud VPS (deployed on merge to develop branch)
- Production environment: Hetzner Cloud VPS (deployed on merge to main branch)
- Deployment strategy: Docker-compose based deployment via SSH
- Includes database migrations and environment configuration
┌─────────────────┐ ┌───────────────────┐ ┌───────────────────┐
│ Local Dev (WSL)│ │ Staging (Hetzner)│ │ Production (Hetzner)│
│ │ │ │ │ │
│ Docker Compose │────▶│ Docker Compose │────▶│ Docker Compose │
│ All Services │ │ All Services │ │ All Services │
└─────────────────┘ └───────────────────┘ └───────────────────┘
│ │ │
▼ ▼ ▼
┌─────────────────┐ ┌───────────────────┐ ┌───────────────────┐
│ Local Databases │ │ Staging Databases │ │ Prod Databases │
│ & Message Broker│ │ & Message Broker │ │ & Message Broker │
└─────────────────┘ └───────────────────┘ └───────────────────┘
- Collects logs and metrics
- Alerts on service disruptions
- Provides performance dashboards