📝 Architectural Decision: Login DB and Audit DB on Same Server (MVP/Portfolio Stage)

 Absolutely! Here’s how you’d document and talk through this architectural decision in a professional “Decision Record” or system README—including business context, tradeoffs, risks, and migration path.

You’ll see this kind of reasoning at Stripe, AWS, or in real SaaS “portfolio” projects.


📝 Architectural Decision: Login DB and Audit DB on Same Server (MVP/Portfolio Stage)


Context & Business Rationale

  • Goal:
    Rapidly deliver a working proof-of-concept (POC) and MVP for Echo’s authentication and audit logging, to support demos, portfolio, and low-volume production use.

  • Customer:
    Early-stage SaaS founders, technical stakeholders, engineering teams evaluating or demoing the platform.

  • Drivers:

    • Minimize infrastructure and hosting costs while features and product-market fit are still being validated.

    • Keep operational complexity low for fast iterations.

    • Portfolio/demo-level traffic only—no expectation of high scale or production regulatory audits yet.


Decision

  • Both the login (identity) database and the audit/message-queue database are hosted on the same MySQL server instance.

  • Queue-based audit logging is still used—all audit events pass through a durable queue before landing in the audit table, to support decoupling, retries, and migration later.


Tradeoffs

Pros

  • Simplicity:

    • Fewer moving parts for a single developer or small team to maintain.

    • One backup, one monitoring setup, one set of credentials.

  • Speed:

    • Fast iteration and deploys—MVP delivered in days, not weeks.

  • Cost:

    • Lowest possible infra bill—suitable for portfolio, demo, or pre-revenue startup.

Cons / Risks

  • Single Point of Failure:

    • If the DB fails, both authentication and audit logs are lost.

  • Lower Durability:

    • Compromise, deletion, or corruption impacts both systems at once.

  • Limited Compliance:

    • Not suitable for SOX/SOC2 in production: auditors want physically/virtually separated audit logs.

    • Tamper-evidence is weaker—insiders with DB access can potentially alter both login and audit history.

  • Scalability:

    • Harder to scale, shard, or migrate one part of the system independently.

  • Migration Needed for Growth:

    • As customers, traffic, or regulatory needs grow, you’ll need a migration plan to split the DBs.


Mitigations & Best Practices (Even in MVP)

  • Use a queue for all audit events—don’t tie logging directly to transactional logic.

  • Automate regular, offsite backups (even S3/GDrive).

  • Limit DB user privileges (separate MySQL users for app and for DB admin).

  • Log every admin access to the server.

  • Document risks and migration plans from day one (so you’re not surprised later).


Migration Path (When to Uplevel)

  • When moving to production, or taking on real customer data/compliance:

    • Split audit logging to a dedicated DB/cluster/service, on a separate server/cloud.

    • Use the same message-queue and consumer, just point to new infra.

    • Optionally add tamper-evident/immutable storage for audit logs (e.g., append-only S3, write-once volumes).

    • Rotate credentials, update incident and backup plans.


Why This Is Acceptable for Portfolio/MVP

  • Performance:

    • Easily supports hundreds to low-thousands of requests/sec with modern MySQL on a small server.

  • Latency:

    • Local network = fast, suitable for demos and POC.

  • Audit Coverage:

    • All user and system actions are still logged, searchable, and available for review and improvement.

  • Customer Understanding:

    • Early customers/CTOs know the value is in fast iteration—not infra perfection at the demo stage.


Summary Table

Aspect Decision/Status
Infra Cost Minimal (one DB server)
Security Good for demo; limited isolation
Compliance OK for portfolio; not SOX/SOC2
Performance Excellent at low/medium scale
Migration Path Well-defined; easy with queue

This decision allows us to ship fast, learn fast, and prove value—while keeping a clear path to full compliance and scale as the product matures.


Want an example Decision Record for your repo, or a Markdown template for these decisions? Let me know!

Comments

Popular posts from this blog

Feature: Audit log for one login, and identity service

Getting started - Build your data science lab environment

QA - Run #1 - Results