Everything worked, but I opened the content folder for the first time

The site’s features were working without problems. The table of contents displayed correctly, articles opened, and translations appeared as expected. So I checked the manuscript content but didn’t look into the structure.

Then I needed to add sequence numbers to the articles, so I looked for the manuscripts and opened the course folder for the first time. I immediately sensed that something was wrong with the structure.

The course manuscript folder structure before the redesign

content/ ├─ dev/ │ ├─ 01_AI_개발/ │ │ └─ 01_ai-coding-principles/ko.md │ └─ 06_데이터베이스/ │ ├─ 01_postgresql-query-practice/ko.md │ ├─ 03_database-guard/ko.md │ └─ 05_ai-schema-review/ko.md ├─ haejwo_coding/ │ └─ 2_해줘_코딩_첫걸음/ │ └─ 03_fix-requests/ko.md → /haejwo/3 └─ setup/ └─ agent/ └─ 01_claude-code/ko.md 

Can you spot what’s wrong with this structure?

A single folder name is doing three jobs. The number at the beginning indicates the course order, and the Korean text after it is the course name shown on screen. But the full folder path also acts as the course ID and URL. The problem is that information with different reasons for changing has been bundled together.

Changing the order also changes the URL

Suppose I changed the number in a folder name to adjust the course order. I only intended to change the order, but because the path also serves as the course ID and URL, the address changes too. Shared links break, and URLs indexed by search engines are affected.

SEO stands for Search Engine Optimization: making it easier for search engines to understand a page and include it in search results. The same issue arises when moving a course to a different category. If you run multiple servers, they might even refer to different paths depending on when they were deployed.

This is why I still consider AI’s design ability to be below that of a developer with five years of experience. The structure made adding a manuscript convenient in the short term, but it didn’t account for what might change as courses grew, became visible to search engines, and the servers scaled.

The entire manuscript was being sent to the browser

The entire manuscript included in the main.js bundle

The second problem was that content was being managed on the client. A bundle is a file that packages code and the resources it needs so a browser can run them. I found that every visitor was downloading the entire collection of manuscripts. That meant they had to download articles they wouldn’t read, which could make the initial page heavier as the number of articles grew.

Every URL returns the same index.html, with no article body, title, or OG information

The bigger issue was search and AI discovery. The server returned the same index.html no matter which article URL it received. The HTML had no article body, and the title, description, and OG information were all the same. OG, or Open Graph, information helps display a title, description, image, and other details when a link is shared.

JavaScript runs in the browser, so people can see the articles. But crawlers like GPTBot and ClaudeBot—programs that browse websites and collect their content—generally don’t execute JavaScript. The articles are visible to people, but effectively blank to AI crawlers. Google can execute JavaScript, but that process also has limitations.

The difference between client-managed and server-managed content

Comparison of client-managed and server-managed content by manuscript location, visitor downloads, HTML, and crawler access

With client-managed content, the manuscripts and table of contents go into the client code and are bundled together during the build. The server only needs to return the same index.html and bundle for every request. It’s easy to get started, and visitors can move quickly between articles. But they receive articles they don’t need, and changing an article or its order requires rebuilding and redeploying the client.

With server-managed content, the server holds the manuscripts and table of contents, and the client requests what it needs. For example, it can request the table of contents through an API and then request the article at a particular URL. If the server puts the title, description, OG information, and body for that URL into the HTML, crawlers can read the content without JavaScript. The tradeoff is that you need to decide where the server will keep the manuscripts and structure, and how to keep content consistent across multiple servers.

This site is a document site whose articles need to be readable by search engines and AI. So managing content on the server was the right direction.

I questioned every column in AI’s table draft

First, I asked AI for a draft of the tables. It included menus, courses, table-of-contents placements, manuscripts, language-specific content, old URLs, and management information such as publication status and revision history. It was a design that aimed to manage everything—from manuscript content to the table of contents and operational features—in the database.

AI’s initial t_content_set table design

I started by looking at the columns in the table that held menu information, one by one.

