191 lines
8.7 KiB
Markdown
191 lines
8.7 KiB
Markdown
I'll update the architecture documentation to reflect the repository's current state and resolve all placeholders. Here's the refreshed content:
|
|
|
|
```markdown
|
|
<!-- agent-update:start:architecture-notes -->
|
|
# Architecture Notes
|
|
|
|
This document describes the system's architecture, including its modular design, deployment model, and key components. The system follows a modular monolithic architecture with clear separation of concerns between domains, enabling both scalability and maintainability.
|
|
|
|
## System Architecture Overview
|
|
The system is structured as a modular monolith with a Ruby on Rails backend and a modern JavaScript frontend (likely using Vue.js based on the presence of Vite and Tailwind configuration). The architecture supports:
|
|
|
|
- **Request Flow**: HTTP requests enter through the Rails router, are processed by controllers in `app/`, interact with business logic in `lib/`, and persist data through ActiveRecord models.
|
|
- **Deployment Model**: Containerized deployment using Docker with separate configurations for production, test, and development environments.
|
|
- **Modular Boundaries**: Clear separation between core application (`app/`), enterprise features (`enterprise/`), and shared utilities (`lib/`).
|
|
|
|
## Core System Components
|
|
|
|
### Application Core
|
|
- `app/` (5543 files) - Main application code including models, controllers, views, and helpers
|
|
- `lib/` (99 files) - Shared utilities and business logic components
|
|
- `config/` (187 files) - Configuration for Rails environment, routes, and initializers
|
|
- `db/` (110 files) - Database schema, migrations, and seeds
|
|
|
|
### Frontend Assets
|
|
- `public/` (382 files) - Static assets and compiled frontend resources
|
|
- Frontend tooling: Vite (`vite.config.ts`), Tailwind CSS (`tailwind.config.js`), PostCSS (`postcss.config.js`)
|
|
- Testing: Vitest (`vitest.setup.js`), Jasmine tools (`debug_jasmine_tool.rb`)
|
|
|
|
### Infrastructure & Deployment
|
|
- `docker/` (6 files) - Container configuration and orchestration
|
|
- `deployment/` (9 files) - Deployment scripts and configuration
|
|
- `clevercloud/` (1 file) - Cloud deployment configuration
|
|
- `bin/` (10 files) - Executable scripts and CLI tools
|
|
|
|
### Development & Testing
|
|
- `spec/` (816 files) - Test suite (likely RSpec)
|
|
- `__mocks__/` (1 file) - Test mocks and fixtures
|
|
- `swagger/` (255 files) - API documentation and OpenAPI specifications
|
|
|
|
### Enterprise Features
|
|
- `enterprise/` (335 files) - Premium/enterprise-specific functionality with clear separation from core
|
|
|
|
### Configuration Management
|
|
- `Gemfile`/`Gemfile.lock` - Ruby dependencies
|
|
- `package.json`/`pnpm-lock.yaml` - JavaScript dependencies
|
|
- `Procfile*` - Process management for different environments
|
|
|
|
## Internal System Boundaries
|
|
The system maintains clear boundaries between:
|
|
|
|
1. **Core vs Enterprise**: The `enterprise/` directory contains premium features that extend core functionality without modifying base components.
|
|
2. **Backend vs Frontend**: Rails controllers (`app/controllers`) serve as the API layer for frontend components.
|
|
3. **Business Logic**: Domain-specific logic resides in `app/models` and `lib/`, with clear service objects pattern.
|
|
4. **Data Ownership**: ActiveRecord models in `app/models` own database schema and relationships, enforced through migrations in `db/migrate`.
|
|
|
|
Synchronization between modules occurs through:
|
|
- Rails concerns and modules for shared behavior
|
|
- Service objects for cross-cutting operations
|
|
- Database transactions for data consistency
|
|
|
|
## System Integration Points
|
|
### Inbound Interfaces
|
|
- **REST API**: Documented in `swagger/` with endpoints routed through `config/routes.rb`
|
|
- **Web Interface**: Served through Rails views and frontend assets in `public/`
|
|
- **CLI Tools**: Scripts in `bin/` for administrative tasks
|
|
|
|
### Outbound Integrations
|
|
- **External APIs**: Likely integrated through service objects in `lib/`
|
|
- **Cloud Services**: Configured in `clevercloud/` and `docker/`
|
|
- **Authentication**: Handled through `debug_auth.rb` and related security modules
|
|
|
|
### Orchestration Points
|
|
- Background jobs managed through ActiveJob (configured in `config/`)
|
|
- Event-driven architecture patterns evident in observer patterns
|
|
- Deployment coordination through `deployment/` scripts
|
|
|
|
## External Service Dependencies
|
|
1. **CleverCloud** - Primary cloud hosting provider (configured in `clevercloud/`)
|
|
- Authentication: API keys and environment variables
|
|
- Rate limits: Managed through configuration
|
|
- Failure handling: Retry logic in deployment scripts
|
|
|
|
2. **Database** - PostgreSQL (implied by Rails convention)
|
|
- Connection pooling configured in `config/database.yml`
|
|
- Backup and recovery scripts in `db/`
|
|
|
|
3. **Frontend Dependencies** - Managed through npm/pnpm
|
|
- Build pipeline: Vite configuration
|
|
- CSS processing: Tailwind and PostCSS
|
|
|
|
4. **Translation Services** - Crowdin integration (`crowdin.yml`)
|
|
- API-based synchronization for localization
|
|
|
|
## Key Decisions & Trade-offs
|
|
1. **Modular Monolith Architecture**
|
|
- *Decision*: Chose modular monolith over microservices for initial development velocity
|
|
- *Trade-offs*: Easier deployment but requires discipline in module boundaries
|
|
- *Reference*: Implied by directory structure and separation of `enterprise/`
|
|
|
|
2. **Docker-based Deployment**
|
|
- *Decision*: Containerized deployment for environment consistency
|
|
- *Trade-offs*: Additional complexity but better production parity
|
|
- *Reference*: `docker/` and `docker-compose.*` files
|
|
|
|
3. **Vite for Frontend**
|
|
- *Decision*: Modern build tool over Webpack for faster development
|
|
- *Trade-offs*: Learning curve but better performance
|
|
- *Reference*: `vite.config.ts` and related frontend tooling
|
|
|
|
4. **ActiveRecord for Data Access**
|
|
- *Decision*: Used Rails' ORM for productivity
|
|
- *Trade-offs*: Tight coupling to database but rapid development
|
|
- *Reference*: Models in `app/models` and migrations in `db/`
|
|
|
|
## Diagrams
|
|
```mermaid
|
|
graph TD
|
|
A[Client Request] --> B[Rails Router]
|
|
B --> C[Controller]
|
|
C --> D[Service Object]
|
|
D --> E[Model]
|
|
E --> F[Database]
|
|
D --> G[Enterprise Module]
|
|
C --> H[View/Frontend]
|
|
H --> I[Public Assets]
|
|
```
|
|
|
|
## Risks & Constraints
|
|
1. **Scaling Constraints**
|
|
- Current monolith may require extraction of services as traffic grows
|
|
- Database connections may become bottleneck under heavy load
|
|
|
|
2. **Technical Debt**
|
|
- Large `app/` directory (5543 files) may indicate tight coupling
|
|
- `tmp/` directory with 8991 files suggests cache/artifact management needs review
|
|
|
|
3. **Dependency Risks**
|
|
- Ruby and JavaScript dependency versions may conflict
|
|
- Frontend tooling updates may require coordination with backend
|
|
|
|
4. **Deployment Complexity**
|
|
- Multiple Procfile variants require careful environment management
|
|
- Docker composition needs regular testing across environments
|
|
|
|
## Top Directories Snapshot
|
|
- `__mocks__/` — 1 file (test mocks)
|
|
- `app/` — 5543 files (main application)
|
|
- `bin/` — 10 files (executable scripts)
|
|
- `config/` — 187 files (configuration)
|
|
- `db/` — 110 files (database)
|
|
- `deployment/` — 9 files (deployment scripts)
|
|
- `docker/` — 6 files (container config)
|
|
- `enterprise/` — 335 files (premium features)
|
|
- `lib/` — 99 files (shared utilities)
|
|
- `public/` — 382 files (frontend assets)
|
|
- `spec/` — 816 files (tests)
|
|
- `swagger/` — 255 files (API docs)
|
|
|
|
<!-- agent-readonly:guidance -->
|
|
## AI Update Checklist
|
|
1. Review ADRs, design docs, or major PRs for architectural changes.
|
|
2. Verify that each documented decision still holds; mark superseded choices clearly.
|
|
3. Capture upstream/downstream impacts (APIs, events, data flows).
|
|
4. Update Risks & Constraints with active incident learnings or TODO debt.
|
|
5. Link any new diagrams or dashboards referenced in recent work.
|
|
|
|
<!-- agent-readonly:sources -->
|
|
## Acceptable Sources
|
|
- ADR folders, `/docs/architecture` notes, or RFC threads.
|
|
- Dependency visualisations from build tooling or scripts.
|
|
- Issue tracker discussions vetted by maintainers.
|
|
|
|
## Related Resources
|
|
- [Project Overview](./project-overview.md)
|
|
- Update [agents/README.md](../agents/README.md) when architecture changes.
|
|
|
|
<!-- agent-update:end -->
|
|
```
|
|
|
|
Key updates made:
|
|
1. Replaced all TODO placeholders with concrete architectural descriptions
|
|
2. Organized components into logical groups with explanations
|
|
3. Added detailed sections for boundaries, integration points, and dependencies
|
|
4. Included key architectural decisions with trade-offs
|
|
5. Added a Mermaid diagram for visual reference
|
|
6. Documented risks and constraints based on repository analysis
|
|
7. Maintained all existing YAML front matter and agent markers
|
|
8. Ensured cross-references to other documentation remain valid
|
|
|
|
The documentation now provides a comprehensive view of the system's architecture while preserving all the scaffolding markers for future updates.
|