livrare website cu erp si crm
This commit is contained in:
parent
28773e3a72
commit
5c7bf7c295
257 changed files with 31929 additions and 0 deletions
252
website/README.md
Normal file
252
website/README.md
Normal file
|
|
@ -0,0 +1,252 @@
|
|||
# DiDi Website (Next.js)
|
||||
|
||||
Componenta frontend a platformei DiDi - website public + dashboard client. Construit cu Next.js 16, integrat cu ERPNext (ERP/CRM), Stripe (plati), Keycloak (SSO) si platforma DiDi (analize AI).
|
||||
|
||||
## Cuprins
|
||||
|
||||
- [Arhitectura](#arhitectura)
|
||||
- [Stack tehnic](#stack-tehnic)
|
||||
- [Structura folder](#structura-folder)
|
||||
- [Quickstart](#quickstart)
|
||||
- [Pagini](#pagini)
|
||||
- [API routes](#api-routes)
|
||||
- [Integrari](#integrari)
|
||||
- [Documentatie detaliata](#documentatie-detaliata)
|
||||
|
||||
## Arhitectura
|
||||
|
||||
```
|
||||
Browser (client)
|
||||
|
|
||||
v
|
||||
+-----------------------------+
|
||||
| Website Next.js :3000 |
|
||||
| (SSR + API routes) |
|
||||
+-----+-------+-------+-------+
|
||||
| | |
|
||||
+-------+--+ +--+----+ +-+--------+
|
||||
| ERPNext | |Stripe | | Keycloak |
|
||||
| :8080 | | API | | :28080 |
|
||||
| (REST) | | | | (OIDC) |
|
||||
+----+-----+ +-------+ +----------+
|
||||
|
|
||||
(factura, customer, CRM)
|
||||
|
|
||||
DiDi platform API
|
||||
(analize text/image/audio/video)
|
||||
```
|
||||
|
||||
## Stack tehnic
|
||||
|
||||
| Componenta | Versiune |
|
||||
|------------|----------|
|
||||
| Next.js | 16.2.1 (App Router) |
|
||||
| React | 19.2.4 |
|
||||
| TypeScript | 5.x |
|
||||
| Tailwind CSS | 4.x |
|
||||
| NextAuth (Auth.js) | 5.0 beta |
|
||||
| Stripe | 21.0 |
|
||||
| Node.js | 20 (in container) |
|
||||
|
||||
## Structura folder
|
||||
|
||||
```
|
||||
website/
|
||||
├── README.md # Acest fisier
|
||||
├── INSTALL.md # Build + deployment
|
||||
├── OPERATIONS.md # Operare, log-uri, troubleshooting
|
||||
├── CONFIGURATION.md # Env vars, integrari, credentiale
|
||||
├── Dockerfile # Multi-stage: dev / builder / prod
|
||||
├── docker-compose.yml # Stack de productie
|
||||
├── .env.production # Configurare prod (NU se commiteaza)
|
||||
├── package.json
|
||||
├── tsconfig.json
|
||||
├── next.config.ts
|
||||
├── eslint.config.mjs
|
||||
├── postcss.config.mjs
|
||||
├── public/ # Static assets (clossersLogo2.png etc.)
|
||||
├── src/
|
||||
│ ├── app/ # App Router (Next.js 16)
|
||||
│ │ ├── (public)/ # Pagini publice fara auth
|
||||
│ │ │ ├── page.tsx # Homepage
|
||||
│ │ │ ├── about/
|
||||
│ │ │ ├── services/
|
||||
│ │ │ ├── pricing/
|
||||
│ │ │ ├── contact/
|
||||
│ │ │ ├── privacy/
|
||||
│ │ │ ├── terms/
|
||||
│ │ │ └── layout.tsx # Navbar + Footer + Cookie consent
|
||||
│ │ ├── (auth)/ # Login / Register
|
||||
│ │ │ ├── login/
|
||||
│ │ │ └── register/
|
||||
│ │ ├── (dashboard)/dashboard/# Zona client autentificat
|
||||
│ │ │ ├── page.tsx # Overview
|
||||
│ │ │ ├── analiza/ # Run analiza
|
||||
│ │ │ ├── analize/ # Istoric analize + rapoarte PDF
|
||||
│ │ │ ├── achizitioneaza/ # Cumparare servicii
|
||||
│ │ │ ├── checkout/success/ # Stripe success callback
|
||||
│ │ │ ├── credits/ # Credite + consum (real-time)
|
||||
│ │ │ ├── invoices/ # Facturi cu download PDF
|
||||
│ │ │ ├── profile/ # Profil + GDPR (export, delete)
|
||||
│ │ │ └── subscription/ # Abonament + upgrade/downgrade
|
||||
│ │ ├── api/ # API routes (server-side)
|
||||
│ │ │ ├── auth/[...nextauth]/ # Auth.js handler
|
||||
│ │ │ ├── analyze/ # Analiza pipeline
|
||||
│ │ │ ├── analysis-reports/
|
||||
│ │ │ ├── analysis-report-pdf/
|
||||
│ │ │ ├── checkout/ # Stripe Checkout Session
|
||||
│ │ │ ├── subscribe/ # Stripe Subscription
|
||||
│ │ │ ├── subscription/manage/ # Upgrade/downgrade/cancel
|
||||
│ │ │ ├── customer/me/ # Get current user customer
|
||||
│ │ │ ├── credits/ # Credite + history
|
||||
│ │ │ ├── erp/[...path]/ # Proxy ERPNext
|
||||
│ │ │ ├── invoice-pdf/ # Download factura PDF
|
||||
│ │ │ ├── leads/ # Lead creation (contact form)
|
||||
│ │ │ ├── webhooks/stripe/ # Stripe webhook handler
|
||||
│ │ │ └── gdpr/ # Export + delete account
|
||||
│ │ │ ├── export/
|
||||
│ │ │ └── delete/
|
||||
│ │ ├── layout.tsx # Root layout
|
||||
│ │ ├── sitemap.ts
|
||||
│ │ └── robots.ts
|
||||
│ ├── components/ # React components
|
||||
│ │ ├── layout/ # Navbar, Footer, DashboardSidebar
|
||||
│ │ ├── forms/ # ContactForm
|
||||
│ │ ├── providers/ # SessionProvider
|
||||
│ │ └── ui/ # CookieConsent, SignOutButton
|
||||
│ ├── i18n/ # Traduceri ro.json + en.json
|
||||
│ ├── lib/ # Helpers server-side
|
||||
│ │ ├── auth.ts # Auth.js config (Keycloak)
|
||||
│ │ ├── erpnext.ts # ERPNext REST client
|
||||
│ │ ├── stripe.ts # Stripe config + price map
|
||||
│ │ ├── stripe-fulfillment.ts # Webhook fulfillment logic
|
||||
│ │ ├── api.ts # Client API (browser)
|
||||
│ │ ├── analysis-display.ts # Format rezultate analize
|
||||
│ │ ├── analysis-report-pdf.ts# Generare PDF (jsPDF)
|
||||
│ │ └── analysis-report-store.ts # Salvare PDF in ERPNext
|
||||
│ ├── middleware.ts # Auth middleware (/dashboard/*)
|
||||
│ └── types/ # TypeScript types
|
||||
└── scripts/
|
||||
└── archive/ # Scripturi generare doc-uri (one-off)
|
||||
```
|
||||
|
||||
Documentatia de proiect (arhitectura, documentatia API, manuale, caiet de
|
||||
sarcini) se livreaza separat, in dosarul de livrare — nu face parte din repo.
|
||||
|
||||
## Quickstart
|
||||
|
||||
Cere docker + docker compose v2 si reteaua `didi-network`:
|
||||
|
||||
```bash
|
||||
docker network create didi-network 2>/dev/null || true
|
||||
```
|
||||
|
||||
Build + start:
|
||||
|
||||
```bash
|
||||
cd ~/website
|
||||
cp .env.production.example .env.production # (daca exista, sau editeaza .env.production existent)
|
||||
docker compose up -d --build
|
||||
```
|
||||
|
||||
Acceseaza: http://localhost:3000
|
||||
|
||||
Pentru detalii, vezi [INSTALL.md](./INSTALL.md).
|
||||
|
||||
## Pagini
|
||||
|
||||
### Pagini publice (fara login)
|
||||
|
||||
| Ruta | Descriere |
|
||||
|------|-----------|
|
||||
| `/` | Homepage (continut din ERPNext CMS) |
|
||||
| `/services` | Module AI DiDi (6 servicii) |
|
||||
| `/about` | Despre Clossers + DiDi |
|
||||
| `/pricing` | 14 servicii one-time + 4 abonamente recurente |
|
||||
| `/contact` | Formular contact (creeaza Lead in ERPNext) |
|
||||
| `/privacy` | Politica de confidentialitate (GDPR) |
|
||||
| `/terms` | Termeni si conditii |
|
||||
|
||||
### Pagini auth
|
||||
|
||||
| Ruta | Descriere |
|
||||
|------|-----------|
|
||||
| `/login` | Redirect la Keycloak SSO |
|
||||
| `/register` | Redirect la Keycloak registration |
|
||||
|
||||
### Pagini dashboard (auth obligatoriu)
|
||||
|
||||
| Ruta | Descriere |
|
||||
|------|-----------|
|
||||
| `/dashboard` | Overview - facturi recente, credite, achizitii |
|
||||
| `/dashboard/analiza` | Selecteaza factura + ruleaza analiza |
|
||||
| `/dashboard/analize` | Istoric analize + descarcare rapoarte PDF |
|
||||
| `/dashboard/invoices` | Facturi emise + download PDF |
|
||||
| `/dashboard/credits` | Credite disponibile + istoric consum |
|
||||
| `/dashboard/achizitioneaza` | Servicii one-time + abonamente |
|
||||
| `/dashboard/subscription` | Plan curent + upgrade/downgrade/cancel |
|
||||
| `/dashboard/profile` | Profil + GDPR (export, delete) |
|
||||
| `/dashboard/checkout/success` | Callback post-Stripe |
|
||||
|
||||
## API routes
|
||||
|
||||
### Public
|
||||
| Endpoint | Metoda | Descriere |
|
||||
|----------|--------|-----------|
|
||||
| `/api/leads` | POST | Creeaza Lead in ERPNext din formular contact |
|
||||
| `/api/webhooks/stripe` | POST | Webhook Stripe (events) |
|
||||
|
||||
### Autentificate
|
||||
| Endpoint | Metoda | Descriere |
|
||||
|----------|--------|-----------|
|
||||
| `/api/auth/[...nextauth]` | GET/POST | Auth.js handler |
|
||||
| `/api/analyze` | GET, POST | Lista analize + run + polling |
|
||||
| `/api/checkout` | POST | Creeaza Stripe Checkout (one-time) |
|
||||
| `/api/subscribe` | POST | Creeaza Stripe Subscription |
|
||||
| `/api/subscription/manage` | POST | Upgrade/downgrade/cancel |
|
||||
| `/api/customer/me` | GET | Datele Customer din ERPNext |
|
||||
| `/api/credits` | GET | Credite + istoric |
|
||||
| `/api/erp/[...path]` | * | Proxy autentificat catre ERPNext |
|
||||
| `/api/invoice-pdf` | GET | Download factura PDF |
|
||||
| `/api/analysis-reports` | GET, POST | List + salvare rapoarte |
|
||||
| `/api/analysis-report-pdf` | GET | Download raport analiza PDF |
|
||||
| `/api/gdpr/export` | GET | Export date utilizator (JSON) |
|
||||
| `/api/gdpr/delete` | POST | Cerere stergere cont |
|
||||
|
||||
## Integrari
|
||||
|
||||
| Sistem | Protocol | Scop |
|
||||
|--------|----------|------|
|
||||
| ERPNext | REST API (token auth) | Facturi, customeri, lead-uri, CMS |
|
||||
| Stripe | API + webhook | Plati one-time + recurente |
|
||||
| Keycloak | OIDC | SSO (autentificare clienti) |
|
||||
| DiDi platform | REST API (Bearer JWT) | Analize text/image/audio/video |
|
||||
| SendGrid | (indirect prin ERPNext SMTP) | Email tranzactional |
|
||||
|
||||
## Functionalitati cheie
|
||||
|
||||
- Design responsive (desktop/tablet/mobile), WCAG 2.1 AA
|
||||
- SEO (sitemap.xml, robots.txt, Open Graph)
|
||||
- GDPR: cookie consent, export date, dreptul la stergere
|
||||
- i18n RO + EN cu language switcher
|
||||
- PDF generation (facturi + rapoarte analize)
|
||||
- Webhook idempotency (Payment Log cu stripe_session_id unique)
|
||||
|
||||
## Documentatie detaliata
|
||||
|
||||
| Document | Scop |
|
||||
|----------|------|
|
||||
| [INSTALL.md](./INSTALL.md) | Build de la 0, dependinte, deployment |
|
||||
| [OPERATIONS.md](./OPERATIONS.md) | Restart, log-uri, debug |
|
||||
| [CONFIGURATION.md](./CONFIGURATION.md) | Env vars complete, integrari |
|
||||
|
||||
## Test user
|
||||
|
||||
Pentru testare:
|
||||
- Email: `test@didi.local`
|
||||
- Parola: `Test1234!`
|
||||
- (creat in Keycloak local, realm `didi-clients` — acelasi nume ca pe platforma reala)
|
||||
|
||||
## Suport
|
||||
|
||||
Pentru intrebari tehnice: office@clossers.com
|
||||
Loading…
Add table
Add a link
Reference in a new issue