This project is a decentralized exchange (DEX) that facilitates swap operations between Solana (SOL) and USDT. The backend utilizes PostgreSQL for database management, and the frontend is built using Next.js with integration for authentication and token management.
- Swap Operations: Allows swapping between Solana and USDT using Jupiter's swap API.
- Token Balances: Fetches and displays token balances and their USD value.
- Authentication: User authentication via NextAuth.
- Dynamic UI: Responsive and dynamic frontend components for a seamless user experience.
- Docker
- Node.js (v14 or higher)
- PostgreSQL
- Solana CLI (for local development)
-
Pull PostgreSQL Docker Image
docker pull postgres:latest
-
Run PostgreSQL Container
docker run --name postgres-container -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=yourpassword -e POSTGRES_DB=yourdatabase -p 5432:5432 -d postgres:latest
Replace
yourpassword
andyourdatabase
with your desired password and database name.
-
Clone the Repository
git clone https://github.com/your-repo/decentralized-exchange.git cd decentralized-exchange
-
Install Dependencies
cd backend npm install
-
Set Up Environment Variables
Create a
.env
file in thebackend
directory and add the following variables:DATABASE_URL=postgres://postgres:yourpassword@localhost:5432/yourdatabase SOLANA_CLUSTER=https://mainnet.helius-rpc.com/?api-key=your_api_key
Replace
yourpassword
,yourdatabase
, andyour_api_key
with your PostgreSQL password, database name, and Solana API key, respectively. -
Run Migrations
If applicable, run migrations to set up your database schema.
npm run migrate
-
Start the Backend Server
npm start
-
Install Dependencies
cd frontend npm install
-
Set Up Environment Variables
Create a
.env.local
file in thefrontend
directory and add the following variables:NEXT_PUBLIC_API_URL=http://localhost:3000/api
Adjust
NEXT_PUBLIC_API_URL
if your API runs on a different URL or port. -
Start the Frontend Server
npm run dev
-
Access the Application
Open your browser and navigate to
http://localhost:3000
. -
Authentication
Sign in using Google authentication. Ensure that your Google OAuth credentials are properly configured in the NextAuth settings.
-
Swap Tokens
Use the provided UI to perform swap operations between Solana and USDT.
-
View Token Balances
Navigate to the token management section to view and manage your token balances.
Contributions are welcome! Please open an issue or submit a pull request for any enhancements or bug fixes.