Coder Social home page Coder Social logo

pixlon's Introduction

Pixlon

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.

Features

  • User authentication using NextAuth
  • Image upload and management
  • Prisma ORM for database interactions
  • MongoDB as the database
  • Docker for containerization

Prerequisites

  • Node.js
  • Docker and Docker Compose
  • MongoDB

Getting Started

1. Clone the Repository

git clone https://github.com/your-username/pixlon.git
cd pixlon

2. Install Dependencies

npm install

3. Environment Variables

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"

4. Docker Setup

Ensure Docker and Docker Compose are installed on your machine. Then, build and start the Docker containers:

docker-compose build
docker-compose up

5. Access the Application

The application will be available at http://localhost:3000.

Project Structure

  • app/ - Contains the Next.js pages
  • app/api/ - Contains the API routes
  • lib/ - Contains configuration files and utility functions
  • models/ - Contains Mongoose models
  • prisma/ - Contains Prisma schema
  • public/uploads/ - Directory to store uploaded images

API Endpoints

Image Upload

  • Endpoint: POST /api/upload
  • Description: Handles image uploads
  • Request Body: file (multipart/form-data)

Create Admin User

  • Endpoint: POST /api/admin/create
  • Description: Creates an admin user
  • Request Body:
    {
      "username": "admin",
      "password": "password123"
    }

Development

Running Locally

To run the application locally without Docker:

  1. Ensure MongoDB is running locally or adjust DATABASE_URL in .env.local.
  2. Install dependencies and run the development server:
npm install
npm run dev

Building for Production

To create a production build:

npm run build
npm start

Troubleshooting

Common Issues

  • 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.

License

This project is licensed under the MIT License.

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

Acknowledgments

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.