Why MongoDB Is Our Primary Database (and Why It May Fit Yours Too)
MongoDB fits QuotyAI's dynamic business data, but flexible schemas still need validation, transactions, indexes, and an exit plan. Here are the current limits and tradeoffs.
I built QuotyAI because I was tired of AI that guesses and tools that underdeliver. A system can aim for reliable behavior, but it still needs validation, tests, and bounded claims.
When your product stores AI-generated business rules, the database is part of the product architecture. For QuotyAI, MongoDB fit the shape of the data. It was not the only possible choice, and it was not a shortcut around data modeling.
“You don’t need the perfect database. You need the right one for your current constraints—and a plan for when those constraints change.”
The Decision Matrix
I considered PostgreSQL, SurrealDB, and MongoDB.
PostgreSQL was the safe default: joins, constraints, mature tooling, and transactions. I built an early prototype on it. My problem was not that PostgreSQL cannot store JSON. It was that our product’s evolving, customer-specific configuration kept producing schema changes I did not want to manage as table migrations.
SurrealDB was technically interesting. I removed the old “1,200 open issues” and pricing claims because they were undated and not independently verified. The durable concern was operational familiarity: as a solo founder, I preferred a database I could reason about and recover without becoming its first production debugger.
MongoDB passed the criteria that mattered to this product:
- One person can operate it.
- Optional, customer-specific fields can evolve without
ALTER TABLE. - Nested business configuration can live in one document when that is the right model.
- The driver and hosting ecosystem are mature enough for our needs.
That does not make MongoDB the only viable database. PostgreSQL with JSONB, or a hybrid design, could also work with different modeling and migration choices.
What We Actually Store
QuotyAI turns a rule like “rooms are $50/night, $20 cleaning, 10% off over seven nights” into a pricing function:
function calculatePrice(nights: number): number {
const base = nights * 50;
const cleaning = 20;
const discount = nights >= 7 ? 0.1 : 0;
return (base + cleaning) * (1 - discount);
}
We store generated code, schemas, tests, and release context. The exact artifact layout has changed since the original April 2026 post.
Here is the current BusinessEntity shape from the repository:
const BusinessEntitySchema = z.object({
_id: MongoDbIdParamSchema,
tenantId: MongoDbIdParamSchema,
name: z.string(),
primaryIndustry: IndustrySchema,
secondaryIndustries: z.array(IndustrySchema).optional(),
currency: CurrencySchema.optional(),
timezone: z.string().optional(),
customAttributes: z.record(z.string(), z.unknown()).optional(),
codeBase: BusinessCodeBaseHeadSchema.optional(),
skillsPrimaryLanguageCode: SkillLanguageSchema,
skillsSecondaryLanguageCodes: z.array(SkillLanguageSchema).optional(),
createdAt: z.date(),
updatedAt: z.date().optional(),
deletedAt: z.date().optional(),
}).strip();
The important fields are still validated. Flexibility lives in bounded places such as customAttributes and versioned skill artifacts—not in an unbounded “anything goes” document.
The old AiExecutableSource interface shown in the April post no longer matches the repository. The current design uses code-base environment pointers and skill-definition records. Keeping the obsolete interface would have made the example misleading.
Flexible Does Not Mean Unvalidated
MongoDB’s schema validation guide supports JSON Schema rules on collection writes. You can validate core fields and leave room for dynamic properties.
A practical policy is:
- Validate identifiers, ownership, types, and required core fields.
- Version generated artifacts.
- Reject unknown fields at the application boundary when they are not intentional.
- Test migrations and compatibility when an artifact contract changes.
- Use transactions when several documents must change atomically.
Adding an optional document field usually avoids a table migration. It does not mean zero migration work: readers, writers, backfills, indexes, and old document versions still need a compatibility plan.
Transactions Are Real, with Boundaries
MongoDB supports multi-document ACID transactions on replica sets and sharded clusters. In the Node.js driver, use a client session and pass it to each operation.
await client.withSession(async (session) => {
await session.withTransaction(async () => {
await orders.insertOne(order, { session });
await checkpoints.insertOne(checkpoint, { session });
});
});
The callback API retries certain transient errors and unknown commit results. You still need to make the callback idempotent and handle errors that are not retryable.
Current boundaries from the limits documentation:
- Default transaction lifetime: 60 seconds, configurable by the cluster.
- Maximum BSON document size: 16 MiB.
- Maximum BSON nesting: 100 levels.
- Transactions have restrictions on capped collections, system databases, and certain commands.
Transactions protect atomic changes. They do not validate your business rules or prevent a bad write that is internally consistent.
Atlas Free Tier: Useful, but Not a Production Promise
The original FAQ said the free tier could launch production infrastructure in five minutes with monitoring and backups. That was too strong.
As of 2026-11-24, the Atlas Free cluster limits include:
| Limit | Free cluster |
|---|---|
| Storage, including indexes | 0.5 GB |
| Read/write operations | 100 per second |
| Connections | 500 |
| Transfer | 10 GB in + 10 GB out per rolling seven days |
| Databases / collections | 100 / 500 |
| Idle pause | After 30 days with zero connections |
| Backups | Private preview; do not assume general availability |
| MongoDB version | 8.0 |
This is a small-scale development environment. Before production, evaluate a dedicated tier, backup/restore procedures, monitoring, connection pooling, network controls, and the operational limits your workload actually needs.
The Cost of Admission
Joins Have a Cost
MongoDB supports $lookup, but it is not the same as designing every relationship as a relational join. Embedding data that is read together can reduce round trips. Denormalizing data that changes often creates consistency work.
The original post said we stored business names in 14 places and had zero denormalization bugs in eight months. Those were private, undated observations. I no longer present them as evidence that denormalization is safe. We manage consistency deliberately and test it.
Indexes Need a Budget
MongoDB permits up to 64 indexes per collection. Every index consumes storage and slows writes. “MongoDB will let you create memory-heavy indexes without warning” was exaggerated; the real issue is that index design is still your responsibility.
Nested Arrays Can Be Awkward
Positional updates and concurrent modifications to nested arrays can be harder to reason about than separate documents. If items need independent updates or unbounded growth, model them separately.
What I Would Change If I Started Again
- Add validation for core fields earlier.
- Write an artifact compatibility and rollback policy before generating executable code at scale.
- Avoid nested arrays for independently updated items.
- Define backup, restore, and connection-pool limits before calling the database production-ready.
I removed the original claims about 1,200 businesses, 10,000 concurrent conversations, 50 ms responses, and three months without infrastructure changes. They were private metrics without a dated measurement method, not public evidence.
The Verdict
MongoDB gets out of the way for QuotyAI’s evolving document-shaped data. That is a real advantage for a small team.
It is not the best database for every workload. Stable relational data, complex joins, and teams with strong PostgreSQL operations may favor PostgreSQL. The right choice depends on access patterns, consistency requirements, and who will operate the system—not on whether you are one founder or ten.
Frequently Asked Questions
Why choose MongoDB for QuotyAI? QuotyAI stores evolving business configuration, generated schemas, and executable skill artifacts whose shapes differ by customer. MongoDB lets those documents evolve without a table migration for every new optional field. The tradeoff is that correctness must be enforced with schema validation, application contracts, indexes, and tests.
Do MongoDB transactions guarantee data integrity? MongoDB supports multi-document ACID transactions on replica sets and sharded clusters. They require a session, appropriate read/write concerns, and retry handling for transient errors. They do not make an invalid application model correct, and the default transaction lifetime is 60 seconds.
Can MongoDB validate only some fields? Yes. JSON Schema validation can constrain critical fields while leaving other properties flexible. MongoDB rejects inserts or updates that violate the configured rules by default, but validation coverage is only as good as the schema you write.
Is the MongoDB Atlas free tier suitable for production? It is a small-scale development environment, not a production guarantee. As of 2026-11-24, a Free cluster has 0.5 GB storage including indexes, 100 operations per second, 500 connections, 10 GB transfer in and 10 GB out per rolling seven days, and automatic pause after 30 days with no connections. Backups are a private preview, and full backup availability should not be assumed.
When should you prefer PostgreSQL? Prefer PostgreSQL when your data is inherently relational, joins and constraints are central, schemas are stable, or your team already operates it well. MongoDB is not a universal upgrade, and team size alone does not decide the database.
Sources
- MongoDB schema validation
- MongoDB transactions
- MongoDB limits and thresholds
- Atlas Free cluster limits
- Local QuotyAI schemas, checked 2026-11-24
Tags: mongodb database solo-founder startup backend
Related articles
Self-Hosted Agent Observability with LangChain, LangSmith SDK, and DeepAgents
How to persist LangChain DeepAgents traces in MongoDB with LangChainTracer and a custom LangSmith client — including the boundaries and operational costs.
Read articleVibe Coding vs Open Source: The Math Has Changed
AI coding agents make custom glue code cheaper to draft. The build-or-install decision still has to include review, testing, maintenance, and operational risk.
Read articleWhy I Picked Bun and Hono for QuotyAI's Backend
A bounded case for Bun and Hono on a solo-founder TypeScript backend: less framework ceremony, typed request contracts, and tradeoffs you should audit before switching.
Read article