AlgorithmsOnlineLibrary is a web application for creating and storing algorithms.
- User authentication using JWT.
- Password hashing with bcrypt for security.
- Role-based access control (e.g., Admin, User).
- Algorithm submission and management.
- Email notifications for user-related actions.
- RESTful API design using Gorilla Mux.
- CORS support for cross-origin requests.
-
Clone the repository:
git clone https://github.com/yourusername/yourproject.git cd yourproject
-
Install Dependencies:
go mod tidy
-
Set Up the Environment:
Create a .env file in the root of your project and add the necessary environment variables (e.g., database connection string, JWT secret key).
DB_HOST=localhost DB_PORT=5432 DB_USER=yourusername DB_PASSWORD=yourpassword DB_NAME=yourdbname JWT_SECRET=my_secret_key EMAIL_HOST=smtp.example.com EMAIL_PORT=465 [email protected] EMAIL_PASSWORD=yourpassword
-
Set Up PostgreSQL:
Ensure you have PostgreSQL installed and running. Create the database and tables as described in the schema below.
psql -U yourusername -d yourdbname -a -f setup.sql
-
Install Frontend Dependencies:
Navigate to the frontend directory and install the dependencies.
cd frontend npm install
-
Start the Development Servers:
- Backend:
go run main.go
- Frontend:
npm start
Once the server is running, you can interact with the API using web-client (frontend on port http://localhost:3000) and tools like curl or Postman. The base URL is typically http://localhost:8080.
This project uses the following dependencies:
- Gorilla Mux: HTTP router and URL matcher for Go.
- JWT-Go: JSON Web Token implementation for Go, useful for handling authentication and authorization.
- Godotenv: Loads environment variables from a
.env
file into Go applications, simplifying configuration management. - Gomail: Package for sending emails in Go.
- CORS: Middleware for handling Cross-Origin Resource Sharing (CORS) in Go HTTP servers.
- bcrypt: Password hashing library for securely hashing and comparing passwords.
- Axios: Promise-based HTTP client for the frontend.
- POST /login: User login and JWT token generation.
- POST /register: Register a new user.
- GET /algorithms: Retrieve a list of all algorithms.
- POST /algorithms: Submit a new algorithm.
- GET /algorithms/{id}: Get details of a specific algorithm.
For detailed information about the database schema, see DATABASE_SCHEMA.md.
This project is licensed under the MIT License. See the LICENSE file for details.