oneCard is a high-performance digital cards marketplace built with modern web technologies. This platform enables users to create, buy, and manage digital business cards with a focus on scalability, maintainability, and developer experience.
- MVC Architecture - Clean separation of concerns in backend
- Next.js 14 - App Router, Server Components, and ISR
- Scalable Infrastructure - Docker Compose ready for production
- Responsive Design - Mobile-first UI with Tailwind CSS
backend/
βββ config/ # Environment configs & DB connection
βββ controllers/ # Business logic (MVC Controllers)
βββ models/ # Data schemas (MVC Models)
βββ routes/ # API endpoints (MVC Routes)
βββ services/ # Reusable business logic (for scaling)
βββ utils/ # Helpers, middleware, error handlers
βββ validations/ # Request validation schemas
βββ server.js # Entry point
frontend/
βββ app/ # Next.js App Router structure
β βββ (auth)/ # Authentication routes
β βββ api/ # Server-side API routes
β βββ cards/ # Card management routes
β βββ dashboard/ # User dashboard
β βββ layout.tsx # Root layout
β βββ page.tsx # Home page
βββ components/ # Reusable UI components
βββ lib/ # Shared logic (API clients, utils)
βββ public/ # Static assets
βββ styles/ # Global styles
βββ next.config.js # Next.js configuration
- Node.js v18+
- MongoDB (local or cloud instance)
- Docker (optional for containerized setup)
git clone https://github.com/aliBenhenia/OneCard-Morocco
cd OneCard-Morocco
Frontend (Next.js):
cd frontend
npm install -f # Force install to handle potential peer dependency issues
npm run dev
Backend (Express):
cd ../backend
npm install
npm install -g nodemon # Global installation for development
nodemon src/server.js
Frontend runs at: http://localhost:3000
Backend API runs at: http://localhost:3001
docker-compose up --build
This will:
- Build and run frontend container (port 3000)
- Build and run backend container (port 3001)
graph LR
A[Client Request] --> B[Routes]
B --> C[Controllers]
C --> D[Services]
D --> E[Models]
E --> F[MongoDB]
F --> E
E --> D
D --> C
C --> B
B --> A
- Routes: Define API endpoints (
/api/cards
,/api/users
) - Controllers: Handle request/response logic
- Services: Reusable business logic (decoupled from HTTP)
- Models: Data schemas and database operations
- Service Layer: Critical for microservices transition later
- Validation Separation: Dedicated validation layer prevents controller bloat
- Middleware Pipeline: Custom middleware for auth, logging, errors
- Next.js App Router: Built-in caching, data fetching, and route handlers
graph TB
A[Client] --> B[Nginx Load Balancer]
B --> C[Frontend Cluster]
B --> D[Backend Cluster]
D --> E[Redis Cache]
D --> F[MongoDB Cluster]
D --> G[Payment Service]
D --> H[Notification Service]
For future scaling:
- Frontend: CDN + Static Export (Next.js)
- Backend: Kubernetes pods with auto-scaling
- Database: MongoDB Atlas sharding
- Caching: Redis for session and query caching
- Async Processing: RabbitMQ for background jobs
- Single Express server
- Next.js frontend
- MongoDB replica set
- Extract User Service
- Create Card Processing Service
- Implement Notification Service
- Separate Payment Gateway
- Frontend: Vercel/Netlify (SSG)
- Backend: AWS ECS/Fargate
- Database: MongoDB Atlas
- Infrastructure: Terraform-managed
npm run dev # Start dev server
npm run build # Create production build
npm run lint # Run linter
npm start # Production start
npm run dev # Dev mode with nodemon
npm test # Run tests
docker-compose up # Start full stack
docker-compose down # Stop containers
docker-compose logs -f # Follow logs
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under MIT License. See LICENSE
for more information.
Pro Tip: For production deployment, always use
docker-compose -f docker-compose.prod.yml up -d
with production-optimized configuration. The development setup includes hot-reloading and debugging tools not suitable for production.
oneCard - Where digital connections begin β¨