Building My First RAG System in One Week with Kiro IDE š
Source: Dev.to
š The Challenge
As a junior apps developer, Iād never built a RAG (Retrieval Augmented Generation) system before. The concept seemed intimidating: vector embeddings, semantic search, chunking strategiesāall foreign territory. But the Kiroween hackathonās āSkeleton Crewā category sparked an idea: what if I could build ONE reusable skeleton that transforms into ANY AI personality?
Seven days later, I had Project Corpus: a productionāready RAG chatbot that can become a professional legal assistant, a mystical spirit, or anything elseājust by swapping a config file.
š Live Demo | GitHub Repo
š® What is Project Corpus?
Project Corpus is a documentāchat application with a twist: the same core logic powers radically different AI personalities.
Two Personalities, One Skeleton
āļø Legal Eagle
- Professional legal document analysis
- Formal responses with precise citations
- Blue corporate styling with typewriter sounds
- Ideal for contract analysis and legal research
š» Ouija Board
- Mystical document exploration āfrom beyond the veilā
- Cryptic, atmospheric responses with spooky emojis
- Dark gothic theme with bloodādrip animations
- Ambient drone audio with static glitch effects
Both apps share the same skeleton_core moduleāonly the config changes.
š ļø The Tech Stack
Backend
- Python 3.13 + Flask 3.1.0
- ChromaDB 0.5.20 (vector database)
- Google Gemini API 0.8.3 (embeddings + generation)
pypdf5.1.0 (PDF processing)
Frontend
- Vanilla JavaScript (no frameworks)
- Custom CSS with theme variables
- ServerāSent Events for realātime progress
Testing
pytest7.4.3hypothesis6.92.1 (propertyābased testing)
Development
- Kiro IDE (the secret weapon š)
š¤ How Kiro Transformed My Development
1. šØ Vibe Coding: Learning While Building
As a junior developer, I needed to understand RAG, not just write code. Kiroās conversational approach let me learn and build simultaneously.
Example conversation
Me: "How do I chunk PDFs by page and preserve page numbers?"
Kiro: *Explains chunking strategies, then generates code that:*
- Extracts PDF pages individually
- Chunks each page with 500āÆchar / 50āÆoverlap
- Stores metadata with source, page, chunk_index
- Retrieves page numbers in search results
Most Impressive Generation
Kiro produced the entire ServerāSent Events upload pipeline in one conversation, including:
- Flask SSE streaming with
Response(stream_with_context()) - 4āstage progress calculation (reading, parsing, vectorizing, finalizing)
- Clientāside
EventSourcelistener with progress bars - Graceful error handling
I had never used SSE before; Kiro not only wrote the code but also explained why SSE beats polling for this use case.
2. š Specs: Systematic UI Polish
After building core features with vibe coding, I created .kiro/spec.md describing the desired user experience:
## 4. Implemented Features
1. **Document Upload (`/upload`):**
- Realātime progress tracking via SSE
- Pageāaware chunking with metadata
- File validation (type, size, content)
2. **Chat Interface (`/chat`):**
- Semantic search with relevance filtering
- Source citations with page numbers
- Typewriter effect for responses
With the spec in place, I could say āimplement sectionāÆ4.1ā and Kiro would systematically add all featuresāno backāandāforth needed.
Vibe Coding vs. Specs
- Vibe Coding: Exploratory, great for learning and core features.
- Specs: Systematic, perfect for polish and completeness.
3. š Steering Docs: Teaching Kiro My Architecture
I created four steering documents that taught Kiro the projectās DNA.
structure.md ā The gameāchanger
### Skeleton + Config Pattern
The `skeleton_core` module contains all shared RAG functionality.
Individual app folders provide configuration objects that customize behavior.
Each `app_*/config.py` must define:
- `APP_NAME`: String for branding
- `THEME_CSS`: CSS theme identifier
- `SYSTEM_PROMPT`: AI personality instructions
- `CHUNK_SIZE`, `CHUNK_OVERLAP`, `TOP_K_RESULTS`, `RELEVANCE_THRESHOLD`
Before steering docs
- Me: āAdd a delete document featureā
- Kiro: Modifies
app_legal/main.pydirectly ā (breaks reusability)
After steering docs
- Me: āAdd a delete document featureā
- Kiro: Adds
delete_document()toskeleton_core/vector_store.py, creates/documents/DELETE route, updates frontend ā (maintains skeleton pattern)
Steering docs reduced āwrong suggestionsā by ~80%, turning Kiro into a partner who understood the projectās philosophy, not just its syntax.
4. šŖ Agent Hooks: Automated Quality Assurance
I built five hooks that caught bugs before deployment.
test-runner-on-save.kiro.hook
{
"when": { "type": "fileEdited", "patterns": ["**/*.py"] },
"then": { "type": "runCommand", "command": "pytest --tb=short -q" }
}
Runs tests automatically on every save, catching breaking changes instantly.
config-validator.kiro.hook ā Validates that config files contain all required fields, preventing runtime errors.
env-check-on-session.kiro.hook ā Verifies GOOGLE_API_KEY exists on session start, saving minutes of debugging.
Impact ā Shifted workflow from reactive debugging to proactive validation, providing a safety net for a junior developer.
š§ The Biggest Challenges
1. RAG Learning Curve
Understanding vector embeddings, semantic search, and chunking was overwhelming. Kiro became my teacher, offering explanations and solutions when search results were irrelevant.
Solution: Implemented relevance filtering that only shows documents within 0.3 distance units of the best match, ensuring accurate citations.
2. PageāAware Chunking
Preserving page numbers through extraction ā chunking ā embedding ā storage ā retrieval required careful metadata management.
Solution: Added page tracking at each stage with metadata, e.g.:
metadata = {
"source": filename,
"page": page_num,
"chunk_index": i
}
3. Theme Switching Architecture
Supporting radically different personalities from a single codebase demanded strong abstraction.
Solution: Adopted a configābased approach; adding a new personality now takes ~10āÆminutes.
š What Iām Proud Of
1. Learning RAG in One Week
Went from zero RAG knowledge to a productionāready system with vector search, embeddings, and semantic retrieval in 7āÆdays. Kiroās vibe coding made this possible.
2. The Skeleton Pattern Works
The architecture is genuinely reusable. Adding a new personality is as simple as:
mkdir app_detective
# Add config.py with Config class
# Add main.py entry point
# Done! š
3. ProductionāQuality UI
- Smooth animations (typewriter effect, blood drips)
- Realātime upload progress with SSE
- Document library with selective filtering
- Accessibility (ARIA labels, keyboard navigation)
- Themeāspecific audio (typewriter, ambient drone)