Pixlon is a Next.js application designed to allow admins to upload and manage profile pictures, banners, and other related media that can be downloaded by visitors. This project uses Prisma with MongoDB for data management, NextAuth for authentication, and Docker for containerization.
- User authentication using NextAuth
- Image upload and management
- Prisma ORM for database interactions
- MongoDB as the database
- Docker for containerization
- Node.js
- Docker and Docker Compose
- MongoDB
git clone https://github.com/your-username/pixlon.git
cd pixlon
npm install
Create a .env.local
file in the root of the project and add the following environment variables:
DATABASE_URL="mongodb://root:example@mongo:27017/mydatabase?authSource=admin"
NEXTAUTH_URL="http://localhost:3000"
IMAGE_UPLOAD_DIR="/app/public/uploads"
Ensure Docker and Docker Compose are installed on your machine. Then, build and start the Docker containers:
docker-compose build
docker-compose up
The application will be available at http://localhost:3000
.
app/
- Contains the Next.js pagesapp/api/
- Contains the API routeslib/
- Contains configuration files and utility functionsmodels/
- Contains Mongoose modelsprisma/
- Contains Prisma schemapublic/uploads/
- Directory to store uploaded images
- Endpoint:
POST /api/upload
- Description: Handles image uploads
- Request Body:
file
(multipart/form-data)
- Endpoint:
POST /api/admin/create
- Description: Creates an admin user
- Request Body:
{ "username": "admin", "password": "password123" }
To run the application locally without Docker:
- Ensure MongoDB is running locally or adjust
DATABASE_URL
in.env.local
. - Install dependencies and run the development server:
npm install
npm run dev
To create a production build:
npm run build
npm start
- Container Restarting: Ensure the
next build
command runs successfully during Docker image build. - Environment Variables: Verify that all required environment variables are correctly set in
.env.local
.
This project is licensed under the MIT License.
Contributions are welcome! Please open an issue or submit a pull request.