Skip to content
This repository was archived by the owner on Oct 10, 2025. It is now read-only.

Commit 34750e1

Browse files
committed
refactor: reorganize repo into infrastructure and application components
- Separate infrastructure (VM/server setup) from application (Docker/app config) - Move infrastructure files to infrastructure/ (cloud-init, terraform, tests, docs) - Move application files to application/ (compose, scripts, configs, docs) - Create distributed .gitignore files for each component - Add ADR-001 documenting Makefile location decision - Update all documentation and references to match new structure - Centralize port documentation in application/docs/firewall-requirements.md - Add TOML formatting conventions with .taplo.toml and VS Code settings - Update GitHub Actions workflow for new file paths - Validate all Makefile commands work after reorganization
1 parent 8a33e42 commit 34750e1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+2822
-1646
lines changed

.editorconfig

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# EditorConfig is awesome: https://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# All files
7+
[*]
8+
charset = utf-8
9+
end_of_line = lf
10+
insert_final_newline = true
11+
trim_trailing_whitespace = true
12+
13+
# TOML files
14+
[*.toml]
15+
indent_style = space
16+
indent_size = 2
17+
max_line_length = 100
18+
19+
# JSON files
20+
[*.json]
21+
indent_style = space
22+
indent_size = 2
23+
24+
# Markdown files
25+
[*.md]
26+
trim_trailing_whitespace = false
27+
max_line_length = 80
28+
29+
# YAML files
30+
[*.{yml,yaml}]
31+
indent_style = space
32+
indent_size = 2

.github/copilot-instructions.md

