How sverdam/retotc2005b works
1. This repository is split into two deployable parts: a TypeScript backend API in back-end/ and a Vite/React frontend SPA in front-end/. The browser talks to the backend over HTTP; the backend talks to a relational database and the local file system.
2. The backend is the system’s core. back-end/index.ts is the entry point, and src/routes/index.ts aggregates the feature routes. The README confirms the backend reads a .env file for database credentials and a JWT secret, and it initializes the database schema from an empty database on startup.
3. Data access is organized around domain models in src/models/ and a database connection in src/connection/connection.ts. The model set shows the main business entities: company, category, contact, location, filter, companyFilter, textModule, fileModule, and user.
4. The backend API is split by resource, with matching controllers/ and routes/ files for companies, categories, contacts, locations, filters, text modules, file modules, and users. authRoutes.ts is separate, which indicates authentication is handled as a distinct boundary from the rest of the CRUD/API surface.
5. Security is layered in src/security/ and src/middlewares/authMiddleware.ts. JWT signing/verification lives in jwt.ts, password hashing in hashing.ts, and the auth middleware likely protects admin or mutation routes. This makes user identity and route authorization a first-class part of the backend architecture.
6. File uploads are a separate subsystem. src/middlewares/multer.ts handles multipart uploads, and the back-end/files/ tree is partitioned into documents, images, logos, and temp. fileModuleController.ts and services/fileModuleService.ts suggest uploaded files are tracked as domain records, not just stored as raw blobs.
7. The backend appears to support a directory/catalog domain centered on companies. Supporting entities like categories, locations, filters, and text modules imply a company profile can be enriched with structured metadata, searchable attributes, and attached content/files.
8. The frontend is a client-side React application with route-based pages defined in src/routes/index.tsx. The main screens are Directory, UserAdminPage, and ErrorPage, which suggests a public browsing experience plus an authenticated administration area.
9. UI composition on the frontend is componentized around directory browsing and admin actions: DirectoryCard, FilterModal, DeleteConfirmModal, and Footer. This points to a flow where users browse companies, refine results with filters, and admins can confirm destructive actions.
10. The frontend’s API boundary is centralized in src/api/CompanyAPI.ts and src/api/index.ts, so the UI does not call the backend directly from each component. That separation makes the HTTP contract an explicit layer between presentation and backend services.
11. The main runtime data flow is: user interaction in the React SPA → API calls through the frontend API layer → backend routes/controllers → model/database layer and, when needed, file upload/storage handling. Authenticated flows additionally pass through JWT-based middleware before reaching protected controllers.
12. In architectural terms, this is a modular monolith: one backend service with clear internal boundaries by feature, one frontend SPA, one database, and local filesystem storage for uploaded assets. The most important diagram boundaries are frontend vs backend, API vs persistence, and authenticated vs public routes.
Main entry points: index.ts Route hub · company.ts Domain models · index.tsx Page routes · textModuleRoutes.ts Content API
Components 20
Front-end SPA
Client-side React application for browsing the directory and administering users.
- App shell · Bootstraps the SPA and global UI styles.
front-end/src/main.tsx - Page routes · Defines the main client-side screens and navigation.
front-end/src/routes/index.tsx - Directory · Public browsing experience for companies and filters.
front-end/src/pages/Directory.tsx - Admin page · Authenticated administration surface for user or content management.
front-end/src/pages/UserAdminPage.tsx - Error page · Fallback screen for invalid or failed routes.
front-end/src/pages/ErrorPage.tsx - Directory UI · Cards, filters, modals, and footer used in the directory flow.
front-end/src/components/DirectoryCard.tsx - API layer · Centralized browser-to-backend request wrapper.
front-end/src/api/index.ts - Company API · Frontend contract for directory and company-related calls.
front-end/src/api/CompanyAPI.ts
Back-end API
TypeScript service that exposes the HTTP API, auth, persistence, and file handling.
- Server entry · Starts the backend service and wires the application runtime.
back-end/index.ts - Route hub · Aggregates feature routes into the API surface.
back-end/src/routes/index.ts - Auth routes · Dedicated authentication endpoints separate from CRUD resources.
back-end/src/routes/authRoutes.ts - Company API · Company read/write endpoints and controllers.
back-end/src/routes/companyRoutes.ts - Catalog API · Category, location, filter, and contact endpoints that enrich company data.
back-end/src/routes/categoryRoutes.ts - Content API · Text and file module endpoints for attached content.
back-end/src/routes/textModuleRoutes.ts - User API · User administration endpoints.
back-end/src/routes/userRoutes.ts - Auth middleware · Verifies JWTs and protects sensitive routes.
back-end/src/middlewares/authMiddleware.ts - Security utils · Password hashing and JWT helpers used by auth flows.
back-end/src/security/jwt.ts - Domain models · Company, user, category, location, filter, text, file, and contact entities.
back-end/src/models/company.ts - DB connection · Database connection used by the model layer.
back-end/src/connection/connection.ts
Storage
Relational database and local filesystem used by the backend.
- File storage · Uploaded documents, images, logos, and temp files on disk.
back-end/files
Connections 23
- App shell → Page routes: mounts · The SPA entry mounts the client-side route tree.
- Page routes → Directory: renders · Route tree serves the directory browsing page.
- Page routes → Admin page: renders · Route tree serves the administration page.
- Page routes → Error page: renders · Route tree serves the fallback error page.
- Directory → Directory UI: uses · Directory page composes cards, filters, and modals.
- Admin page → Directory UI: uses · Admin flow reuses shared UI components.
- Directory UI → API layer: calls · UI components trigger API requests through the shared client.
- API layer → Company API: exports · Central API layer exposes the company contract.
- Company API → Route hub: HTTP · Browser requests travel to the backend route hub.
- Server entry → Route hub: registers · Server bootstrap attaches the aggregate routes.
- Route hub → Auth routes: includes · Main router includes dedicated auth endpoints.
- Route hub → Company API: includes · Main router includes company endpoints.
- Route hub → Catalog API: includes · Main router includes catalog and enrichment endpoints.
- Route hub → Content API: includes · Main router includes content and file module endpoints.
- Route hub → User API: includes · Main router includes user administration endpoints.
- Auth routes → Auth middleware: protects · Authenticated access passes through JWT middleware.
- Company API → Domain models: reads/writes · Company controllers operate through domain models.
- Catalog API → Domain models: reads/writes · Catalog controllers persist structured metadata.
- Content API → Domain models: reads/writes · Content controllers persist text and file module records.
- User API → Domain models: reads/writes · User controllers operate through the user model.
- Domain models → DB connection: queries · Models depend on the database connection.
- Content API → File storage: stores · File module handling moves uploads into local storage.
- Security utils → Auth routes: supports · Hashing and JWT helpers underpin authentication.