How srivathsav999/ai-planet-assignment works
Project type and purpose
• This is a full-stack web application called “ai-planet-assignment.”
• Purpose: Allow users to upload PDF documents via a React UI and ask AI-powered questions about their content.
• Frontend: React app with drag-and-drop file upload and chat interface.
• Backend: FastAPI service handling file storage, text extraction, database persistence, and Q&A via LlamaIndex/OpenAI.
File structure
• Top-level directories:
• backend/ – FastAPI code, models, database config, QA engine, utils, upload directory
• frontend/ – React code, components, API service, static assets, Vite config
• Backend:
• main.py (controllers/routes: health, /upload, /ask)
• qa_engine.py (business logic: build index, call OpenAI)
• database.py & models.py (SQLAlchemy async, documents table)
• uploads/ (file system storage)
• Frontend:
• src/components – ChatInterface.jsx, FileUpload.jsx, ThemeToggle.jsx
• src/services/api.js – axios or fetch wrappers to call FastAPI endpoints
• index.html, App.jsx, styling files
• Config/build files:
• backend/requirements.txt, .gitignore
• frontend/package.json, vite.config.js, eslint.config.js
README for additional insights
• Endpoints: GET / (health), POST /upload, POST /ask
• Tech stack details: React, FastAPI, SQLAlchemy (SQLite), PyMuPDF, LlamaIndex, OpenAI
• Database: documents table with id, filename, content, created_at
• Error handling and CORS notes
Detailed capturing of essential elements
• Do not oversimplify: break down the backend into its submodules (controllers vs. extraction vs. QA vs. persistence).
• Local filesystem storage separate from the DB.
• Async operations where relevant (e.g., file I/O, DB access, API calls).
• Configurations (CORS, .env for API key).