Lines changed: 82 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -27,31 +27,46 @@ torrust-tracker-demo/
2727
│ ├── workflows/ # GitHub Actions CI/CD pipelines
2828
│ └── copilot-instructions.md # This contributor guide
2929
├── docs/
30-
│ ├── infrastructure/ # Local testing documentation
31-
│ │ ├── quick-start.md # Fast setup guide
32-
│ │ ├── local-testing-setup.md # Detailed setup
33-
│ │ └── libvirt-setup.md # Troubleshooting guide
34-
│ ├── setup.md # Production deployment docs
35-
│ ├── deployment.md # Deployment procedures
36-
│ ├── firewall.md # Security configuration
37-
│ └── *.md # Additional operational docs
30+
│ ├── adr/ # Architecture Decision Records
31+
│ │ └── 001-makefile-location.md # Makefile location decision
32+
│ └── README.md # Cross-cutting documentation index
3833
├── infrastructure/ # Infrastructure as Code
3934
│ ├── terraform/ # OpenTofu/Terraform configurations
4035
│ │ ├── main.tf # VM and infrastructure definition
41-
│ │ └── local.tfvars # Local configuration (git-ignored)
36+
│ │ └── terraform.tfvars.example # Example configuration
4237
│ ├── cloud-init/ # VM provisioning templates
4338
│ │ ├── user-data.yaml.tpl # Main system configuration
4439
│ │ ├── user-data-minimal.yaml.tpl # Debug configuration
4540
│ │ ├── meta-data.yaml # VM metadata
4641
│ │ └── network-config.yaml # Network setup
47-
│ └── scripts/ # Infrastructure automation scripts
48-
├── share/
49-
│ ├── bin/ # Deployment and utility scripts
50-
│ └── container/default/config/ # Docker service configurations
51-
├── tests/infrastructure/ # Infrastructure validation tests
52-
├── compose.yaml # Docker Compose for services
42+
│ ├── scripts/ # Infrastructure automation scripts
43+
│ ├── tests/ # Infrastructure validation tests
44+
│ ├── docs/ # Infrastructure documentation
45+
│ │ ├── quick-start.md # Fast setup guide
46+
│ │ ├── local-testing-setup.md # Detailed setup
47+
│ │ ├── infrastructure-overview.md # Architecture overview
48+
│ │ ├── testing/ # Testing documentation
49+
│ │ └── third-party/ # Third-party setup guides
50+
│ ├── .gitignore # Infrastructure-specific ignores
51+
│ └── README.md # Infrastructure overview
52+
├── application/ # Application deployment and services
53+
│ ├── share/
54+
│ │ ├── bin/ # Deployment and utility scripts
55+
│ │ ├── container/ # Docker service configurations
56+
│ │ ├── dev/ # Development configs
57+
│ │ └── grafana/ # Grafana dashboards
58+
│ ├── docs/ # Application documentation
59+
│ │ ├── production-setup.md # Production deployment docs
60+
│ │ ├── deployment.md # Deployment procedures
61+
│ │ ├── firewall-requirements.md # Application firewall requirements
62+
│ │ ├── useful-commands.md # Operational commands
63+
│ │ └── media/ # Screenshots and diagrams
64+
│ ├── compose.yaml # Docker Compose for services
65+
│ ├── .env.production # Production environment template
66+
│ ├── .gitignore # Application-specific ignores
67+
│ └── README.md # Application overview
5368
├── Makefile # Main automation interface
54-
└── *.md # Project documentation
69+
└── *.md # Project root documentation
5570
```
5671

5772
### Key Components
@@ -61,25 +76,20 @@ torrust-tracker-demo/
6176
- **OpenTofu/Terraform**: Declarative infrastructure configuration
6277
- **Cloud-init**: Automated VM provisioning and setup
6378
- **Scripts**: Automation helpers for libvirt, monitoring, etc.
79+
- **Tests**: Infrastructure validation and integration tests
80+
- **Documentation**: Infrastructure-specific guides and references
6481

65-
#### 🐳 Docker Services (`compose.yaml`, `share/container/`)
66-
67-
- **Nginx**: Reverse proxy and SSL termination
68-
- **Grafana**: Metrics visualization and dashboards
69-
- **Prometheus**: Metrics collection and storage
70-
- **Certbot**: Automated SSL certificate management
82+
#### 🐳 Application Services (`application/`)
7183

72-
#### 🧪 Testing (`tests/infrastructure/`)
73-
74-
- **Validation scripts**: Ensure infrastructure works correctly
75-
- **Integration tests**: End-to-end deployment verification
76-
- **CI/CD pipelines**: Automated testing in GitHub Actions
84+
- **Docker Compose**: Service orchestration configuration
85+
- **Service Configs**: Nginx, Grafana, Prometheus configurations
86+
- **Deployment Scripts**: Application deployment and utility scripts
87+
- **Documentation**: Production setup, deployment, and operational guides
7788

7889
#### 📚 Documentation (`docs/`)
7990

80-
- **Production**: Setup, deployment, and operational guides
81-
- **Local testing**: Development and testing instructions
82-
- **Troubleshooting**: Common issues and solutions
91+
- **Cross-cutting**: Project-wide documentation and ADRs
92+
- **Architecture Decisions**: Documented design choices and rationale
8393

8494
## 🛠️ Development Workflow
8595

@@ -174,11 +184,22 @@ make test-syntax # Syntax validation only
174184
- **Links**: Prefer relative links for internal documentation
175185
- **Code blocks**: Always specify language for syntax highlighting
176186

187+
#### TOML Configuration Files
188+
189+
- **Formatting**: Use [Even Better TOML](https://marketplace.visualstudio.com/items?itemName=tamasfe.even-better-toml) extension for VS Code
190+
- **Style**: Blank lines between sections, 2-space indentation, preserve comments
191+
- **Configuration**: Project includes `.taplo.toml` and `.vscode/settings.json` for consistent formatting
192+
- **Key conventions**:
193+
- Blank line before each `[section]` and `[[array]]`
194+
- Detailed comments for port configurations
195+
- Preserve logical grouping and order
196+
- No automatic key reordering
197+
177198
#### Infrastructure as Code
178199

179200
- **Validation**: All Terraform/OpenTofu must pass `tofu validate`
180201
- **Planning**: Test with `tofu plan` before applying
181-
- **Variables**: Use `local.tfvars` for sensitive/local config (git-ignored)
202+
- **Variables**: Use `terraform.tfvars` for sensitive/local config (git-ignored)
182203
- **Templates**: Use `.tpl` extension for templated files
183204

184205
### Testing Requirements
@@ -200,8 +221,8 @@ make test-syntax # Syntax validation only
200221

201222
#### Secrets Management
202223

203-
- **SSH Keys**: Use template variables, store in `local.tfvars`
204-
- **Git Ignore**: All sensitive files must be in `.gitignore`
224+
- **SSH Keys**: Use template variables, store in `terraform.tfvars`
225+
- **Git Ignore**: Distributed `.gitignore` files in each component (root, infrastructure, application)
205226
- **Environment Variables**: Use environment variables for CI/CD secrets
206227
- **Review**: All security-related changes require review
207228

@@ -218,26 +239,49 @@ make test-syntax # Syntax validation only
218239

219240
1. **Read the documentation**:
220241

221-
- [Quick Start Guide](../docs/infrastructure/quick-start.md)
222-
- [Complete Setup Guide](../docs/infrastructure/local-testing-setup.md)
242+
- [Quick Start Guide](../infrastructure/docs/quick-start.md)
243+
- [Complete Setup Guide](../infrastructure/docs/local-testing-setup.md)
244+
- [Production Setup Guide](../application/docs/production-setup.md)
223245

224-
2. **Set up your environment**:
246+
2. **Set up your development environment**:
225247

226248
```bash
227249
make install-deps # Install dependencies
228250
make setup-ssh-key # Configure SSH access
229251
make test-prereq # Verify setup
230252
```
231253

232-
3. **Test a simple change**:
254+
3. **Install recommended VS Code extensions**:
255+
256+
- **[Even Better TOML](https://marketplace.visualstudio.com/items?itemName=tamasfe.even-better-toml)** - TOML syntax highlighting and formatting
257+
- **[ShellCheck](https://marketplace.visualstudio.com/items?itemName=timonwong.shellcheck)** - Shell script linting
258+
- **[YAML](https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml)** - YAML support with schema validation
259+
- **[markdownlint](https://marketplace.visualstudio.com/items?itemName=DavidAnson.vscode-markdownlint)** - Markdown linting
260+
- **[HashiCorp Terraform](https://marketplace.visualstudio.com/items?itemName=HashiCorp.terraform)** - Terraform/OpenTofu support
261+
262+
4. **Configure VS Code workspace**:
263+
264+
- Project includes `.vscode/settings.json` with TOML formatting configuration
265+
- Extensions will use project-specific settings automatically
266+
- Reload VS Code after installing extensions for settings to take effect
267+
268+
5. **TOML Formatting Setup**:
269+
270+
- **Configuration files**: `.taplo.toml` and `.vscode/settings.json` control formatting
271+
- **Format on save**: TOML files auto-format when saved (`Ctrl+S`)
272+
- **Manual format**: Use `Shift+Alt+F` (Windows/Linux) or `Shift+Option+F` (Mac)
273+
- **Style**: Blank lines between sections, 2-space indentation, preserved comments
274+
- **Reload required**: After changing settings, reload VS Code window (`Ctrl+Shift+P` → "Developer: Reload Window")
275+
276+
6. **Test a simple change**:
233277

234278
```bash
235279
make apply # Deploy test VM
236280
make ssh # Verify access
237281
make destroy # Clean up
238282
```
239283

240-
4. **Review existing issues**: Check [GitHub Issues](https://github.com/torrust/torrust-tracker-demo/issues) for good first contributions
284+
7. **Review existing issues**: Check [GitHub Issues](https://github.com/torrust/torrust-tracker-demo/issues) for good first contributions
241285

242286
### For Infrastructure Changes
243287

.github/workflows/infrastructure.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ on:
55
branches: [main, develop]
66
paths:
77
- "infrastructure/**"
8-
- "tests/infrastructure/**"
8+
- "infrastructure/tests/**"
99
- "Makefile"
1010
- ".github/workflows/infrastructure.yml"
1111
pull_request:
1212
branches: [main, develop]
1313
paths:
1414
- "infrastructure/**"
15-
- "tests/infrastructure/**"
15+
- "infrastructure/tests/**"
1616
- "Makefile"
1717
- ".github/workflows/infrastructure.yml"
1818

@@ -39,8 +39,8 @@ jobs:
3939
4040
- name: Test script permissions
4141
run: |
42-
test -x tests/infrastructure/test-local-setup.sh
43-
test -x tests/infrastructure/test-integration.sh
42+
test -x infrastructure/tests/test-local-setup.sh
43+
test -x infrastructure/tests/test-integration.sh
4444
4545
- name: Run syntax tests
4646
env:
@@ -65,11 +65,12 @@ jobs:
6565
- name: Check documentation links
6666
run: |
6767
# Verify documentation files exist
68-
test -f docs/infrastructure/quick-start.md
69-
test -f docs/infrastructure/local-testing-setup.md
68+
test -f infrastructure/docs/quick-start.md
69+
test -f infrastructure/docs/local-testing-setup.md
7070
test -f infrastructure/README.md
71+
test -f application/README.md
7172
7273
# Check for common documentation issues
73-
grep -q "Quick Start" docs/infrastructure/quick-start.md
74-
grep -q "OpenTofu" docs/infrastructure/local-testing-setup.md
74+
grep -q "Quick Start" infrastructure/docs/quick-start.md
75+
grep -q "OpenTofu" infrastructure/docs/local-testing-setup.md
7576
grep -q "make" README.md

.gitignore

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1-
.env
1+
# Project-level gitignore - cross-cutting files only
2+
# Specific ignores are in infrastructure/.gitignore and application/.gitignore
3+
4+
# Repository organization tool output
25
repomix-output.xml
3-
storage/
6+
7+
# Note: This repository uses distributed .gitignore files:
8+
# - infrastructure/.gitignore: Infrastructure-specific files (Terraform, VMs, etc.)
9+
# - application/.gitignore: Application-specific files (Docker, logs, data, etc.)
10+
# - .gitignore (this file): Project-wide cross-cutting files only

.taplo.toml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Taplo (Even Better TOML) configuration
2+
# This configures the TOML formatter for this project
3+
[formatting]
4+
# Column width for wrapping
5+
column_width = 100
6+
# Indentation (2 spaces)
7+
indent_string = " "
8+
# Alignment and spacing
9+
align_entries = false
10+
align_comments = true
11+
indent_tables = false
12+
indent_entries = false
13+
# Compact settings - set to false to preserve spacing
14+
compact_arrays = false
15+
compact_inline_tables = false
16+
compact_entries = false
17+
# Array formatting
18+
array_trailing_comma = true
19+
array_auto_expand = true
20+
array_auto_collapse = false
21+
# Inline table settings
22+
inline_table_expand = true
23+
# Blank lines - allow up to 2 consecutive blank lines
24+
allowed_blank_lines = 2
25+
# Preserve key/array order (don't reorder across blank lines)
26+
reorder_keys = false
27+
reorder_arrays = false
28+
reorder_inline_tables = false
29+
# Line endings and trailing newline
30+
trailing_newline = true
31+
crlf = false

.vscode/settings.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
// Even Better TOML formatter configuration (camelCase for VS Code)
3+
"evenBetterToml.formatter.columnWidth": 100,
4+
"evenBetterToml.formatter.indentString": " ",
5+
"evenBetterToml.formatter.alignEntries": false,
6+
"evenBetterToml.formatter.alignComments": true,
7+
"evenBetterToml.formatter.indentTables": false,
8+
"evenBetterToml.formatter.indentEntries": false,
9+
"evenBetterToml.formatter.compactArrays": false,
10+
"evenBetterToml.formatter.compactInlineTables": false,
11+
"evenBetterToml.formatter.compactEntries": false,
12+
"evenBetterToml.formatter.arrayTrailingComma": true,
13+
"evenBetterToml.formatter.arrayAutoExpand": true,
14+
"evenBetterToml.formatter.arrayAutoCollapse": false,
15+
"evenBetterToml.formatter.inlineTableExpand": true,
16+
"evenBetterToml.formatter.allowedBlankLines": 2,
17+
"evenBetterToml.formatter.reorderKeys": false,
18+
"evenBetterToml.formatter.reorderArrays": false,
19+
"evenBetterToml.formatter.reorderInlineTables": false,
20+
"evenBetterToml.formatter.trailingNewline": true,
21+
"evenBetterToml.formatter.crlf": false,
22+
// Format on save for TOML files
23+
"[toml]": {
24+
"editor.formatOnSave": true,
25+
"editor.defaultFormatter": "tamasfe.even-better-toml"
26+
}
27+
}

MAKEFILE_TESTING_TODO.md

Whitespace-only changes.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Default variables
55
VM_NAME ?= torrust-tracker-demo
66
TERRAFORM_DIR = infrastructure/terraform
7-
TESTS_DIR = tests/infrastructure
7+
TESTS_DIR = infrastructure/tests
88

99
# Help target
1010
help: ## Show this help message

0 commit comments

Comments
 (0)