If you’ve ever built much than a speedy prototype pinch AI devices for illustration Lovable aliases Replit, you’ve apt felt nan clash that comes pinch extending nan first version. A mini codification refactoring tin trigger caller bugs, a caller characteristic tin break aged logic and advancement starts to consciousness for illustration rework alternatively of iteration.
This shape isn’t random. Most AI coding devices are designed to make codification quickly, alternatively than preserving building complete time. While they tin create moving APIs and functions, they don’t found an overarching architecture to link and shape them. The consequence is simply a single, functional codebase pinch constricted isolation, unclear ownership and nary reliable way for reuse. What originates arsenic accelerated improvement soon becomes rework.
The improvement from AI codification procreation to composable architecture changes really AI fits into real-world package development. Instead of producing full files successful 1 shot, developers tin usage AI to create independent modules that plug into a broader architecture. This attack aligns amended pinch really teams maintain, trial and vessel accumulation code.
In this article, I’ll locomotion done what that looks like.
I’ll commencement by asking an AI assistant to make code for a mini moving React app and inspect its structure. Next, I’ll place wherever nan architecture creates clash erstwhile making changes aliases adding caller features. Finally, I’ll rebuild nan aforesaid app utilizing a composable workflow that enforces boundaries, type search and modular reuse, turning nan aforesaid generated codification into package that tin turn sustainably.
Let’s Generate nan App
To put composability to nan test, I asked Cursor to make a complete React task head exertion utilizing a azygous prompt.
The petition mirrors really astir developers interact pinch AI tools: picture nan requirements erstwhile and fto nan exemplary supply applicable suggestions for a afloat implementation.
Create a complete React task manager application. Requirements: Login/logout flow with mock authentication (username/password check against hardcoded data). After logging in, display a Dashboard page with a task list. Allow adding and deleting tasks. Store the authentication state in local storage so that the session persists after refresh. Use React functional components with hooks. Include basic error handling and loading states. |
Below is nan generated task head and its record structure. The afloat codification is besides disposable in this GitHub Repository.

AI-generated task manager
src/ ├── App.css ├── App.js ├── App.test.js ├── index.css ├── index.js ├── logo.svg ├── reportWebVitals.js ├── setupTests.js ├── components/ │ ├── Dashboard.css │ ├── Dashboard.js │ ├── Login.css │ └── Login.js └── contexts/ └── AuthContext.js |
At first glance, nan task building looks acquainted and usable. The app compiles and runs successfully, providing authentication, a dashboard, and persistent task guidance done section storage, precisely arsenic requested successful nan prompt.
However, nan existent mobility isn’t whether nan exertion runs, but really nan files are structured. The coming architecture lacks clear boundaries. Logic, state, and position are intertwined. Nothing successful this building enforces modularity, reuse aliases type control.
This is wherever nan absence of composable architecture becomes visible.
The champion AI codification generators tin nutrient moving applications, but they seldom specify systems. Without isolation betwixt authorities and UI, clear ownership of logic aliases definitive contracts betwixt components, each characteristic becomes interdependent.
In nan adjacent section, I’ll analyse nan building of this exertion much closely, highlighting wherever architectural shortcuts create friction.
Issues With nan Cursor-Generated App
The generated task manager’s building shows clear limitations erstwhile evaluated for semipermanent maintainability. The weaknesses are not successful nan syntax aliases React patterns, but successful nan system’s composition.
The pursuing examples exemplify really these structural gaps look successful nan code.
- No prop boundaries betwixt components
Where it happens: App.js (lines 9–22)
const ProtectedRoute = ({ children }) => { const { user, loading } = useAuth(); if (loading) { return ( <div className="loading-container"> <div className="spinner"></div> <p>Loading...</p> </div> ); } return user ? children : <Navigate to="/login" replace />; }; |
ProtectedRoute accepts immoderate children constituent without constraints. No defined interface explains what benignant of constituent tin beryllium passed, what props it should person aliases what information discourse it depends on.
In a larger application, this leads to vulnerable integration points. Without definitive boundaries, a mini alteration successful nan way logic tin silently impact each constituent nested wrong it.
Every constituent should specify its interface and dependencies. In a composable system, this is achieved done typed props, contracts aliases schema definitions that picture what each portion consumes and exposes.
- Zero trial coverage
Where it happens: App.test.js (lines 4–8)
import { render, screen } from '@testing-library/react'; import App from './App'; test('renders study respond link', () => { render(<App />); const linkElement = screen.getByText(/learn react/i); expect(linkElement).toBeInTheDocument(); }); |
The only trial checks that nan React starter template renders, leaving each existent exertion logic unverified. Authentication, authorities persistence and task updates run without immoderate automated guardrails.
Without portion aliases integration tests, nan strategy has nary measurable feedback loop. Each alteration risks introducing regressions that stay invisible until runtime.
Each module should person defined and testable behavior. Isolated tests service arsenic nan compositional boundaries of a system, ensuring that changes successful 1 area do not silently change another.
- Broken separation of concerns
Where it happens: Dashboard.js (lines 32–52)
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
const handleAddTask = async (e) => { e.preventDefault(); if (!newTask.trim()) { setError('Task explanation cannot beryllium empty'); return; } setLoading(true); setError(''); await new Promise(resolve => setTimeout(resolve, 500)); const task = { id: Date.now().toString(), text: newTask.trim(), completed: false, createdAt: new Date().toISOString() }; setTasks(prev => [task, ...prev]); setNewTask(''); setLoading(false); }; |
The handleAddTask usability combines arena handling, validation, API simulation and authorities updates successful 1 place, making it difficult to trial aliases switch immoderate azygous part.
As nan app grows, adding caller features would require rewriting this logic alternatively than extending it done isolated modules.
Logic, authorities and position should germinate independently of each other, enabling systems to accommodate without requiring nan rewriting of full components.
- Tightly coupled state
Where it happens: AuthContext.js (lines 19–21)
export const AuthProvider = ({ children }) => { const [user, setUser] = useState(null); const [loading, setLoading] = useState(true); |
The authentication authorities lives straight wrong nan supplier component. All updates, persistence logic and API handling are bound to a azygous context.
This coupling prevents reusability. The authentication logic cannot beryllium shared crossed projects aliases replaced pinch a different implementation because nan authorities is not portable aliases parameterized.
Application authorities should person clear ownership and unrecorded extracurricular nan components that devour it. This separation keeps nan authorities reusable and portable crossed contexts.
- No way for reusability
Where it happens: AuthContext.js (lines 6–9, 32–52)
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
const MOCK_USERS = [ { username: 'admin', password: 'password123', name: 'Admin User' }, { username: 'user', password: 'user123', name: 'Regular User' } ]; const login = async (username, password) => { setLoading(true); await new Promise(resolve => setTimeout(resolve, 1000)); const foundUser = MOCK_USERS.find( u => u.username === username && u.password === password ); if (foundUser) { const userData = { username: foundUser.username, name: foundUser.name }; setUser(userData); localStorage.setItem('user', JSON.stringify(userData)); setLoading(false); return { success: true }; } else { setLoading(false); return { success: false, error: 'Invalid username aliases password' }; } }; |
Mock users are hardcoded straight into nan authentication context, pinch nary abstraction aliases configuration layer. This tightly couples authentication logic to nan app, making it intolerable to merge a caller supplier without rewriting nan full context.
Authentication should alternatively beryllium defined done an interface, allowing providers to beryllium swapped seamlessly without requiring modifications to soul logic.
Rebuilding With a Composable Architecture
The issues successful nan codification generated by AI devices are not unsocial to Cursor. They look successful almost each AI-generated task that prioritizes codification completion complete architectural intent. To correct them, developers request to alteration their practices to make code based connected modular composition.
Composable architecture starts pinch an architectural scheme that guides nan codification procreation process. Before penning immoderate logic, nan strategy defines its structure, including what units exist, really they pass and wherever authorities and behaviour reside. Once these boundaries are set, AI tin safely make codification for each constituent wrong that structure. The output becomes a web of versioned modules, alternatively than a single, untracked codebase.
This attack is what Hope AI and Bit Cloud instrumentality together. Hope AI generates codification done an architecture-first workflow, and Bit Cloud provides nan strategy that stores, versions and reuses each generated component. Together, they show really AI-assisted codification procreation tin germinate into a repeatable package improvement process.
The rebuild follows 3 system steps:
Step 1: Defining Architecture Before Code
The improvement process originates pinch an architectural proposal. The developer describes nan high-level design, for instance, separating logic into services, hooks and UI layers, and nan AI returns a sketch of that building earlier penning a azygous statement of code.
For our task manager, Hope AI projected nan pursuing layout:

Hope AI Architecture
This architectural layout already resolves respective earlier issues:
- Pages grip navigation-level logic (login, dashboard).
- UI components attraction connected rendering and relationship (task-item, add-task).
- Hooks encapsulate authorities and information (use-tasks, use-auth).
- The root app connects these pieces without embedding logic directly.
By reviewing this building earlier generation, developers tin set boundaries, for example, requesting a services/TaskService to isolate async logic.
This architectural checkpoint converts AI from a codification shaper into a creation collaborator.
Step 2: Component Generation
After nan architecture is approved, Hope AI generates each constituent arsenic a standalone, testable unit. Instead of assembling a ample bundle of files, it produces small, modular components pinch clear responsibilities, each packaged pinch section tests, archiving and usage previews.
For example, nan useAuth hook is generated arsenic a reusable usability alternatively than a artifact of inline logic:
export function useAuth(): UseAuthValue { const [currentUser, setCurrentUser] = useState<User | null>(null); const [isAuthLoading, setIsAuthLoading] = useState(true); useEffect(() => { }, []); const login = useCallback(async (username: string, password: string): Promise<void> => { }, []); const logout = useCallback(() => { }, []); |
A matching trial record use-tasks.spec.tsx is besides created to validate nan hook’s behavior:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
describe('useAuth', () => { beforeEach(() => { localStorage.clear(); }); it('should initialize pinch personification information from localStorage if it exists', () => { const mockUser = { id: '123', username: 'testuser' }; localStorage.setItem('app-auth-session', JSON.stringify(mockUser)); const { result } = renderHook(() => useAuth()); expect(result.current.user).toEqual(mockUser); expect(result.current.isAuthenticated).toBe(true); }); it('should log successful a personification and shop nan personification successful localStorage', async () => { const { result } = renderHook(() => useAuth()); await act(async () => { await result.current.login('testuser', 'password'); }); expect(result.current.user).toEqual({ id: 'clxtest123', username: 'testuser' }); expect(localStorage.getItem('app-auth-session')).toEqual(JSON.stringify({ id: 'clxtest123', username: 'testuser' })); }); |
Each constituent appears successful nan reappraisal sheet erstwhile generated, wherever developers tin refine logic done prompts aliases nonstop edits. This keeps quality oversight astatine nan halfway of nan codification procreation process, ensuring that AI-generated codification remains guided by developer intent.
The consequence is simply a room of modular, tested components that support real-world development.
Step 3: Versioning, Reuse and Team Collaboration
When a constituent reaches stability, developers tin threat it into a versioned merchandise straight from nan reappraisal panel. Each threat captures nan nonstop authorities of nan component, its code, limitations and metadata, creating an immutable grounds successful Bit Cloud’s type history. This makes it elemental to reuse, rotation backmost aliases branch from immoderate earlier type without introducing regressions.
Once versioned, updates travel a system reappraisal process. Proposed changes unfastened as Change Requests, wherever teammates tin reappraisal diffs, time off feedback and o.k. revisions earlier they merge. This travel preserves value while allowing continuous loop crossed teams.
Stable components tin past beryllium installed arsenic limitations from Bit Cloud’s registry aliases Git. For example, to reuse nan authentication hook:
npm one @<org>/tasks.hooks.use-auth@<version>
The image beneath shows nan rebuilt task manager, now system astir independent, reusable components.

Rebuilt Task Manager Application
By starring pinch architecture and composability, AI-generated applications germinate into modular systems that standard people pinch squad and business growth.
Practical Checklist
Before deploying immoderate AI-generated application, usage this checklist to measure its accumulation readiness:
Applications that walk these criteria will scale sustainably pinch your team and business requirements.
Wrapping Up
The correction that weakens each AI-generated app isn’t nan codification itself but nan deficiency of structure, modularity and clear boundaries. Developers often trust connected codification completion and codification suggestions to velocity up package development, but without a scheme for composable architecture, nan resulting applications go fragile, difficult to support and difficult to extend.
To build AI-assisted applications that scale, teams should commencement pinch architecture, defining modular components, clear interfaces and separation of concerns earlier generating code. Integrating codification review, testing and type power ensures that each module maintains precocious codification value and tin beryllium reused crossed projects.
By adopting this approach, AI transitions from a elemental codification generator to a partner successful structured, sustainable package development, enabling teams to create prototypes that germinate into lasting, maintainable applications. You tin motion up for Bit Cloud and research their generous free tier to spot really modular AI codification procreation tin heighten your codification procreation process.
YOUTUBE.COM/THENEWSTACK
Tech moves fast, don't miss an episode. Subscribe to our YouTube channel to watercourse each our podcasts, interviews, demos, and more.
Group Created pinch Sketch.
English (US) ·
Indonesian (ID) ·