top of page

AI as Backend: Can a Bot Replace a Developer? (Spoiler: Not Yet, But...)

Samuel Ventimiglia

At Heveloon, we're always exploring the cutting edge of technology, and the rise of powerful AI tools like large language models (LLMs) has us asking: Can we build an entire backend using just AI? We put it to the test, and the results are fascinating – and a little humbling.



AI as Backend

The Dream: AI Backend Creation

The initial, ambitious goal was to see if we could provide an AI with just a database connection string and have it magically spin up a fully functional, production-ready backend for a simple application. The dream? Zero coding, just pure AI-driven development.


The Reality Check: Requirements are King (and Queen)

It quickly became clear that a database connection string alone is woefully insufficient. An AI, no matter how advanced, can't infer what your application should do from just the how of connecting to a database. This is the fundamental challenge:

  • Business Logic: The core rules and processes of your application are invisible to the AI without explicit instructions. "When a user does X, do Y and Z" needs to be clearly defined.

  • API Design: What endpoints do you need? What data should they accept and return? The AI can't guess your intended API structure.

  • Security: Authentication, authorisation, input validation – these critical aspects require careful planning and explicit instructions.


The Experiment: A To-Do List App

We decided to build a simple to-do list application as our test case. We chose a common tech stack:

  • Frontend: React

  • Backend: Node.js with Express.js

  • Database: PostgreSQL

  • AI Assistance: A large language model (similar to the one powering this conversation!) and code completion tools like GitHub Copilot.


Phase 1: The Naive Approach (and Why It Failed)

Initially, we tried feeding the AI just the database connection string. Unsurprisingly, the results were unusable. The AI had no context, and no understanding of the purpose of the application. It might have created some generic tables, but they wouldn't have matched our needs.


Phase 2: Adding Structure with Swagger (OpenAPI)

The game changed when we introduced a Swagger (OpenAPI) specification. This provided a machine-readable blueprint of our API:

  • Endpoints: /users, /login, /todos, etc.

  • Request/Response Schemas: The structure of the data being exchanged.

  • Data Types and Validation: Ensuring the API receives and sends the correct data.

With the Swagger spec, the AI could now generate a significant amount of boilerplate code:

  • Express.js route handlers (with placeholders for the actual logic).

  • Database interaction code (using Sequelize, an ORM).

  • Basic data validation.

This was a huge leap forward. The AI could handle much of the repetitive, predictable code, freeing us to focus on the more complex aspects.


Phase 3: The Missing Piece: Detailed Software Logic

Even with Swagger, the AI couldn't magically implement the business logic. This is where we had to provide detailed, step-by-step instructions for each API endpoint. For example, for creating a new to-do item, we described:

  1. Verify user authentication (using a JWT token).

  2. Get the user's ID from the token.

  3. Validate the input data (title is required, description is optional).

  4. Create a new row in the todo_items table.

  5. Return a successful response with the newly created item.

  6. Handle error conditions (unauthorised, invalid input, database errors).

With this level of detail, the AI could translate our descriptions into code, filling in the placeholders in the generated route handlers.


The Results: A Powerful Assistant, Not a Replacement

The combination of a database connection, a Swagger specification, and detailed software logic descriptions enabled the AI to generate a substantial portion of the backend code. We estimate it handled 60-80% of the "boilerplate" and straightforward logic.

However – and this is crucial – a human developer was still absolutely essential:

  • Code Review: The AI-generated code must be reviewed for correctness, security vulnerabilities, and code quality.

  • Complex Logic: Intricate business rules or algorithms often require manual coding or significant refinement of the AI's output.

  • Authentication/Authorisation: Implementing robust security requires human expertise.

  • Testing: AI can generate basic tests, but comprehensive testing needs human judgement.

  • Maintainability: Ensuring the code is well-structured and easy to maintain is a human responsibility.

  • Deployment and Monitoring: While AI can help with deployment scripts, the overall infrastructure management and monitoring still need human oversight.


Key Takeaways

  • AI is a powerful tool for backend development, but not a magic bullet. It can significantly accelerate the process, especially for repetitive tasks and well-defined logic.

  • Clear, precise requirements are paramount. The more detailed your specifications (database schema, API design, business logic), the better the AI will perform.

  • Swagger/OpenAPI is your friend. It provides a machine-readable way to describe your API, making it much easier for AI to generate code.

  • Human developers are still essential. They are the architects, reviewers, and refiners, ensuring the quality, security, and maintainability of the code.

  • The future is collaborative. The most effective workflow involves humans and AI working together, leveraging each other's strengths.


What's Next?

We're continuing to explore how AI can further streamline backend development. We're particularly interested in:

  • Improved AI understanding of complex business logic.

  • Automated generation of more comprehensive test suites.

  • AI-powered tools for managing database migrations.

  • AI-assisted code refactoring and optimisation.


The journey of AI-assisted development is just beginning, and we're excited to be at the forefront of this evolution. Stay tuned to Heveloon for more updates!


 
 
 

Comentários


bottom of page