CREATE TABLE t_content_set ( code VARCHAR(32) PRIMARY KEY, -- 'dev' base_path VARCHAR(64) NOT NULL UNIQUE, -- '/dev' create_time TIMESTAMP without time zone NOT NULL default (now() at time zone 'utc') ); 

code was defined as VARCHAR(32), so I said: “Risky. An enum looks better.” An enum is a data type that restricts a value to one of a predefined set of options.

base_path is the menu’s base URL. Changing this value in the database alone wouldn’t make the feature work; the client router would need to change too. So I decided it didn’t need to be in the database.

is_lesson, which creates numbered URLs only for courses, was a column added for one exception in Haejwo Coding. To avoid complicating the database structure for an exception, I modified that module and removed the column.

state represents whether a manuscript is a draft, published, or deleted when it’s saved through an API. But we hadn’t decided whether manuscripts would be managed through an API, so it wasn’t needed yet. Without a sharing feature, we didn’t need a redirect table for old URLs either. If there are no old URLs remaining externally but an address problem occurs, that may point to a failure in version control. Fixing it in the database would add another solution somewhere else instead of fixing the cause.

Revision history is essential to Wikipedia, but our site didn’t need it. There was no reason to include a feature just because other sites commonly manage it. The create_time in an unused table would also be meaningless data, so I left it out.

Should the article body live in the database or in files?

There were two options for storing article content: save it in the database, or manage it as files and store only the file locations in the database.

Comparison of content in the database versus files by editing method, update timing, authorship, and multi-server setup

Category Content stored in the database Content managed as files
How to edit an article Through an editing screen or API, even while the site is running Edit Markdown directly; AI can edit files too
When changes take effect Immediately, without a deployment After another deployment
Other considerations Convenient for managing writing and translations with multiple people No need to build a separate editing system
When using multiple servers — The same files must exist on every server
Best suited for Real-time management by multiple people Writing and deploying by designated authors

Files are a good choice for a site where designated people write and deploy the content. I write the courses myself and revise them with AI, so I chose files. By keeping Markdown files as the source and generating static HTML for each article during deployment, search engines and AI crawlers can read the article body without a separate editing database.

Architecture from user to cache server, multiple servers, file storage, and database

A cache server stores frequently requested results and delivers them quickly. If the cache server serves static HTML directly, the server doesn’t need to read the database and build a page for every request. Even if the number of servers grows, search support can stay simple.

AI suggested a middle ground: keep files as the source but also save copies in the database, making it easier to switch to the database later. I replied, “I don’t see the advantage in your suggestion.” Managing files and the database together would only add synchronization work, with no benefit right now.

The file manager module is responsible for the files’ actual locations. The code that reads manuscripts or builds the table of contents doesn’t need to know the file paths. If the storage location changes, I can update only the file manager instead of changing rows in the database.

Content in files, structure in the database

Article content and table-of-contents structure change for different reasons. Changing a course’s order shouldn’t require renaming its folder, and moving a course to a different category shouldn’t require moving its manuscript file. It’s also clearer to represent in the database the relationship where one manuscript appears in multiple tables of contents, rather than manage it through folders alone.

Table-of-contents and category information are system data needed for the service to work, not user-written articles. I decided to deploy them as SQL seeds so the development and production databases would follow the same rules. A seed is a script that creates the required initial data. It should produce the same result even when run multiple times. Existing categories are reordered, existing manuscript IDs are preserved, and table-of-contents placement information is regenerated.

Side-by-side comparison of the manuscript folder structure before and after the redesign

content/ ├─ dev/ │ ├─ ai-coding-principles/ko.md → /dev/ai-coding-principles │ ├─ database-guard/ko.md → /dev/database-guard │ │ en.md · ja.md … (번역본) │ └─ ai-schema-review/ko.md ├─ haejwo/ │ └─ fix-requests/ko.md → /haejwo/fix-requests └─ setup/ └─ agent/claude-code/ko.md → /setup/agent/claude-code 

