Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debate AI Architecture Proposal (Microservices Architecture) #20

Open
ParagGhatage opened this issue Jan 6, 2025 · 3 comments
Open

Comments

@ParagGhatage
Copy link

ParagGhatage commented Jan 6, 2025

Description

This is a proposal for the architecture of the AI Debate Tool aimed at helping users improve their debating skills through interaction with an AI. The architecture includes model selection, technologies for backend and frontend, as well as possible future features like real-time debates.


High-Level Architecture Overview

1. Frontend:

  • React.js/Next.js: For dynamic UI and server-side rendering.
  • TailwindCSS: For styling and responsive design.

2. Backend:

  • Flask/FastAPI: For creating the REST API endpoints.
  • Celery with Redis: For handling background tasks like model inference.

3. AI Logic Layer:

  • GPT-2: For generating AI arguments.
  • DistilBERT: For evaluating and analyzing user-submitted arguments.
  • T5/BART: For scoring the debate and generating feedback.
  • PyTorch/TensorFlow: For running the models.

4. Database:

  • PostgreSQL: For storing user data, debate history, and feedback.
  • Redis: For caching and session management.

5. Future Possibility (User vs User Debate):

  • WebSockets (Socket.io): For implementing real-time, user-vs-user debates.

6. Deployment:

  • Docker: For containerizing the application.
  • Gunicorn: For production deployment

Directory structure -

      ├── README.md                        # Project Overview
      ├── LICENSE                          # License Information
      ├── .gitignore                       # Git Ignore File
      ├── backend/                         # Backend Codebase
      │   ├── README.md                    # Backend Documentation
      │   ├── go.mod                       # Golang Dependency Management
      │   ├── go.sum                       # Golang Dependency Management
      │   ├── routes.go                    # API Routing for Golang Backend
      │   ├── todo.txt                     # Backend TODO List
      │   ├── cmd/
      │   │   └── server/
      │   │       └── main.go              # Main Entry Point for Backend Server
      │   ├── ai_service/                  # Microservice for AI
      │   │   ├── README.md                # AI Service Documentation
      │   │   ├── requirements.txt         # Python Dependencies for AI
      │   │   ├── app.py                   # Flask/FastAPI Main App
      │   │   ├── models/
      │   │   │   ├── model.py             # Pre-trained AI Model
      │   │   │   ├── tokenizer.py         # Tokenization Logic
      │   │   │   └── debate_nlp.py        # NLP Model Functions for Arguments
      │   │   ├── scripts/
      │   │   │   ├── preprocess.py        # Data Preprocessing Scripts
      │   │   │   └── train.py             # Training New Models
      │   │   └── tests/
      │   │       └── test_ai_service.py   # Unit Tests for AI Service
      │   ├── websocket_service/           # Real-Time Debate Service
      │   │   ├── main.go                  # WebSocket Implementation in Golang
      │   │   ├── handlers.go              # WebSocket Handlers
      │   │   └── utils.go                 # Utility Functions for WebSocket
      │   ├── auth_service/                # User Authentication Service
      │   │   ├── main.go                  # Auth Service in Golang
      │   │   ├── jwt_utils.go             # JWT Token Management
      │   │   └── database/
      │   │       └── schema.sql           # Database Schema for Users
      │   └── shared/
      │       └── config/                  # Shared Configurations
      │           ├── database.go          # DB Config for Golang
      │           ├── env_config.go        # Environment Variables
      │           └── logger.go            # Logging Utility
      ├── frontend/                        # Frontend Codebase
      │   ├── README.md                    # Frontend Documentation
      │   ├── components.json              # shadcn Components
      │   ├── eslint.config.js             # Linting Rules
      │   ├── index.html                   # Entry HTML File
      │   ├── package-lock.json            # NPM Lock File
      │   ├── package.json                 # Dependencies and Scripts
      │   ├── postcss.config.js            # PostCSS Configuration
      │   ├── tailwind.config.js           # Tailwind CSS Configuration
      │   ├── tsconfig.app.json            # TypeScript Config (App Specific)
      │   ├── tsconfig.json                # TypeScript Config (Root)
      │   ├── tsconfig.node.json           # TypeScript Config (Node Specific)
      │   ├── vite.config.ts               # Vite Config File
      │   ├── public/                      # Public Assets (Static Files)
      │   ├── src/
      │   │   ├── App.css                  # Global Styles
      │   │   ├── App.tsx                  # App Entry Point
      │   │   ├── index.css                # Tailwind Base Styles
      │   │   ├── main.tsx                 # Main File to Render React App
      │   │   ├── vite-env.d.ts            # Vite Environment Types
      │   │   ├── Pages/                   # React Pages
      │   │   │   ├── Home.tsx             # Home Page
      │   │   │   ├── Debate.tsx           # Debate Session Page
      │   │   │   ├── Dashboard.tsx        # User Dashboard
      │   │   │   └── Authentication.tsx   # Authentication Page
      │   │   ├── assets/                  # Static Assets (Images, Icons)
      │   │   ├── components/              # Reusable Components
      │   │   │   ├── Debate/              # Debate-Specific Components
      │   │   │   │   ├── DebateInput.tsx  # User Input Box for Debates
      │   │   │   │   ├── ArgumentCard.tsx # Display User/AI Arguments
      │   │   │   │   └── Timer.tsx        # Timer for Debate Sessions
      │   │   │   └── ui/                  # UI Components (Buttons, Inputs)
      │   │   │       ├── button.tsx       # Button Component
      │   │   │       ├── input.tsx        # Input Field Component
      │   │   │       ├── label.tsx        # Label Component
      │   │   │       └── separator.tsx    # Separator Line Component
      │   │   ├── context/                 # Global React Context
      │   │   │   ├── theme-provider.tsx   # Dark/Light Theme Management
      │   │   │   └── debate-context.tsx   # Context for Real-Time Debate State
      │   │   ├── lib/                     # Utility Functions
      │   │   │   ├── api.ts               # API Call Utilities
      │   │   │   └── utils.ts             # General Utilities
      │   │   └── styles/                  # Component/Global Styles
      ├── docs/                            # Project Documentation
      │   ├── architecture.md              # Architecture Overview
      │   ├── api-design.md                # API Design Details
      │   ├── workflows.md                 # Developer Workflows
      │   └── installation.md              # Installation Instructions
      └── tests/                           # End-to-End and Integration Tests
          ├── backend_tests/               # Backend Test Suites
          │   ├── ai_service_tests.py      # Tests for AI Service
          │   ├── websocket_tests.go       # Tests for WebSocket
          │   └── auth_tests.go            # Tests for Auth Service
          └── frontend_tests/              # Frontend Test Suites
              ├── debate_test.spec.ts      # Tests for Debate Components
              ├── auth_test.spec.ts        # Tests for Auth Components
              └── e2e/                     # End-to-End Tests
                  └── debate_e2e.spec.ts   # Full Debate Flow Testing ```
## Workflow Overview

1. **User Logs In / Registers**:
   - User logs in or registers, initiating a session.

2. **User Starts a Debate**:
   - The user either selects a topic or allows the AI to generate one.
   - Backend uses **GPT-2** to generate the AI's argument.

3. **User Submits Argument**:
   - User inputs their argument, which is analyzed using **DistilBERT** for clarity and logic.

4. **Feedback and Scoring**:
   - **T5/BART** is used to generate feedback and a score based on the user's argument.

5. **User vs. User Debate (Future)**:
   - Real-time debates with live feedback using **Socket.io** and **WebSocket**.

---

## Technical Stack

- **Frontend**: React.js, Next.js, TailwindCSS
- **Backend**: Flask/FastAPI, Celery with Redis
- **AI Models**: GPT-2, DistilBERT, T5/BART (via Hugging Face)
- **Database**: PostgreSQL, Redis
- **Real-time Features (Future)**: Socket.io/WebSocket for user-vs-user debates
- **Deployment**: Docker, Gunicorn

---

## Next Steps

1. Upon receiving approval, I will implement the architecture as described.
2. Routes, models, and integration with the AI logic layer will be set up.
3. Future feature implementation: WebSockets for user-vs-user debates.

---

Let me know if there are any adjustments or clarifications needed. Looking forward to your feedback!

## After setting basic architecture, I will create some issues for different components, so that other contributors can work on those issues.
@adilkadivala
Copy link

adilkadivala commented Jan 6, 2025

please include graphql to make sure to fetching and sending necessary data to end-user,
and also any ORM for simplicity and easy to migrate from one database to another if needed,
and instead of using flask honoapi is more make sense in next.js due to it's high performance.
Redis io is quit fit more than Celery with Redis:

here what I mean

  1. Frontend
  • Next.js: For server-side rendering, API routes, and React components
  • TailwindCSS: For responsive and customizable styling
  • Shadcn ui: For Beautifully designed components
  • Apollo Client: For GraphQL data fetching and state management
  1. Backend
  • Hono-api: For handling server-side logic and API endpoints
  • Prisma: As an ORM for database interactions
  • Redis: for caching and session

else all seems workable..

please Let me know how did you get this @ParagGhatage

@ParagGhatage
Copy link
Author

Hey @adilkadivala ,
There are some major architecture changes needed.
I will be editing this issue with the finalized architecture of the project in a few days.

@adilkadivala
Copy link

Let's make it togather @ParagGhatage

@ParagGhatage ParagGhatage changed the title DebateAI Architecture Proposal Debate AI Architecture Proposal (Microservices Architecture) Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants