11# Mint
22
3- A modern platform for conducting programming contests and managing coding problems.
3+ ![ Mint Logo ] ( https://raw.githubusercontent.com/myselfaryan/Mint/main/public/image/logo.png )
44
5- ## Development Setup
5+ <p align =" center " >
6+ <b >Mint</b > is a modern, full-featured platform for conducting programming contests, managing coding problems, and building developer communities.
7+ </p >
68
7- ### Prerequisites
9+ <p align =" center " >
10+ <a href =" https://github.com/myselfaryan/Mint/actions " ><img src =" https://img.shields.io/github/actions/workflow/status/myselfaryan/Mint/ci.yml?branch=main&style=flat-square " alt =" Build Status " ></a >
11+ <a href =" https://github.com/myselfaryan/Mint/blob/main/LICENSE " ><img src =" https://img.shields.io/github/license/myselfaryan/Mint?style=flat-square " alt =" License " ></a >
12+ </p >
813
9- - Node.js 22.2.0+ and npm
10- - Docker
11- - [ Bun] ( https://bun.sh ) (recommended package manager)
14+ ---
1215
13- ### Quick Start
16+ ## ✨ Features
1417
15- 1 . Clone the repository
18+ - 🏆 Host and manage programming contests
19+ - 📚 Organize and share coding problems
20+ - 👥 Multi-organization support
21+ - 📊 Real-time monitoring and analytics (Prometheus)
22+ - 🔒 Secure authentication and user management
23+ - 📝 Interactive API documentation (Swagger)
24+ - ⚡ Fast, modern stack (Next.js, Bun, Drizzle, Tailwind CSS)
1625
17- 2 . Install dependencies
26+ ---
1827
19- ``` bash
20- bun install
21- ```
28+ ## 🚀 Quick Start
2229
23- 3 . Set up environment variables
30+ ### Prerequisites
31+ - Node.js 22.2.0+
32+ - Docker
33+ - [ Bun] ( https://bun.sh ) (recommended)
34+
35+ ### Setup
2436
2537``` bash
26- cp .env.example .env
27- ```
38+ # 1. Clone the repository
39+ bun install
2840
29- 4 . Start the database
41+ # 2. Copy environment variables
42+ cp .env.example .env
3043
31- ``` bash
44+ # 3. Start the database
3245bun pg
33- ```
3446
35- 5 . Run migrations and seed data
36-
37- ``` bash
47+ # 4. Run migrations and seed data
3848bun db:migrate
3949bun db:superuser # Create an admin user
40- bun db:seed # Add test data (optional)
41- ```
42-
43- 6 . Start the development server
50+ bun db:seed # (Optional) Add test data
4451
45- ``` bash
52+ # 5. Start the development server
4653bun dev
4754```
4855
49- Visit ` http://localhost:3000 ` to see the application.
50-
51- ## Available Commands
52-
53- ### Development
56+ Visit [ http://localhost:3000 ] ( http://localhost:3000 ) to see the app.
5457
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- ```
58+ ---
6359
64- ### Database Management
60+ ## 🛠️ Project Structure
6561
66- #### PostgreSQL Control
67-
68- ``` bash
69- bun pg # Start PostgreSQL container
70- bun pg:stop # Stop and remove PostgreSQL container
62+ ``` text
63+ mint/
64+ ├── app/ # Next.js app router pages
65+ │ ├── api-doc/ # Swagger API documentation
66+ │ └── api/ # API routes
67+ ├── components/ # React components
68+ ├── db/ # Database schema and migrations
69+ ├── lib/ # Utility functions and shared logic
70+ ├── middleware/ # Request middleware (logging, metrics, error handling)
71+ ├── public/ # Static assets
72+ └── scripts/ # CLI scripts for development
7173```
7274
73- Connection Details:
75+ ---
7476
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)
77+ ## ⚡ Available Commands
8378
8479``` bash
85- bun pg-admin # Start pgAdmin web interface
80+ bun dev # Start development server
81+ bun build # Build for production
82+ bun start # Start production server
83+ bun lint # Run ESLint
84+ bun format # Format code with Prettier
85+ bun format:check # Check code formatting
86+
87+ # Database
88+ bun pg # Start PostgreSQL container
89+ bun pg:stop # Stop and remove PostgreSQL container
90+ bun pg-admin # Start pgAdmin web interface
8691bun pg-admin:stop # Stop and remove pgAdmin container
92+ bun db:migrate # Generate and apply database migrations
93+ bun db:seed # Add test data to database
94+ bun db:clear # Clear all data from database
95+ bun db:superuser # Create an admin user interactively
8796```
8897
89- Access Details:
90-
91- - URL: http://localhost:5050
92- - Email: ` admin@admin.com `
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
105-
106- The seeding process creates:
107-
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)
115-
116- All test users are created with password: ` password123 `
117-
118- ## Project Structure
119-
120- ``` bash
121- mint/
122- ├── app/ # Next.js app router pages
123- │ ├── api-doc/ # Swagger API documentation
124- │ └── api/ # API routes
125- ├── components/ # React components
126- ├── db/ # Database schema and migrations
127- ├── lib/ # Utility functions and shared logic
128- ├── middleware/ # Request middleware (logging, metrics, error handling)
129- ├── public/ # Static assets
130- └── scripts/ # CLI scripts for development
131- ```
132-
133- ## Monitoring
134-
135- The application includes built-in monitoring with Prometheus metrics:
98+ ---
13699
137- - HTTP request counts and durations
138- - Active user counts
139- - Database query durations
100+ ## 🧪 Test Data
140101
141- Metrics are available at: ` http://localhost:3000/api/metrics `
102+ Seeding creates:
103+ - 2 Admin users
104+ - 3 Organizer users
105+ - 5 Regular users
106+ - 3 Organizations
107+ - 2 Problems, 2 Contests, 2 Groups per organization
142108
143- ### Available Metrics
109+ All test users: ` password123 `
144110
145- - ` http_requests_total ` : Counter of HTTP requests
146- - ` http_request_duration_ms ` : Histogram of HTTP request durations
147- - ` active_users ` : Gauge of currently active users
148- - ` db_query_duration_ms ` : Histogram of database query durations
111+ ---
149112
150- ### Prometheus Configuration
113+ ## 📊 Monitoring & Metrics
151114
152- Add to your ` prometheus.yml ` :
115+ - Built-in Prometheus metrics: HTTP requests, user counts, DB query durations
116+ - Metrics endpoint: [ http://localhost:3000/api/metrics ] ( http://localhost:3000/api/metrics )
153117
118+ ** Prometheus config:**
154119``` yaml
155120scrape_configs :
156121 - job_name : ' mint'
@@ -159,62 +124,52 @@ scrape_configs:
159124 metrics_path : ' /api/metrics'
160125` ` `
161126
162- ## Troubleshooting
127+ ---
163128
164- ### Database Issues
129+ ## 🩺 Troubleshooting
165130
166- 1. If containers are already running:
131+ - **Reset containers:**
132+ ` ` ` bash
133+ docker stop mint-postgres mint-pgadmin
134+ docker rm mint-postgres mint-pgadmin
135+ ```
136+ - ** Check ports:**
137+ ``` bash
138+ sudo lsof -i :5432 # PostgreSQL
139+ sudo lsof -i :5050 # pgAdmin
140+ ```
141+ - ** Full reset:**
142+ ``` bash
143+ bun pg:stop && bun pg-admin:stop && bun pg && bun pg-admin && bun db:clear && bun db:migrate && bun db:seed
144+ ```
167145
168- ` ` ` bash
169- docker stop mint-postgres mint-pgadmin
170- docker rm mint-postgres mint-pgadmin
171- ```
146+ > ** Note:** You can use ` npm run ` instead of ` bun ` if preferred.
172147
173- 1 . If ports are in use:
148+ ---
174149
175- - Check if PostgreSQL is running locally: ` sudo lsof -i :5432 `
176- - Check if something is using pgAdmin port: ` sudo lsof -i :5050 `
177-
178- 2 . To completely reset:
179-
180- ``` bash
181- bun pg:stop
182- bun pg-admin:stop
183- bun pg
184- bun pg-admin
185- bun db:clear
186- bun db:migrate
187- bun db:seed
188- ```
189-
190- > [ !NOTE]
191- > While Bun is recommended, you can still use npm by replacing ` bun ` with ` npm run ` in all commands.
192-
193- ## Contributing
150+ ## 🤝 Contributing
194151
1951521 . Fork the repository
1961532 . Create your feature branch (` git checkout -b feature/amazing-feature ` )
1971543 . Commit your changes (` git commit -m 'Add some amazing feature' ` )
1981554 . Push to the branch (` git push origin feature/amazing-feature ` )
1991565 . Open a Pull Request
200157
201- ## License
158+ ---
159+
160+ ## 📄 License
202161
203- This project is licensed under the MIT License - see the [ LICENSE] ( LICENSE ) file for details .
162+ MIT License. See [ LICENSE] ( LICENSE ) .
204163
205- ## API Documentation
164+ ---
206165
207- The API documentation is available at ` /api-doc ` when running the development server.
208- It provides:
166+ ## 📚 API Documentation
209167
210- - Interactive API documentation
168+ - Interactive docs at ` /api-doc ` (dev server)
211169- Request/response examples
212170- API endpoint testing interface
213171
214- ### Adding Documentation
215-
216- Add JSDoc comments with Swagger annotations to your API routes:
217-
172+ ** Add docs to API routes:**
218173``` typescript
219174/**
220175 * @swagger
@@ -227,9 +182,11 @@ Add JSDoc comments with Swagger annotations to your API routes:
227182 */
228183```
229184
230- ### Environment Variables
185+ ---
231186
232- Make sure your ` .env ` file includes:
187+ ## 🔑 Environment Variables
188+
189+ Copy ` .env.example ` to ` .env ` and fill in:
233190
234191``` env
235192DATABASE_URL=postgres://postgres:postgres@localhost:5432/mint
@@ -244,24 +201,11 @@ SMTP_FROM_NAME=Mint Platform
244201SMTP_FROM_EMAIL=noreply@example.com
245202```
246203
247- #### Email Configuration Details
248-
249- - ` SMTP_HOST ` : Your SMTP server hostname (e.g., smtp.gmail.com for Gmail)
250- - ` SMTP_PORT ` : SMTP port (usually 587 for TLS or 465 for SSL)
251- - ` SMTP_SECURE ` : Use ` true ` for port 465, ` false ` for other ports
252- - ` SMTP_USER ` : Your SMTP username/email
253- - ` SMTP_PASSWORD ` : Your SMTP password or app-specific password
254- - ` SMTP_FROM_NAME ` : Display name for sent emails
255- - ` SMTP_FROM_EMAIL ` : Email address used as sender
256-
257- #### Gmail Setup
258-
259- If using Gmail:
260- 1 . Enable 2-factor authentication
261- 2 . Generate an app password
262- 3 . Use the app password as ` SMTP_PASSWORD `
204+ ** Gmail setup:**
205+ - Enable 2FA
206+ - Generate an app password
207+ - Use as ` SMTP_PASSWORD `
263208
264- Example Gmail configuration:
265209``` env
266210SMTP_HOST=smtp.gmail.com
267211SMTP_PORT=587
@@ -270,4 +214,12 @@ SMTP_USER=your-gmail@gmail.com
270214SMTP_PASSWORD=your-app-specific-password
271215```
272216
217+ ---
218+
219+ ## 🙋 Contact
220+
221+ For questions, suggestions, or support, open an [ issue] ( https://github.com/myselfaryan/Mint/issues ) or contact [ @myselfaryan ] ( https://github.com/myselfaryan ) .
222+
223+ ---
224+
273225<!-- test ci deploy -->
0 commit comments