# dincaalex/unilink architecture

> Architecture diagram of the GitHub repository dincaalex/unilink, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dincaalex/unilink
- Repository: https://github.com/dincaalex/unilink

## Overview

1. **Repo shape**
   - This is a two-part local full-stack prototype: `sanmarcos-jobs/` is the React frontend, and `server/` is the Express + SQLite backend.
   - The root `package.json` only orchestrates both apps, so the diagram should show one developer command starting two separate runtimes.

2. **Runtime entrypoints**
   - Frontend: Vite serves a single-page app from `sanmarcos-jobs/src/main.jsx` into `index.html`.
   - Backend: `server/index.js` exposes all API endpoints under `/api`.
   - Dev flow is local-only: frontend on `5173`, backend on `3001`, no external SaaS dependencies.

3. **Frontend app shell**
   - The frontend is organized around pages, reusable components, and a global context.
   - `App.jsx` and `main.jsx` provide the app shell and routing; `Navbar`, `GlowInput`, and `Select` are shared UI pieces.

4. **Frontend state boundary**
   - `src/context/AppDataContext.jsx` is the main client-side state hub.
   - It centralizes authenticated user/session data plus domain data such as jobs, student profile, company profile, and applications.
   - This context is the main boundary between UI screens and backend data access.

5. **Frontend data access**
   - `src/lib/api.js` is the HTTP client used by the UI to talk to the backend.
   - `src/lib/useLocalStorageState.js` suggests some client-side persistence for UI/session-related state, but the authoritative data lives in SQLite on the server.

6. **Frontend screens and flows**
   - The main pages are: `LoginPage`, `FeedPage`, `JobDetailPage`, `NewJobPage`, `ProfilePage`, `EditProfilePage`, and `CvPrintPage`.
   - The user flow is: login → browse/filter feed → open job detail → apply or publish (depending on role) → manage profile/CV.
   - `CvPrintPage` is a print-friendly view intended for the browser’s print/PDF dialog rather than a server-side PDF service.

7. **Backend API boundary**
   - `server/index.js` is the application boundary for all business operations.
   - The API surface is small and domain-focused: login, jobs, profile CRUD for student/company, and applications.
   - There is no separate auth service, queue, or worker layer.

8. **Backend data layer**
   - `server/db.js` defines the SQLite schema and database access logic using `better-sqlite3`.
   - Data is stored in a single file, `server/data.sqlite`, with WAL mode enabled.
   - The schema includes `users`, `students`, `companies`, `jobs`, and `applications`.

9. **Seed and bootstrap behavior**
   - `server/seedData.js` provides initial demo content.
   - On first backend startup, the database file is created and seeded automatically, so the app is self-contained and runnable from scratch.
   - This means the architecture diagram should show bootstrap/seed logic as part of the backend initialization path.

10. **Domain model and persistence**
   - Jobs, profiles, and applications are persisted in SQLite; relationships are simple and direct.
   - Several composite fields such as skills, experience, education, certifications, requirements, and benefits are stored as JSON text in single columns to keep the schema lightweight.
   - Applications are a separate table keyed by `studentId` and `jobId`, making postulation state a first-class persisted entity.

11. **Role model**
   - The system has two operational roles: student and company.
   - Students can browse jobs, apply, and manage their own profile/CV.
   - Companies can manage their profile and create job postings; the backend enforces this with role checks such as the `x-role: empresa` header on job creation.
   - There is no university admin role implemented yet.

12. **Authentication model**
   - Login is intentionally simple: `POST /login` checks email/password against the `users` table and returns the role.
   - There are no JWTs, server sessions, or password hashing in this prototype.
   - Frontend route protection is also minimal, so the role is mostly used to control UI behavior and API access.

13. **What to emphasize in an architecture diagram**
   - Draw one client SPA talking directly to one local API server.
   - Put SQLite as the single source of truth behind the API.
   - Show the global React context as the client-side state coordinator.
   - Show the main domain flows separately: jobs, profiles, and applications.
   - Note that the system is fully local, seeded on startup, and designed as a course prototype rather than a production deployment.

Main entry points: [`sanmarcos-jobs/src/App.jsx`](https://github.com/dincaalex/unilink/blob/main/sanmarcos-jobs/src/App.jsx) (App shell), [`sanmarcos-jobs/src/context/AppDataContext.jsx`](https://github.com/dincaalex/unilink/blob/main/sanmarcos-jobs/src/context/AppDataContext.jsx) (App data), [`server/index.js`](https://github.com/dincaalex/unilink/blob/main/server/index.js) (API server), [`package.json`](https://github.com/dincaalex/unilink/blob/main/package.json) (Dev start)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_root["Workspace"]
  node_root_dev["Dev start<br/>workspace script<br/>[package.json]"]
end

subgraph group_frontend["Frontend"]
  node_fe_vite["Vite app<br/>spa runtime<br/>[vite.config.js]"]
  node_fe_main["Entry<br/>react bootstrap<br/>[main.jsx]"]
  node_fe_app["App shell<br/>router shell<br/>[App.jsx]"]
  node_fe_ctx["App data<br/>client state<br/>[AppDataContext.jsx]"]
  node_fe_api["API client<br/>http client<br/>[api.js]"]
  node_fe_ls["Local state<br/>persistence helper"]
  node_fe_nav["Navbar<br/>shared ui<br/>[Navbar.jsx]"]
  node_fe_input["GlowInput<br/>shared ui<br/>[GlowInput.jsx]"]
  node_fe_select["Select<br/>shared ui<br/>[Select.jsx]"]
  node_fe_login["Login<br/>page<br/>[LoginPage.jsx]"]
  node_fe_feed["Feed<br/>page<br/>[FeedPage.jsx]"]
  node_fe_detail["Job detail<br/>page<br/>[JobDetailPage.jsx]"]
  node_fe_newjob["New job<br/>page<br/>[NewJobPage.jsx]"]
  node_fe_profile["Profile<br/>page<br/>[ProfilePage.jsx]"]
  node_fe_editprofile["Edit profile<br/>page"]
  node_fe_cvprint["CV print<br/>page<br/>[CvPrintPage.jsx]"]
end

subgraph group_backend["Backend"]
  node_be_server["API server<br/>express app<br/>[index.js]"]
  node_be_db[("SQLite store<br/>database access<br/>[db.js]")]
  node_be_seed["Seed data<br/>bootstrap seed<br/>[seedData.js]"]
  node_be_data[("data.sqlite<br/>sqlite file")]
end

node_root_dev -->|"starts"| node_fe_vite
node_root_dev -->|"starts"| node_be_server
node_fe_vite -->|"serves"| node_fe_main
node_fe_main -->|"boots"| node_fe_app
node_fe_app -->|"wraps"| node_fe_ctx
node_fe_app -->|"renders"| node_fe_nav
node_fe_app -->|"routes"| node_fe_login
node_fe_app -->|"routes"| node_fe_feed
node_fe_app -->|"routes"| node_fe_detail
node_fe_app -->|"routes"| node_fe_newjob
node_fe_app -->|"routes"| node_fe_profile
node_fe_app -->|"routes"| node_fe_editprofile
node_fe_app -->|"routes"| node_fe_cvprint
node_fe_ctx -->|"calls"| node_fe_api
node_fe_ctx -->|"persists"| node_fe_ls
node_fe_ctx -->|"api"| node_be_server
node_be_server -->|"queries"| node_be_db
node_be_server -->|"boots with"| node_be_seed
node_be_seed -->|"initializes"| node_be_data
node_be_db -->|"stores"| node_be_data

click node_root_dev "https://github.com/dincaalex/unilink/blob/main/package.json"
click node_fe_vite "https://github.com/dincaalex/unilink/blob/main/sanmarcos-jobs/vite.config.js"
click node_fe_main "https://github.com/dincaalex/unilink/blob/main/sanmarcos-jobs/src/main.jsx"
click node_fe_app "https://github.com/dincaalex/unilink/blob/main/sanmarcos-jobs/src/App.jsx"
click node_fe_ctx "https://github.com/dincaalex/unilink/blob/main/sanmarcos-jobs/src/context/AppDataContext.jsx"
click node_fe_api "https://github.com/dincaalex/unilink/blob/main/sanmarcos-jobs/src/lib/api.js"
click node_fe_ls "https://github.com/dincaalex/unilink/blob/main/sanmarcos-jobs/src/lib/useLocalStorageState.js"
click node_fe_nav "https://github.com/dincaalex/unilink/blob/main/sanmarcos-jobs/src/components/Navbar.jsx"
click node_fe_input "https://github.com/dincaalex/unilink/blob/main/sanmarcos-jobs/src/components/GlowInput.jsx"
click node_fe_select "https://github.com/dincaalex/unilink/blob/main/sanmarcos-jobs/src/components/Select.jsx"
click node_fe_login "https://github.com/dincaalex/unilink/blob/main/sanmarcos-jobs/src/pages/LoginPage.jsx"
click node_fe_feed "https://github.com/dincaalex/unilink/blob/main/sanmarcos-jobs/src/pages/FeedPage.jsx"
click node_fe_detail "https://github.com/dincaalex/unilink/blob/main/sanmarcos-jobs/src/pages/JobDetailPage.jsx"
click node_fe_newjob "https://github.com/dincaalex/unilink/blob/main/sanmarcos-jobs/src/pages/NewJobPage.jsx"
click node_fe_profile "https://github.com/dincaalex/unilink/blob/main/sanmarcos-jobs/src/pages/ProfilePage.jsx"
click node_fe_editprofile "https://github.com/dincaalex/unilink/blob/main/sanmarcos-jobs/src/pages/EditProfilePage.jsx"
click node_fe_cvprint "https://github.com/dincaalex/unilink/blob/main/sanmarcos-jobs/src/pages/CvPrintPage.jsx"
click node_be_server "https://github.com/dincaalex/unilink/blob/main/server/index.js"
click node_be_db "https://github.com/dincaalex/unilink/blob/main/server/db.js"
click node_be_seed "https://github.com/dincaalex/unilink/blob/main/server/seedData.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_root_dev toneBlue
class node_fe_vite,node_fe_main,node_fe_app,node_fe_ctx,node_fe_api,node_fe_ls,node_fe_nav,node_fe_input,node_fe_select,node_fe_login,node_fe_feed,node_fe_detail,node_fe_newjob,node_fe_profile,node_fe_editprofile,node_fe_cvprint toneAmber
class node_be_server,node_be_db,node_be_seed,node_be_data toneMint
```

## Components

### Workspace

Local prototype workspace orchestrating frontend and backend runtimes.

- [Dev start](https://github.com/dincaalex/unilink/blob/main/package.json): workspace script · Runs both client and server locally from the root package. · `package.json`

### Frontend

React SPA served by Vite.

- [Vite app](https://github.com/dincaalex/unilink/blob/main/sanmarcos-jobs/vite.config.js): spa runtime · Serves the React single-page app on the local dev port. · `sanmarcos-jobs/vite.config.js`
- [Entry](https://github.com/dincaalex/unilink/blob/main/sanmarcos-jobs/src/main.jsx): react bootstrap · Mounts the app into the HTML shell. · `sanmarcos-jobs/src/main.jsx`
- [App shell](https://github.com/dincaalex/unilink/blob/main/sanmarcos-jobs/src/App.jsx): router shell · Defines the top-level app layout and route flow. · `sanmarcos-jobs/src/App.jsx`
- [App data](https://github.com/dincaalex/unilink/blob/main/sanmarcos-jobs/src/context/AppDataContext.jsx): client state · Global state boundary for session, jobs, profiles, and applications. · `sanmarcos-jobs/src/context/AppDataContext.jsx`
- [API client](https://github.com/dincaalex/unilink/blob/main/sanmarcos-jobs/src/lib/api.js): http client · Browser client used to call the backend API. · `sanmarcos-jobs/src/lib/api.js`
- [Local state](https://github.com/dincaalex/unilink/blob/main/sanmarcos-jobs/src/lib/useLocalStorageState.js): persistence helper · Client-side storage helper for lightweight persisted UI state. · `sanmarcos-jobs/src/lib/useLocalStorageState.js`
- [Navbar](https://github.com/dincaalex/unilink/blob/main/sanmarcos-jobs/src/components/Navbar.jsx): shared ui · Shared navigation chrome across screens. · `sanmarcos-jobs/src/components/Navbar.jsx`
- [GlowInput](https://github.com/dincaalex/unilink/blob/main/sanmarcos-jobs/src/components/GlowInput.jsx): shared ui · Reusable form input component. · `sanmarcos-jobs/src/components/GlowInput.jsx`
- [Select](https://github.com/dincaalex/unilink/blob/main/sanmarcos-jobs/src/components/Select.jsx): shared ui · Reusable select component. · `sanmarcos-jobs/src/components/Select.jsx`
- [Login](https://github.com/dincaalex/unilink/blob/main/sanmarcos-jobs/src/pages/LoginPage.jsx): page · Simple role-aware login screen. · `sanmarcos-jobs/src/pages/LoginPage.jsx`
- [Feed](https://github.com/dincaalex/unilink/blob/main/sanmarcos-jobs/src/pages/FeedPage.jsx): page · Browse and filter jobs. · `sanmarcos-jobs/src/pages/FeedPage.jsx`
- [Job detail](https://github.com/dincaalex/unilink/blob/main/sanmarcos-jobs/src/pages/JobDetailPage.jsx): page · View a job and act on it. · `sanmarcos-jobs/src/pages/JobDetailPage.jsx`
- [New job](https://github.com/dincaalex/unilink/blob/main/sanmarcos-jobs/src/pages/NewJobPage.jsx): page · Company posting flow. · `sanmarcos-jobs/src/pages/NewJobPage.jsx`
- [Profile](https://github.com/dincaalex/unilink/blob/main/sanmarcos-jobs/src/pages/ProfilePage.jsx): page · View student or company profile data. · `sanmarcos-jobs/src/pages/ProfilePage.jsx`
- [Edit profile](https://github.com/dincaalex/unilink/blob/main/sanmarcos-jobs/src/pages/EditProfilePage.jsx): page · Edit student or company profile data. · `sanmarcos-jobs/src/pages/EditProfilePage.jsx`
- [CV print](https://github.com/dincaalex/unilink/blob/main/sanmarcos-jobs/src/pages/CvPrintPage.jsx): page · Print-friendly CV view for browser print or PDF export. · `sanmarcos-jobs/src/pages/CvPrintPage.jsx`

### Backend

Express API with SQLite persistence.

- [API server](https://github.com/dincaalex/unilink/blob/main/server/index.js): express app · Local backend boundary exposing all business operations under /api. · `server/index.js`
- [SQLite store](https://github.com/dincaalex/unilink/blob/main/server/db.js): database access · Single-file SQLite persistence with schema and query logic. · `server/db.js`
- [Seed data](https://github.com/dincaalex/unilink/blob/main/server/seedData.js): bootstrap seed · Initial demo content loaded on first startup. · `server/seedData.js`
- **data.sqlite**: sqlite file · Persistent local database file.

## Connections

- Dev start → Vite app: starts · Launches the frontend dev server.
- Dev start → API server: starts · Launches the backend API server.
- Vite app → Entry: serves · Vite serves the SPA entrypoint.
- Entry → App shell: boots · Mounts the app shell and routing.
- App shell → App data: wraps · Provides global client state to screens.
- App shell → Navbar: renders · Shared chrome used across the app.
- App shell → Login: routes · Auth entry screen.
- App shell → Feed: routes · Job browsing screen.
- App shell → Job detail: routes · Job detail screen.
- App shell → New job: routes · Company posting screen.
- App shell → Profile: routes · Profile viewing screen.
- App shell → Edit profile: routes · Profile editing screen.
- App shell → CV print: routes · Print-oriented CV screen.
- App data → API client: calls · Uses the HTTP client for backend access.
- App data → Local state: persists · Stores lightweight client-side state.
- App data → API server: api · Synchronizes app data through the backend API.
- API server → SQLite store: queries · Handles login, jobs, profiles, and applications through the DB layer.
- API server → Seed data: boots with · Initializes the local demo dataset on first run.
- Seed data → data.sqlite: initializes · Creates the persisted database file when missing.
- SQLite store → data.sqlite: stores · Reads and writes the SQLite database file.
