RocketMainta documentation

Architecture

RocketMainta is a classic server-rendered application: one Go process serves the HTML pages, the JSON API and the static assets, and MySQL/MariaDB holds the state.

        browser / mobile / third-party client
                       │  HTTP
        ┌──────────────▼───────────────────────────┐
        │  cmd/server/main.go                      │
        │  recover → logger → helmet → etag → gzip │
        │  → static → locale → session → CSRF      │
        ├──────────────────────────────────────────┤
        │  internal/app                             │
        │   routes.go      171 routes             │
        │   mw.go          session, CSRF, guards    │
        │   handler_*.go   public/auth/dashboard/   │
        │                  pay/admin/api/chat      │
        │   render.go      html/template renderer  │
        │   views.go       template helpers         │
        ├──────────────────────────────────────────┤
        │  internal/auth   bcrypt · JWT · TOTP      │
        │  internal/paygate  44 gateways + drivers │
        │  internal/notify    SMTP · SMS · log      │
        │  internal/i18n      DB-backed translator │
        │  internal/pdf        invoice writer      │
        └──────────────┬───────────────────────────┘
                       │  database/sql
        ┌──────────────▼───────────────────────────┐
        │  internal/store  schema · migrations · seed│
        │  MySQL 8 / MariaDB 10.6+ (53 tables)      │
        └──────────────────────────────────────────┘

Request lifecycle

  1. Recover turns a panic into a 500 without killing the process.
  2. Logger writes one line per request with the method, path, status and duration.
  3. Helmet / ETag / Gzip add the usual security and caching headers.
  4. Static serves web/static under /static with an ETag and a one-hour cache.
  5. Locale picks the language from the ?lang= query, the rm_locale cookie, the

Accept-Language header and finally the default language. It also sets the text direction.

  1. Session reads the rm_session cookie (or an Authorization: Bearer header for the API),

verifies the JWT, compares the embedded token_version with the users.token_version column and loads the user. A banned or re-roled account therefore loses its session immediately.

  1. CSRF issues a token in the rm_csrf cookie and validates the _csrf field on every

POST/PUT/PATCH/DELETE. The API and the gateway webhooks are exempt.

  1. The router dispatches to the handler; the renderer renders

web/templates/<section>/<page>.html inside the matching layout.

Rendering

internal/app/render.go implements a small renderer instead of using Fiber's view engine:

make t.New("layout") return a detached copy and the partials would never be attached;

page template is added under the name content;

Adding a page therefore only means dropping a file into web/templates/<section>/.

Data model

53 tables, created by an idempotent embedded schema (internal/store/schema.sql):

AreaTables
Identityusers, roles, permissions, role_permission, user_role, password_resets, verification_codes, twofa_challenges, login_attempts, social_accounts
Cataloguecategories, services, service_options, device_models, brands, technician_slots
Ordersorders, order_items, order_status_histories, reviews, coupons
Moneypayment_gateways, payments, manual_payments, invoices
Supporttickets, ticket_messages, live_chats, chat_messages, contact_messages
Contentpages, sections, faqs, posts, post_categories, post_post_category
Platformsettings, languages, translations, email_templates, sms_templates, sms_providers, notification_events, notification_log, notifications, extensions, audit_logs, gdpr_consents, subscribers, sitemaps, server_metrics

The schema uses portable MySQL/MariaDB SQL (CREATE TABLE IF NOT EXISTS, COALESCE instead of ISNULL, no vendor-specific functions) so it runs on both engines.

Seeding

internal/store/seed.go fills a fresh database with a realistic demo shop:

Every insert uses INSERT IGNORE, so seeding is idempotent and safe to re-run.

Security

ConcernMitigation
Password storagebcrypt with a per-password salt
Session forgeryHS256 JWT + a token_version column checked on every request
CSRFPer-session token, required on every state-changing form
Brute forceLogin throttling per IP and per e-mail address, plus an arithmetic CAPTCHA on registration
Privilege escalationRole guards on the admin group, ownership checks on customer resources
Input validationEvery write goes through explicit validation with field-level error messages
Auditabilityaudit_logs records the actor, the action, the entity and the IP
Privacygdpr_consents table, data export and deletion requests in the customer area

Payments

internal/paygate/registry.go is the single source of truth for the gateway catalogue. Each gateway declares its driver, currency, fee, artwork and the credential fields the admin panel has to render. DriverFor maps a gateway to its implementation:

A gateway without credentials falls back to the sandbox simulator, so the complete order → pay → confirm flow is always reachable. The webhook route /pay/webhook/:code verifies the signature before a payment is marked as paid.