← Back to PRD: ../PRD.md
DevMap follows this principle:
80% Static Analysis
20% AI InterpretationStatic analysis is the foundation.
AI is an enhancement layer.
DevMap should not rely on AI to understand an entire project from raw source files.
Instead, DevMap should first extract structured project information, then use AI to explain that information in a readable way.
Project Files
↓
Scanner
↓
Static Analyzer
↓
Project Map
↓
Snapshot
↓
Context Builder
↓
AI Layer
↓
Terminal Output| Layer | Purpose |
|---|---|
| Scanner | Finds relevant project files |
| Static Analyzer | Extracts structure and relationships |
| Project Map | Internal structured analysis result |
| Snapshot | Saved reusable project context |
| Context Builder | Selects relevant files for questions |
| AI Layer | Explains and answers |
| Terminal Output | Displays result to user |
DevMap MVP focuses on:
- Next.js
- Express
Other stacks are future roadmap items.
The scanner is responsible for discovering project files.
- Traverse project directories
- Collect file metadata
- Apply ignore rules
- Return relevant source files
node_modules/
.git/
.next/
dist/
build/
coverage/
.turbo/
.vercel/
out/
*.min.js
*.min.ts
*.map
*.lock
*.log
.env*
public/assets/The scanner returns a list of relevant files with metadata such as:
- path
- extension
- size
- last modified time
The analyzer extracts useful structure from scanned files.
- Detect framework
- Detect language
- Detect package manager
- Detect routes
- Detect API routes
- Detect imports
- Detect exports
- Detect dependencies
- Detect external services
- Detect database usage
- Detect entry points
- Detect critical files
- Detect common features
Framework detection should use:
package.jsondependencies- project folder patterns
- framework-specific files
| Signal | Detection |
|---|---|
next dependency |
Next.js |
app/ directory |
Next.js App Router |
pages/ directory |
Next.js Pages Router |
express dependency |
Express |
server.ts or server.js |
Node/Express entry point |
The dependency graph maps relationships between files.
Understand which files import other files.
app/page.tsx
→ components/Hero.tsx
→ lib/db.ts- Critical file detection
- Entry point detection
- Context expansion
- Better answers in
devmap ask
Entry points are files where application execution or routing commonly starts.
app/layout.tsx
app/page.tsx
middleware.ts
app/api/*/route.ts
pages/_app.tsx
pages/index.tsxserver.ts
server.js
app.ts
app.js
index.ts
index.jsCritical files are files that strongly affect project behavior.
- Imported by many files
- Used by entry points
- Contains shared configuration
- Contains auth, database, API, or provider logic
- Has framework-specific importance
lib/db.ts
lib/auth.ts
middleware.ts
prisma/schema.prisma
src/server.tsDevMap detects external services using dependency and import patterns.
| Dependency / Import | Service |
|---|---|
@prisma/client |
Prisma |
@supabase/supabase-js |
Supabase |
next-auth |
NextAuth |
stripe |
Stripe |
midtrans-client |
Midtrans |
resend |
Resend |
cloudinary |
Cloudinary |
openai |
OpenAI |
@google/generative-ai |
Gemini |
groq-sdk |
Groq |
DevMap should detect database usage through:
- dependencies
- schema files
- configuration files
- imports
- environment variable names
| Signal | Detection |
|---|---|
prisma/schema.prisma |
Prisma |
@prisma/client |
Prisma Client |
drizzle.config.ts |
Drizzle |
mongoose |
MongoDB / Mongoose |
@supabase/supabase-js |
Supabase |
DATABASE_URL |
Database connection |
Feature detection identifies common application capabilities.
- Authentication
- Database
- API routes
- File upload
- Payments
- AI integration
- Notifications
| Signal | Feature |
|---|---|
next-auth, auth, session, login |
Authentication |
stripe, midtrans, payment |
Payments |
cloudinary, upload, multer |
File Upload |
resend, nodemailer, email |
|
openai, groq, gemini, ai |
AI Integration |
Snapshot is the reusable project context generated by DevMap.
.devmap/snapshot.json- Store current project analysis
- Act as source of truth for
devmap ask - Provide reusable context for AI agents
- Avoid repeated project exploration
- Must include schema version
- Must include generated timestamp
- Must not contain full raw project source by default
- Must be compact
- Must be deterministic
- Must be regenerated by
devmap analyze
interface DevMapSnapshot {
version: string;
generatedAt: string;
project: {
name?: string;
root: string;
framework: "nextjs" | "express" | "react" | "node" | "unknown";
language: "typescript" | "javascript" | "mixed" | "unknown";
packageManager: "pnpm" | "npm" | "yarn" | "bun" | "unknown";
};
stats: {
totalFiles: number;
relevantFiles: number;
totalLines?: number;
};
entryPoints: EntryPoint[];
criticalFiles: CriticalFile[];
routes: RouteInfo[];
apiRoutes: ApiRouteInfo[];
dependencies: DependencyInfo[];
externalServices: ExternalServiceInfo[];
database?: DatabaseInfo;
features: FeatureInfo[];
fileIndex: Record<string, FileInfo>;
}In snapshot schema v1, totalFiles and relevantFiles both count the files
returned by the filtered scanner. DevMap does not currently walk the ignored
filesystem paths to calculate a separate pre-filter total. Both fields remain
in the schema for compatibility and for a future analyzer that may collect
those counts separately.
The Context Builder selects relevant context before sending anything to AI.
It is one of the most important parts of DevMap.
Poor context selection creates:
- high token usage
- irrelevant answers
- slow responses
- hallucinated explanations
Good context selection creates:
- lower token usage
- better answers
- faster responses
- repeatable project understanding
MVP does not use embeddings or vector search.
Use pragmatic heuristics first:
- File path matching
- Keyword matching
- Import/export matching
- Dependency matching
- Known framework conventions
Question:
how does authentication work?Extract keywords:
auth
authentication
login
session
token
middlewareLikely selected files:
middleware.ts
lib/auth.ts
lib/session.ts
app/api/auth/*| Limit | Value |
|---|---|
| Preferred file count | 3–5 files |
| Maximum file count | 5 files |
| English navigation queries | 2 files, 60 lines each |
| Large file behavior | Extract relevant sections |
| Full project source | Never sent |
Test files and fixtures are excluded from normal product questions. They are
eligible when an English query explicitly mentions testing terms such as
test, spec, fixture, or coverage.
Explicit English scope terms provide a ranking boost:
cli,command,terminalweb,ui,frontend,component,pagedocs,documentation,readme
Scope matching is a boost rather than a hard exclusion so cross-package dependencies can still be selected when their direct relevance is stronger.
All AI interactions go through a provider abstraction.
Commands should not call provider APIs directly.
- Groq
- OpenAI
- Gemini
- Validate API key
- Check model availability where possible
- Send completion request
- Stream response
- Handle provider-specific errors
- Normalize output for commands
MVP default model routing:
| Command | Model |
|---|---|
ask |
llama-3.1-8b-instant |
analyze |
openai/gpt-oss-20b |
analyze --deep |
openai/gpt-oss-120b |
| Fallback | openai/gpt-oss-20b |
If a model is unavailable, DevMap should fall back gracefully. Only Groq production models should be used as public defaults.
Users can override automatic routing with devmap config model <model>.
Running devmap config model auto restores the defaults above.
Raw provider errors should not be shown directly to users.
Prompt templates should be centralized.
- Do not inline prompts inside command logic
- Keep prompts versionable
- Keep prompts short and structured
- Prefer structured JSON input
- Ask AI to explain, not discover
- Do not ask AI to infer facts not present in the snapshot/context
DevMap is designed to reduce repeated AI exploration.
However, token-efficiency claims must be benchmarked before being used in public marketing.
- Static analysis first
- Never send the full raw project
- Send compact snapshot data
- For
ask, send only relevant context - Cache and reuse snapshot
MVP cache source:
.devmap/snapshot.jsonFuture cache source:
.devmap/cache.jsondevmap analyzegenerates snapshotdevmap askreuses snapshot- If no snapshot exists,
askmay run quick analysis first - If project changes, user may be prompted to re-analyze
Future cache may include:
- file hashes
- dependency graph
- extracted metadata
- last analysis result per file
~/.devmap/config.jsonStores:
- provider
- API key
- default model
- language preference
.devmap/
└── snapshot.jsonStores:
- latest project snapshot
Future:
.devmap/
├── snapshot.json
└── cache.jsonDevMap may generate or update:
DEVMAP.md
AGENTS.md
.devmap/snapshot.jsonDetailed generated file behavior is documented in:
Default language mode:
auto| Output Type | Language |
|---|---|
| CLI labels | English |
| Technical terms | English where natural |
| AI explanation | Same as user question |
| Generated docs | Config language or detected language |
| Error messages | English |
| Help text | English |
Errors should be actionable.
- Do not show raw stack traces by default
- Explain what failed
- Explain why it may have failed
- Tell user what to do next
- Use
devmap doctorwhen useful
Unable to validate API key.
Possible causes:
- API key is invalid
- Internet connection failed
- Provider service is unavailable
Next:
Run devmap init again or check your provider dashboard.CLI output should be:
- readable
- minimal
- actionable
- friendly for developers
- consistent across commands
Every MVP command supports --json. JSON mode is implemented at the output
context layer so nested operations, such as ask triggering quick analysis,
do not leak human progress text into stdout.
Rules:
- emit exactly one JSON document to stdout
- suppress ANSI, Markdown rendering, bullets, and separators
- keep human output as the default
- use structured error objects and preserve non-zero exit codes for thrown failures
- keep command result schemas stable enough for agents and scripts
- progress feedback
- clear success messages
- clear next step
- useful error messages
DevMap should support:
- Windows
- macOS
- Linux
- Use cross-platform path utilities
- Avoid shell-specific assumptions
- Avoid hardcoded path separators
- Test with different package managers
Commands orchestrate behavior.
They should not contain heavy analysis logic.
Analyzer extracts project structure.
It should not call AI directly.
Context Builder selects relevant project context.
It should not format terminal output.
AI Layer communicates with providers.
It should not scan files directly.
Output Layer formats terminal messages.
It should not contain business logic.
Product direction:
../PRD.md
Command behavior:
Generated file behavior:
Benchmarking:
Testing:
Roadmap: