This is a full-stack application for managing affiliate marketing campaigns and influencers. The platform allows brands to create campaigns, manage influencers, and track the performance of their affiliate marketing efforts.
- User authentication and authorization
- Campaign management (create, read, update, delete)
- Influencer profiles and management
- Campaign-influencer relationship tracking
- Responsive UI with modern design
The project is organized into two main directories:
fullstack-campaign-affiliate/
βββ backend/ # NestJS API server
βββ frontend/ # React client application
- Node.js (v16 or higher)
- MongoDB (v4.4 or higher)
- npm
-
Clone the repository:
git clone https://github.com/dansalahi/fullstack-campaign-affiliate.git cd fullstack-campaign-affiliate
-
Set up the backend:
cd backend npm install cp .env.sample .env # Then edit .env with your configuration
-
Set up the frontend:
cd ../frontend npm install
cd backend
# Development mode
npm run start:dev
# Production mode
npm run start:prod
# Seed the database with sample data
npm run seed
cd frontend
# Development mode
npm run dev
# Build for production
npm run build
cd backend
# Run unit tests
npm run test
# Run e2e tests
npm run test:e2e
# Generate test coverage report
npm run test:cov
cd frontend
# Run tests
npm run test
The backend is built with NestJS, a progressive Node.js framework for building efficient and scalable server-side applications.
- Authentication: JWT-based authentication system
- Database: MongoDB with Mongoose ODM
- API: RESTful API endpoints
- Validation: Request validation using class-validator
- Testing: Jest for unit and e2e tests
- Logging: Custom logger implementation
The frontend is built with React, using modern patterns and libraries:
- State Management: React Query for server state, Context API for application state
- Routing: React Router for navigation
- API Communication: Axios for API requests
- UI Components: Custom components with TailwindCSS
- Authentication: JWT stored in localStorage with automatic token refresh
The backend provides the following API endpoints:
POST /auth/register
- Register a new userPOST /auth/login
- Login and get JWT token
GET /users/profile
- Get current user profile
GET /campaigns
- Get all campaignsGET /campaigns/:id
- Get a specific campaignPOST /campaigns
- Create a new campaignPATCH /campaigns/:id
- Update a campaignDELETE /campaigns/:id
- Delete a campaign
GET /influencers
- Get all influencersGET /influencers/:id
- Get a specific influencerPOST /influencers
- Create a new influencerPATCH /influencers/:id
- Update an influencerDELETE /influencers/:id
- Delete an influencer
GET /campaign-influencers
- Get all campaign-influencer relationshipsGET /campaign-influencers/:id
- Get a specific relationshipPOST /campaign-influencers
- Create a new relationshipPATCH /campaign-influencers/:id
- Update a relationshipDELETE /campaign-influencers/:id
- Delete a relationship
The application comes with a seeding script that populates the database with sample data:
- Admin user:
[email protected]
/admin123
- Regular user:
[email protected]
/user123
- Summer Ebay affiliates
- Winter Amazon affiliates
- Michael Ryhe (1M followers)
- Sophie Martin (750K followers)
- Li Wei (2.5M followers)
- The backend uses MongoDB with Mongoose for data persistence
- JWT is used for authentication across both frontend and backend
- All API endpoints (except auth) require authentication
- The frontend includes protected routes that require authentication
- The application includes comprehensive error handling
When running e2e tests, you may see HTTP error logs (401, 404, 409) in the console. These are expected and are part of testing error handling in the API. The tests are successful if they all pass despite these error logs.
If you encounter MongoDB connection issues, ensure:
- MongoDB is running on your system
- The connection string in
.env
is correct - Network access is allowed to the MongoDB instance
If you experience authentication issues:
- Check that the JWT_SECRET in the backend
.env
file is set - Ensure the frontend is sending the JWT token in the Authorization header
- Verify that the token has not expired
This project is MIT licensed.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request