# README
Graph Project
Overview
This project focuses on graph structures and algorithms such as Dijkstra's algorithm and Minimum Spanning Tree (MST). Our main server is built using Go with the Gin framework, the frontend is developed using JavaScript and the vis.js library, and we also have a graph recognition module from images using Python with OpenCV and NumPy libraries. The graph recognition server is hosted using Flask.
Project Structure
- Backend (Go):
- Framework: Gin
- Main File:
cmd/main.go
- Frontend (JavaScript):
- Library: vis.js
- Graph Recognition (Python):
- Libraries: OpenCV, NumPy
- Server: Flask
- Main File:
graph-recognition/main.py
Prerequisites
- Go installed
- Python 3 installed
- PostgreSQL installed and running
- Make installed
Setup Instructions
1. Clone the Repository
git clone <repository_url>
cd <repository_name>
2. Setting Up Environment Variables
To set up the necessary environment variables, follow these steps:
-
Modify
.env
File: Open the copied.env
file and replaceYOUR_PASSWORD
with your actual PostgreSQL password. Your.env
file should look like this:DB_PASSWORD=YOUR_PASSWORD
Save the changes.
-
Configure
config.yaml
File: Navigate to theconfigs
directory and locate theconfig.yaml
file. Open it in a text editor. You can adjust the database connection settings according to your environment. Here's an example of the configuration section:db: host: "localhost" port: "5432" user: "postgres" db_name: "graph_db"
Modify the values as needed. Ensure that the
host
,port
,user
, anddb_name
fields match your PostgreSQL configuration. Additionally, you can adjust thebind_addr
value if you need to change the server's binding address and port. Save the changes toconfig.yaml
.
3. Combined Commands
-
Run All Go Commands:
make all_go
-
Run All Python Commands (for macOS/Linux):
make all_python_mac
-
Run All Python Commands (for Windows):
make all_python_windows
4. Backend Setup (Go)
-
Download Packages:
make download_packages
-
Build the Project:
make build
-
Run the Server:
make run
-
Database Migrations:
- Create Migrations:
make create_migrations
- Apply Migrations:
make migrate_up POSTGRES_PASSWORD=YOUR_PASSWORD
- Rollback Migrations:
make migrate_down POSTGRES_PASSWORD=YOUR_PASSWORD
5. Graph Recognition Setup (Python)
-
Create Virtual Environment:
make create_venv
-
Activate Virtual Environment:
- For Windows:
make activate_venv_windows
- For macOS/Linux:
make activate_venv_macOs
-
Install Requirements:
make install_requirements
-
Run Flask Server:
make run_flask