The Structured Data Analyzer is a web application that allows users to upload CSV or Excel files, submit questions about the data, and receive detailed analysis and answers using LangChain and OpenAI's GPT model. The application includes both a frontend built with Next.js and a backend built with Flask.
Before running the application, ensure that you have the following installed:
git clone <repository-url>
cd structured-data-analyzerNavigate to the my-app directory (which is your project root) and install the required Python packages:
pip install -r requirements.txtCreate a .env file in the my-app directory and add your OpenAI API key:
OPENAI_API_KEY=your-openai-api-keyNavigate to the my-app directory (where package.json is located) and install the necessary Node.js packages:
npm installTo start the Flask backend, run:
python app.pyBy default, the backend will run on http://localhost:5000.
To start the Next.js frontend, run:
npm run devBy default, the frontend will run on http://localhost:3000.
-
Access the Application:
- Open your web browser and go to
http://localhost:3000.
- Open your web browser and go to
-
Upload a File:
- On the main page, upload a CSV or Excel file by clicking on the upload button or dragging and dropping the file.
-
Submit a Question:
- After the file is uploaded, type a question about the data in the input field and click "Submit".
-
View Results:
- The application will process the question and display the results below the input field.
- /components: Contains the React components used in the frontend.
- /pages: Contains the Next.js pages.
- /public: Static files and assets.
- /app.py: The Flask backend application file.
- /.env: Environment variables for the backend (not included in version control).
- /package.json: Node.js dependencies and scripts for the frontend.
- /requirements.txt: Python dependencies for the backend.
- OPENAI_API_KEY: Your OpenAI API key, required to interact with the GPT model.
- CORS Issues: If you encounter CORS errors, ensure that the Flask backend has CORS enabled as shown in the
app.pysetup. - API Key Issues: Ensure your
.envfile is correctly configured and theOPENAI_API_KEYis valid. - Port Conflicts: Ensure that no other applications are running on ports
3000(frontend) and5000(backend).
- Deployment: For production deployment, ensure to build the frontend using
npm run buildand consider using a production-ready server for Flask like Gunicorn. - Security: Never expose your
.envfile or API keys in public repositories. Always add.envto your.gitignorefile.
Contributions are welcome! Please fork the repository and create a pull request with your changes.
This project is licensed under the MIT License - see the LICENSE file for details.