Skip to content
DozorovPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

MemeMint Backend

A NestJS backend for a Solana meme coin trading platform similar to "Baggs".

Features

  • Authentication System: JWT-based authentication with registration and login
  • User Management: User profiles with Solana wallet integration
  • Database: PostgreSQL with Supabase integration
  • Security: Password hashing with bcrypt, input validation
  • Error Handling: Global exception filters and validation

Tech Stack

  • Framework: NestJS with TypeScript
  • Database: PostgreSQL (Supabase)
  • ORM: TypeORM
  • Authentication: JWT tokens with Passport.js
  • Validation: class-validator and class-transformer
  • Password Hashing: bcrypt

Setup

  1. Install dependencies:

    npm install
  2. Environment Configuration:

    • Copy config.example to .env
    • Fill in your Supabase credentials and other configuration
  3. Database Setup:

    • Create a Supabase project
    • Get your database URL and API keys
    • Update the .env file with your credentials
  4. Run the application:

    # Development
    npm run start:dev
    
    # Production build
    npm run build
    npm run start:prod

API Endpoints

Authentication

  • POST /api/auth/register - User registration
  • POST /api/auth/login - User login
  • GET /api/auth/profile - Get user profile (protected)
  • GET /api/auth/validate - Validate JWT token (protected)

Request/Response Examples

Registration

POST /api/auth/register
Content-Type: application/json

{
  "email": "user@example.com",
  "username": "trader123",
  "password": "SecurePass123!",
  "firstName": "John",
  "lastName": "Doe",
  "solanaWalletAddress": "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM"
}

Login

POST /api/auth/login
Content-Type: application/json

{
  "usernameOrEmail": "trader123",
  "password": "SecurePass123!"
}

Response Format

{
  "user": {
    "id": "uuid",
    "email": "user@example.com",
    "username": "trader123",
    "firstName": "John",
    "lastName": "Doe",
    "solanaWalletAddress": "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM",
    "balance": 0,
    "isActive": true,
    "isEmailVerified": false,
    "createdAt": "2024-01-01T00:00:00.000Z",
    "updatedAt": "2024-01-01T00:00:00.000Z"
  },
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}

Environment Variables

# Database Configuration
DATABASE_URL=postgresql://username:password@localhost:5432/mememint
SUPABASE_URL=your_supabase_project_url
SUPABASE_ANON_KEY=your_supabase_anon_key
SUPABASE_SERVICE_ROLE_KEY=your_supabase_service_role_key

# JWT Configuration
JWT_SECRET=your_super_secret_jwt_key_here
JWT_EXPIRES_IN=7d

# Application Configuration
PORT=3000
NODE_ENV=development

Database Schema

Users Table

  • id (UUID, Primary Key)
  • email (String, Unique)
  • username (String, Unique)
  • password (String, Hashed)
  • firstName (String, Optional)
  • lastName (String, Optional)
  • solanaWalletAddress (String, Optional)
  • balance (Decimal, Default: 0)
  • isActive (Boolean, Default: true)
  • isEmailVerified (Boolean, Default: false)
  • createdAt (Timestamp)
  • updatedAt (Timestamp)

Security Features

  • Password strength validation
  • JWT token-based authentication
  • Password hashing with bcrypt (12 rounds)
  • Input validation and sanitization
  • CORS configuration
  • Global exception handling

Development

# Watch mode
npm run start:dev

# Debug mode
npm run start:debug

# Run tests
npm run test

# Run tests in watch mode
npm run test:watch

# Generate coverage report
npm run test:cov

Next Steps

This backend provides the foundation for a meme coin trading platform. You can extend it with:

  • Solana blockchain integration
  • Token creation and trading endpoints
  • Real-time WebSocket connections
  • Email verification system
  • Admin panel
  • Rate limiting
  • Logging system
  • API documentation with Swagger

License

This project is licensed under the UNLICENSED License.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages