|
|
@@ -1,36 +1,141 @@
|
|
|
-This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
|
|
|
+# Vtorio - File Upload & Management System
|
|
|
|
|
|
-## Getting Started
|
|
|
+A Next.js-based file upload and management system with PostgreSQL database storage and comprehensive API documentation.
|
|
|
|
|
|
-First, run the development server:
|
|
|
+## Features
|
|
|
|
|
|
+- **File Upload**: Upload files via web interface or API
|
|
|
+- **File Management**: List, view, and download uploaded files
|
|
|
+- **Database Storage**: Files stored in PostgreSQL with metadata
|
|
|
+- **API Documentation**: Interactive Swagger/OpenAPI documentation
|
|
|
+- **REST API**: Full RESTful API for programmatic access
|
|
|
+
|
|
|
+## Quick Start
|
|
|
+
|
|
|
+### Prerequisites
|
|
|
+- Node.js 18+
|
|
|
+- PostgreSQL database
|
|
|
+- npm or yarn
|
|
|
+
|
|
|
+### Installation
|
|
|
+
|
|
|
+1. Clone the repository
|
|
|
+2. Install dependencies:
|
|
|
+```bash
|
|
|
+npm install
|
|
|
+```
|
|
|
+
|
|
|
+3. Set up environment variables:
|
|
|
+```bash
|
|
|
+cp .env.example .env
|
|
|
+# Edit .env with your database credentials
|
|
|
+```
|
|
|
+
|
|
|
+4. Set up the database:
|
|
|
+```bash
|
|
|
+npx prisma migrate dev
|
|
|
+```
|
|
|
+
|
|
|
+5. Start the development server:
|
|
|
```bash
|
|
|
npm run dev
|
|
|
-# or
|
|
|
-yarn dev
|
|
|
-# or
|
|
|
-pnpm dev
|
|
|
-# or
|
|
|
-bun dev
|
|
|
```
|
|
|
|
|
|
-Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
|
|
|
+The application will be available at `http://localhost:3000` (or next available port).
|
|
|
+
|
|
|
+## API Documentation
|
|
|
+
|
|
|
+### Interactive Documentation
|
|
|
+Visit `http://localhost:3000/api-docs` for interactive Swagger UI documentation where you can:
|
|
|
+- Test all API endpoints
|
|
|
+- Upload files via the web interface
|
|
|
+- View response schemas and examples
|
|
|
+- Download files directly
|
|
|
|
|
|
-You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
|
|
|
+### API Endpoints
|
|
|
|
|
|
-This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
|
|
|
+| Method | Endpoint | Description |
|
|
|
+|--------|----------|-------------|
|
|
|
+| POST | `/api/upload` | Upload a file (multipart/form-data) |
|
|
|
+| GET | `/api/files` | List all uploaded files with metadata |
|
|
|
+| GET | `/api/files/{id}` | Download a specific file by ID |
|
|
|
+| GET | `/api/openapi.json` | Raw OpenAPI specification |
|
|
|
|
|
|
-## Learn More
|
|
|
+### Example Usage
|
|
|
|
|
|
-To learn more about Next.js, take a look at the following resources:
|
|
|
+#### Upload a file via curl:
|
|
|
+```bash
|
|
|
+curl -X POST http://localhost:3000/api/upload \
|
|
|
+ -F "file=@/path/to/your/file.pdf"
|
|
|
+```
|
|
|
+
|
|
|
+#### List all files:
|
|
|
+```bash
|
|
|
+curl http://localhost:3000/api/files
|
|
|
+```
|
|
|
+
|
|
|
+#### Download a file:
|
|
|
+```bash
|
|
|
+curl http://localhost:3000/api/files/{file-id} --output downloaded-file.pdf
|
|
|
+```
|
|
|
+
|
|
|
+## Database Schema
|
|
|
+
|
|
|
+The application uses Prisma ORM with the following schema:
|
|
|
+
|
|
|
+- **File**: Stores file data and metadata
|
|
|
+ - `id`: Unique identifier
|
|
|
+ - `filename`: Original filename
|
|
|
+ - `mimetype`: MIME type of the file
|
|
|
+ - `size`: File size in bytes
|
|
|
+ - `data`: Binary file content
|
|
|
+ - `createdAt`: Upload timestamp
|
|
|
+ - `updatedAt`: Last update timestamp
|
|
|
+
|
|
|
+## Development
|
|
|
+
|
|
|
+### Database Management
|
|
|
+```bash
|
|
|
+# Reset database
|
|
|
+npx prisma migrate reset
|
|
|
+
|
|
|
+# View database
|
|
|
+npx prisma studio
|
|
|
+
|
|
|
+# Generate new migration
|
|
|
+npx prisma migrate dev --name your-migration-name
|
|
|
+```
|
|
|
+
|
|
|
+### Environment Variables
|
|
|
+Create a `.env` file with:
|
|
|
+```
|
|
|
+DATABASE_URL="postgresql://username:password@localhost:5432/vtorio"
|
|
|
+```
|
|
|
+
|
|
|
+## Deployment
|
|
|
+
|
|
|
+### Docker
|
|
|
+```bash
|
|
|
+# Build and run with Docker Compose
|
|
|
+docker-compose up --build
|
|
|
+```
|
|
|
|
|
|
-- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
|
|
|
-- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
|
|
|
+### Vercel
|
|
|
+1. Push to GitHub
|
|
|
+2. Import project on Vercel
|
|
|
+3. Add environment variables
|
|
|
+4. Deploy
|
|
|
|
|
|
-You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
|
|
|
+## Technologies Used
|
|
|
|
|
|
-## Deploy on Vercel
|
|
|
+- **Next.js 15** - React framework
|
|
|
+- **TypeScript** - Type safety
|
|
|
+- **PostgreSQL** - Database
|
|
|
+- **Prisma** - ORM
|
|
|
+- **Tailwind CSS** - Styling
|
|
|
+- **Swagger UI** - API documentation
|
|
|
+- **Docker** - Containerization
|
|
|
|
|
|
-The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
|
|
|
+## License
|
|
|
|
|
|
-Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
|
|
|
+MIT License - see LICENSE file for details.
|