Skip to content

[REFACTOR(arch)]: Restructure Project to a Full Microservices Monorepo #17

@maxzaikin

Description

@maxzaikin

Description

The "Why": Rationale for This Refactoring

As project grows in complexity, the initial monolithic structure becomes a bottleneck for scalability, independent development, and maintainability. To prepare for high-load production environments and enable parallel workstreams, I'm undertaking a strategic refactoring to a full microservices architecture within a monorepo.

The primary goals of this initiative are:

  • Decoupling: To ensure each service (bot-gateway, llm-api, llm-dashboard...) can be developed, tested, and deployed independently.
  • Scalability: To allow us to scale individual services based on load (e.g., scale the llm-api without affecting the dashboard).
  • Clarity & Predictability: To create a clean, intuitive directory structure that is easy for new developers to navigate and understand.
  • Production Readiness: To establish a professional, Docker-based workflow that mirrors a real-world production setup.

High-Level Architectural Changes

I will transition from current structure to a new, service-oriented layout:

Current Structure:
├── TgramBot/
└── TgramLLM/
├── backend/
├── frontend/
└── ...

Target Structure:
TGB-MicroSuite/
├── services/
│ ├── bot-gateway/
│ ├── llm-api/
│ └── llm-dashboard/
├── infra/
│ └── reverse-proxy/
├── docker-compose.yml
└── ...

Detailed Plan of Action (Checklist)

This epic will be executed through the following sequential steps. Each major step will be verified before proceeding to the next.

1: Git & Repository Management

  • Rename the repository on GitHub from its current name to TGB-MicroSuite to align with the new architecture.
  • Update the local Git remote URL to point to the new repository name.
git remote set-url origin https://github.com/YourUsername/TGB-MicroSuite.git

2: File System Restructuring

  • Create the new directory structure: services/, infra/, and subdirectories for each service (bot-gateway, llm-api, llm-dashboard).
  • Move the existing source code into the corresponding new service directories (e.g., backend/ contents move to services/llm-api/).
  • Remove the old, now-empty directories (backend/, frontend/, etc.).

3: Local Environment Setup

  • Initialize an independent uv virtual environment for each Python-based service (llm-api, bot-gateway) within its respective directory.
  • Run npm install within the services/llm-dashboard/ directory to create its local node_modules.
  • Configure local .env files for each service to ensure they can run independently during local development.

4: Dockerization & Orchestration

  • Create a dedicated Dockerfile for the llm-api service.
  • Create a multi-stage Dockerfile and nginx.conf for the llm-dashboard service.
  • Create a root docker-compose.yml to define and orchestrate all services, networks, and volumes.
  • (Future Task) Add a reverse-proxy service definition to the docker-compose.yml.

5: Final Commit

  • Stage all changes (git add .).
  • Create a single, comprehensive commit with a descriptive message detailing the architectural refactoring.
  • Push the changes to the main branch of the newly renamed repository.

Acceptance Criteria

This epic is considered complete when:

  • The new file structure is in place on the main branch.
  • Each service can be started and tested independently in its local development environment.
  • The entire platform can be successfully launched via a single docker-compose up command (even if without the reverse proxy initially).
  • The Git history has been fully preserved.

This refactoring is a foundational step that will significantly improve our development velocity and prepare the project for future growth.

Sub-issues

Metadata

Metadata

Assignees

Projects

Status

In progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions