Skip to content

ICYou/full-stack-ai-chat

Repository files navigation

Welcome to AnaerobicAI

Anaerobic coffee fermentation is a unique process that enhances the flavor profile of coffee beans by fermenting them in an oxygen-free environment. For the drinker this means a more complex and rich cup of coffee.

They say that developers are machines that turn caffeine into code. As software engineers anaerobic coffe fuels our creativity and productivity, allowing us to craft elegant solutions and innovative applications. AnaerobicAI is an excercise in building a POC AI chat that fuels developers creativity and productivity.

Getting Started

Running the application directly - Docker Compose

To get started with AnaerobicAI, follow these steps:

  1. Clone the repository:
  2. Open the project directory in your terminal.
  3. Run docker-compose up -d to start the application.
  4. Open your web browser and go to http://localhost:8080 to access the chat interface.
  5. Start chatting and enjoy the AnaerobicAI experience!

First time running
Note that the first time you run the application, it may take some time to download the necessary model files. Try reloading the page after a few minutes if the chat continues to be disconnected.

Message respone time
Note that the response time for messages may vary depending on the model being used and the cpu and memory allocated to the docker container. It can take a few seconds to mintes for a response to be generated.

Architecture and features

AnaerobicAi is built using a Python django backend and a React SPA frontend. The backend handles the chat logic and interacts with the AI model, while the frontend provides a user-friendly interface for chatting. The application is containerized using Docker, making it easy to deploy and run in any environment.

Frontend

  • React SPA (Single Page Application)
  • Vite for fast development and build process
  • Tailwind CSS for styling
  • Shadcn UI components for building modern and responsive tailored UI components
  • Chat history is displayed in sidebar. Clicking a previous chat opens a dialog to display the conversation.
  • UI shows connection status. Messages can only be sent when connected.
  • Websocket connection attempts to reconnect if connection cannot be made.
  • Messages are sent through submit button or pressing enter key

Backend

  • Python
  • Django
  • Webscoket connection using Django Channels for real-time chat functionality
  • Daphne ASGI server for handling asynchronous requests and websockets
  • Huggingface transformers for AI model integration
  • Configurable AI models through ENV settings -- docker-compose sets this by default to Qwen/Qwen3-0.6B
  • Chat history is stored in PostgreSQL database
  • Chat history is accesible through REST API endpoints
  • Swagger page and OpenAPI schema for API documentation and testing available at http://localhost:8000/api/swagger/

Database

PostgreSQL integrates well with Django. In addition, it offers good vector support through the pgvector extension to support future AI vector search capabilities.

Docker

  • Docker for containerization
  • Docker Compose for managing multi-container applications (backend, frontend, database)
  • Python daphne server as Django backend server
  • Nginx as a static file server for the frontend
  • PostgreSQL as the database

Limitations

The current implementation of AnaerobicAI has some limitations:

  • Small model sizes (e.g., 0.6B parameters) may not provide the best quality responses.
  • Response times can be slow, especially for larger models or on systems with limited resources.
  • The system loads the model on startup, which may require significant resources depending on the model size.
  • The application was built as POC and is not optimized for production usage. It is missing critical features such as user authentication or advanced error handling. Above all it's not tuned for optimal performance or security.
  • Docker containers can be further optimized for size and build times by using multi-stage builds.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •