|
1 |
| -# pariksa |
| 1 | +# Mint |
2 | 2 |
|
3 |
| -## Migrations |
| 3 | +A modern platform for conducting programming contests and managing coding problems. |
| 4 | + |
| 5 | +## Development Setup |
| 6 | + |
| 7 | +### Prerequisites |
| 8 | + |
| 9 | +- Node.js 22.2.0+ and npm |
| 10 | +- Docker |
| 11 | +- [Bun](https://bun.sh) (recommended package manager) |
| 12 | + |
| 13 | +### Quick Start |
| 14 | + |
| 15 | +1. Clone the repository |
| 16 | + |
| 17 | +2. Install dependencies |
4 | 18 |
|
5 | 19 | ```bash
|
6 |
| -npx drizzle-kit generate # generate SQL migration files based on your Drizzle schema |
7 |
| -npx drizzle-kit migrate # apply generated SQL migration files to your database |
| 20 | +bun install |
8 | 21 | ```
|
9 | 22 |
|
10 |
| -> [!NOTE] |
11 |
| -> Use `bun` instead of `npx` if you are using `bun`. |
| 23 | +3. Set up environment variables |
12 | 24 |
|
13 |
| ---- |
| 25 | +```bash |
| 26 | +cp .env.example .env |
| 27 | +``` |
14 | 28 |
|
15 |
| -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). |
| 29 | +4. Start the database |
16 | 30 |
|
17 |
| -## Getting Started |
| 31 | +```bash |
| 32 | +bun pg |
| 33 | +``` |
18 | 34 |
|
19 |
| -First, run the development server: |
| 35 | +5. Run migrations and seed data |
| 36 | + |
| 37 | +```bash |
| 38 | +bun db:migrate |
| 39 | +bun db:superuser # Create an admin user |
| 40 | +bun db:seed # Add test data (optional) |
| 41 | +``` |
| 42 | + |
| 43 | +6. Start the development server |
20 | 44 |
|
21 | 45 | ```bash
|
22 |
| -npm run dev |
23 |
| -# or |
24 |
| -yarn dev |
25 |
| -# or |
26 |
| -pnpm dev |
27 |
| -# or |
28 | 46 | bun dev
|
29 | 47 | ```
|
30 | 48 |
|
31 |
| -Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. |
| 49 | +Visit `http://localhost:3000` to see the application. |
| 50 | + |
| 51 | +## Available Commands |
| 52 | + |
| 53 | +### Development |
| 54 | + |
| 55 | +```bash |
| 56 | +bun dev # Start development server |
| 57 | +bun build # Build for production |
| 58 | +bun start # Start production server |
| 59 | +bun lint # Run ESLint |
| 60 | +bun format # Format code with Prettier |
| 61 | +bun format:check # Check code formatting |
| 62 | +``` |
| 63 | + |
| 64 | +### Database Management |
| 65 | + |
| 66 | +#### PostgreSQL Control |
| 67 | + |
| 68 | +```bash |
| 69 | +bun pg # Start PostgreSQL container |
| 70 | +bun pg:stop # Stop and remove PostgreSQL container |
| 71 | +``` |
| 72 | + |
| 73 | +Connection Details: |
| 74 | + |
| 75 | +- Host: `localhost` (from host) or `mint-postgres` (from containers) |
| 76 | +- Port: `5432` |
| 77 | +- Database: `mint` |
| 78 | +- Username: `postgres` |
| 79 | +- Password: `postgres` |
| 80 | +- URL: `postgres://postgres:postgres@localhost:5432/mint` |
| 81 | + |
| 82 | +#### pgAdmin (Database UI) |
| 83 | + |
| 84 | +```bash |
| 85 | +bun pg-admin # Start pgAdmin web interface |
| 86 | +bun pg-admin:stop # Stop and remove pgAdmin container |
| 87 | +``` |
| 88 | + |
| 89 | +Access Details: |
| 90 | + |
| 91 | +- URL: http://localhost:5050 |
| 92 | + |
| 93 | +- Password: `admin` |
| 94 | + |
| 95 | +#### Database Operations |
| 96 | + |
| 97 | +```bash |
| 98 | +bun db:migrate # Generate and apply database migrations |
| 99 | +bun db:seed # Add test data to database |
| 100 | +bun db:clear # Clear all data from database |
| 101 | +bun db:superuser # Create an admin user interactively |
| 102 | +``` |
| 103 | + |
| 104 | +### Test Data |
32 | 105 |
|
33 |
| -You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. |
| 106 | +The seeding process creates: |
34 | 107 |
|
35 |
| -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. |
| 108 | +- Admin users (2) |
| 109 | +- Organizer users (3) |
| 110 | +- Regular users (5) |
| 111 | +- Organizations (3) |
| 112 | +- Problems per organization (2) |
| 113 | +- Contests per organization (2) |
| 114 | +- Groups per organization (2) |
36 | 115 |
|
37 |
| -## Learn More |
| 116 | +All test users are created with password: `password123` |
38 | 117 |
|
39 |
| -To learn more about Next.js, take a look at the following resources: |
| 118 | +## Project Structure |
| 119 | + |
| 120 | +```bash |
| 121 | +mint/ |
| 122 | +├── app/ # Next.js app router pages |
| 123 | +├── components/ # React components |
| 124 | +├── db/ # Database schema and migrations |
| 125 | +├── lib/ # Utility functions and shared logic |
| 126 | +├── public/ # Static assets |
| 127 | +└── scripts/ # CLI scripts for development |
| 128 | +``` |
40 | 129 |
|
41 |
| -- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. |
42 |
| -- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. |
| 130 | +## Troubleshooting |
| 131 | + |
| 132 | +### Database Issues |
| 133 | + |
| 134 | +1. If containers are already running: |
| 135 | + |
| 136 | +```bash |
| 137 | +docker stop mint-postgres mint-pgadmin |
| 138 | +docker rm mint-postgres mint-pgadmin |
| 139 | +``` |
| 140 | + |
| 141 | +1. If ports are in use: |
| 142 | + |
| 143 | +- Check if PostgreSQL is running locally: `sudo lsof -i :5432` |
| 144 | +- Check if something is using pgAdmin port: `sudo lsof -i :5050` |
| 145 | + |
| 146 | +2. To completely reset: |
| 147 | + |
| 148 | +```bash |
| 149 | +bun pg:stop |
| 150 | +bun pg-admin:stop |
| 151 | +bun pg |
| 152 | +bun pg-admin |
| 153 | +bun db:clear |
| 154 | +bun db:migrate |
| 155 | +bun db:seed |
| 156 | +``` |
| 157 | + |
| 158 | +> [!NOTE] |
| 159 | +> While Bun is recommended, you can still use npm by replacing `bun` with `npm run` in all commands. |
43 | 160 |
|
44 |
| -You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome! |
| 161 | +## Contributing |
45 | 162 |
|
46 |
| -## Deploy on Vercel |
| 163 | +1. Fork the repository |
| 164 | +2. Create your feature branch (`git checkout -b feature/amazing-feature`) |
| 165 | +3. Commit your changes (`git commit -m 'Add some amazing feature'`) |
| 166 | +4. Push to the branch (`git push origin feature/amazing-feature`) |
| 167 | +5. Open a Pull Request |
47 | 168 |
|
48 |
| -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. |
| 169 | +## License |
49 | 170 |
|
50 |
| -Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details. |
| 171 | +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. |
0 commit comments