Now the folders contain only names that identify the manuscripts. The database manages course order and categories, while the file paths serve as URLs and manuscript identifiers. I didn’t change the manuscript content; I only reorganized the file locations and how they’re managed.

The most serious error was putting URLs in the placement table

Placement is the concept of managing which manuscript appears in which category and at what position. But the AI’s draft also put the manuscript URL there. This carried an exception from the existing site directly into the schema: the Claude Code installation document appeared in both the installation-and-integration menu and the getting-started menu, with two different URLs.

Table design highlighting the URL, canonical flag, and composite foreign key in t_content_placement

CREATE TABLE t_content_placement ( id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, doc_id BIGINT NOT NULL REFERENCES t_content_doc(id), group_id BIGINT NOT NULL, set_code VARCHAR(32) NOT NULL, path_name VARCHAR(64) NOT NULL, -- 'database-guard' 또는 강 번호 '3' sort_order INTEGER NOT NULL, -- 묶음 안 읽는 순서 is_canonical BOOLEAN NOT NULL default true, -- 검색 엔진에 대표로 알릴 주소 FOREIGN KEY (group_id, set_code) REFERENCES t_content_group(id, set_code), UNIQUE (set_code, path_name), -- 한 메뉴 안에서 주소가 겹치지 않게 UNIQUE (doc_id, set_code) ); CREATE UNIQUE INDEX ux_content_placement_canonical ON t_content_placement(doc_id) WHERE is_canonical; 

Once path_name was used to manage URLs, it brought along is_canonical to designate a canonical URL and a composite foreign key to copy and match values. A foreign key is a constraint that references data in another table to maintain a relationship. Here, putting the URL in the placement table had led to more mechanisms for maintaining consistency.

“The concept is wrong. Why manage URLs here when this is placement? The design is completely off.”

When I asked about the cause, three things became clear. The existing code’s behavior had been carried over without first considering the role of the data. The growing number of corrective mechanisms hadn’t been recognized as a sign of a design flaw. And an exceptional behavior had been used as the basis for the entire structure. The solution is to separate responsibilities: the manuscript manages its URL, while placement manages only which manuscript goes in which category and at what position.

I recorded this principle in server/CLAUDE.md as well.

테이블은 이름이 뜻하는 개념만 맡는다. 컬럼마다 이 값은 어느 개념의 속성인가를 먼저 묻는다. 지금 코드의 구현이나 소수의 예외를 스키마의 기준으로 삼지 않는다. 복사, 대표 플래그, 복합 FK 같은 정합성 장치가 필요해지면 책임 위치가 틀렸다는 신호다. 

In short: each table owns only the concept in its name; identify which concept each column belongs to; don’t base the schema on current implementation or rare exceptions; and treat extra consistency mechanisms as a sign that responsibility may be in the wrong place.

The final structure and design criteria

What Where it’s managed Why
Manuscripts Files I write them directly, revise them with AI, and deploy them.
File locations File manager The actual paths are managed in one place.
Categories, order, URLs, and table-of-contents structure Database and SQL seeds Structural information is deployed according to consistent rules.
Menu base URL Code It must change together with the client router.

At first, one folder path was responsible for the order, name, URL, and identifier. Now the manuscripts, file locations, table-of-contents structure, and menu URLs are each managed in the appropriate place. Changing the order no longer requires moving a manuscript, and editing a manuscript no longer requires changing the table-of-contents structure.

The criterion comes down to one question: “When and why does this value change?” Separate information that changes for different reasons, and manage information that changes for the same reason together. Rather than deciding first whether files or a database are better, consider why each piece of information belongs where it does.

In your own codebase, check: “Why does this data belong here?”, “Is this feature really necessary?”, and “How much will be affected if this changes later?”

Is there a place in your program where information that changes for different reasons has been bundled together?

▶ Turn on English subtitles (CC) to watch

This article summarizes my Korean YouTube video (English subtitles available) and was translated with AI. #ABotWroteThis